Torc  0.1
Public Types | Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
TorcControl Class Referenceabstract

#include <torccontrol.h>

Inheritance diagram for TorcControl:
[legend]

Public Types

enum  Type { Logic, Timer, Transition }
 

Public Slots

void SubscriberDeleted (QObject *Subscriber)
 
void InputValueChanged (double Value)
 
void InputValidChanged (bool Valid)
 
- Public Slots inherited from TorcDevice
bool GetValid (void)
 
double GetValue (void)
 
double GetDefaultValue (void)
 
QString GetModelId (void)
 
QString GetUniqueId (void)
 
QString GetUserName (void)
 
QString GetUserDescription (void)
 

Public Member Functions

virtual bool Validate (void)
 
virtual TorcControl::Type GetType (void) const =0
 
virtual bool IsPassthrough (void)
 Only certain logic controls can be passthrough. More...
 
virtual bool AllowInputs (void) const
 Most controls have an input side. More...
 
bool IsKnownInput (const QString &Input) const
 
bool IsKnownOutput (const QString &Output) const
 
QString GetUIName (void) override
 
- Public Member Functions inherited from TorcReferenceCounter
 TorcReferenceCounter (void)
 
virtual ~TorcReferenceCounter (void)=default
 
void UpRef (void)
 
virtual bool DownRef (void)
 
bool IsShared (void)
 
- Public Member Functions inherited from TorcHTTPService
 TorcHTTPService (QObject *Parent, const QString &Signature, const QString &Name, const QMetaObject &MetaObject, const QString &Blacklist=QStringLiteral(""))
 
virtual ~TorcHTTPService ()
 
void ProcessHTTPRequest (const QString &PeerAddress, int PeerPort, const QString &LocalAddress, int LocalPort, TorcHTTPRequest &Request) override
 
QVariantMap ProcessRequest (const QString &Method, const QVariant &Parameters, QObject *Connection, bool Authenticated) override
 
QString GetMethod (int Index)
 
QVariant GetProperty (int Index)
 Get the value of a given property. More...
 
QVariantMap GetServiceDetails (void)
 Return a QVariantMap describing the services methods and properties. More...
 
virtual QString GetPresentationURL (void)
 
- Public Member Functions inherited from TorcHTTPHandler
 TorcHTTPHandler (const QString &Signature, const QString &Name)
 
virtual ~TorcHTTPHandler ()
 
QString Signature (void) const
 
bool GetRecursive (void) const
 
QString Name (void) const
 

Static Public Member Functions

static bool ParseTimeString (const QString &Time, int &Days, int &Hours, int &Minutes, int &Seconds, quint64 &DurationInSeconds)
 Parse a Torc time string into days, hours, minutes and, if present, seconds. More...
 
static QString DurationToString (int Days, quint64 Duration)
 
- Static Public Member Functions inherited from TorcReferenceCounter
static void EventLoopEnding (bool Ending)
 

Protected Member Functions

 TorcControl (TorcControl::Type Type, const QVariantMap &Details)
 
virtual ~TorcControl ()=default
 
void Graph (QByteArray *Data)
 Add this control to the state graph. More...
 
bool Finish (void)
 Finish setup of the control. More...
 
void InputValidChangedPriv (QObject *Input, bool Valid)
 
void CheckInputValues (void)
 
void SetValue (double Value) override
 
void SetValid (bool Valid) override
 
virtual void CalculateOutput (void)=0
 
bool CheckForCircularReferences (const QString &UniqueId, const QString &Path) const
 
- Protected Member Functions inherited from TorcDevice
virtual ~TorcDevice ()
 
- Protected Member Functions inherited from TorcHTTPService
void HandleSubscriberDeleted (QObject *Subscriber)
 

Protected Attributes

bool m_parsed
 
bool m_validated
 
QStringList m_inputList
 
QStringList m_outputList
 
QMap< QObject *, QString > m_inputs
 
QMap< QObject *, QString > m_outputs
 
QMap< QObject *, double > m_inputValues
 
QMap< QObject *, double > m_lastInputValues
 
QMap< QObject *, bool > m_inputValids
 
bool m_allInputsValid
 
- Protected Attributes inherited from TorcDevice
double value
 
double defaultValue
 
QString modelId
 
QString uniqueId
 
QString userName
 
QString userDescription
 
QMutex lock
 
bool wasInvalid
 
- Protected Attributes inherited from TorcReferenceCounter
QAtomicInt m_refCount
 
- Protected Attributes inherited from TorcHTTPService
QReadWriteLock m_httpServiceLock
 
- Protected Attributes inherited from TorcHTTPHandler
QString m_signature
 
bool m_recursive
 
QString m_name
 

Friends

class TorcControls
 

Additional Inherited Members

- Signals inherited from TorcDevice
void ValidChanged (bool Valid)
 
void ValueChanged (double Value)
 
- Static Protected Member Functions inherited from TorcHTTPHandler
static bool MethodIsAuthorised (TorcHTTPRequest &Request, int Allowed)
 Check the current request is authorised and set the authentication header if not. More...
 
static void HandleOptions (TorcHTTPRequest &Request, int Allowed)
 
static void HandleFile (TorcHTTPRequest &Request, const QString &Filename, int Cache)
 
- Static Protected Attributes inherited from TorcDevice
static QHash< QString, TorcDevice * > * gDeviceList = new QHash<QString,TorcDevice*>()
 
static QMutex * gDeviceListLock = new QMutex(QMutex::Recursive)
 
- Static Protected Attributes inherited from TorcReferenceCounter
static bool m_eventLoopEnding = false
 
- Properties inherited from TorcDevice
bool valid
 

Detailed Description

The control is 'valid' if all of its inputs are present, valid and have a known value. It can then determine an output value. If 'invalid' the output will be set to the default.

Definition at line 15 of file torccontrol.h.

Member Enumeration Documentation

Enumerator
Logic 
Timer 
Transition 

Definition at line 23 of file torccontrol.h.

Constructor & Destructor Documentation

TorcControl::TorcControl ( TorcControl::Type  Type,
const QVariantMap &  Details 
)
protected

Definition at line 170 of file torccontrol.cpp.

virtual TorcControl::~TorcControl ( )
protectedvirtualdefault

Member Function Documentation

bool TorcControl::AllowInputs ( void  ) const
virtual

Most controls have an input side.

Reimplemented in TorcTimerControl.

Definition at line 290 of file torccontrol.cpp.

virtual void TorcControl::CalculateOutput ( void  )
protectedpure virtual
bool TorcControl::CheckForCircularReferences ( const QString &  UniqueId,
const QString &  Path 
) const
protected

Definition at line 630 of file torccontrol.cpp.

void TorcControl::CheckInputValues ( void  )
protected

Definition at line 543 of file torccontrol.cpp.

QString TorcControl::DurationToString ( int  Days,
quint64  Duration 
)
static

Definition at line 156 of file torccontrol.cpp.

bool TorcControl::Finish ( void  )
protected

Finish setup of the control.

Finish is only called once all other parsing and validation is complete. The control is connected to its input(s) and output(s) and the device marked as validated. Qt::UniqueConnection prevents multiple slot triggering if 'paired' devices identify the same connection.

Note
An output can have only one input/owner.
For outputs, we only connect to TorcOutput objects or TorcControl objects that have inputs. So no connection to TorcTimerControl or any TorcInput.
For inputs, any sensor or control type is valid.
We always assume an object of a given type has the correct signals/slots.
Todo:
Make Outputs 'valid' aware and handle their own defaults if any input/control is invalid.

Definition at line 406 of file torccontrol.cpp.

virtual TorcControl::Type TorcControl::GetType ( void  ) const
pure virtual

Implemented in TorcLogicControl, and TorcTimerControl.

QString TorcControl::GetUIName ( void  )
overridevirtual

Reimplemented from TorcHTTPService.

Definition at line 295 of file torccontrol.cpp.

void TorcControl::Graph ( QByteArray *  Data)
protected

Add this control to the state graph.

Note
If a Logic control has one single sensor input (NOT another control), one or more outputs (NOT controls) and the operation is a straight pass through (TorcLogicControl::NoOperation), then we do not present the control in the stategraph. This makes the graph clearer but the control is still required as Outputs have no understanding of invalid sensor outputs.

Definition at line 326 of file torccontrol.cpp.

void TorcControl::InputValidChanged ( bool  Valid)
slot

Definition at line 560 of file torccontrol.cpp.

void TorcControl::InputValidChangedPriv ( QObject *  Input,
bool  Valid 
)
protected

Definition at line 575 of file torccontrol.cpp.

void TorcControl::InputValueChanged ( double  Value)
slot

Definition at line 508 of file torccontrol.cpp.

bool TorcControl::IsKnownInput ( const QString &  Input) const

Definition at line 303 of file torccontrol.cpp.

bool TorcControl::IsKnownOutput ( const QString &  Output) const

Definition at line 311 of file torccontrol.cpp.

bool TorcControl::IsPassthrough ( void  )
virtual

Only certain logic controls can be passthrough.

Reimplemented in TorcLogicControl.

Definition at line 284 of file torccontrol.cpp.

bool TorcControl::ParseTimeString ( const QString &  Time,
int &  Days,
int &  Hours,
int &  Minutes,
int &  Seconds,
quint64 &  DurationInSeconds 
)
static

Parse a Torc time string into days, hours, minutes and, if present, seconds.

Valid times are of the format MM, HH:MM, DD:HH:MM with an optional trailing .SS for seconds.

Definition at line 36 of file torccontrol.cpp.

void TorcControl::SetValid ( bool  Valid)
overrideprotectedvirtual

Reimplemented from TorcDevice.

Definition at line 615 of file torccontrol.cpp.

void TorcControl::SetValue ( double  Value)
overrideprotectedvirtual

Reimplemented from TorcDevice.

Definition at line 607 of file torccontrol.cpp.

void TorcControl::SubscriberDeleted ( QObject *  Subscriber)
slot

Definition at line 503 of file torccontrol.cpp.

bool TorcControl::Validate ( void  )
virtual

Reimplemented in TorcLogicControl, and TorcTimerControl.

Definition at line 202 of file torccontrol.cpp.

Friends And Related Function Documentation

friend class TorcControls
friend

Definition at line 17 of file torccontrol.h.

Member Data Documentation

bool TorcControl::m_allInputsValid
protected

Definition at line 76 of file torccontrol.h.

QStringList TorcControl::m_inputList
protected

Definition at line 69 of file torccontrol.h.

QMap<QObject*,QString> TorcControl::m_inputs
protected

Definition at line 71 of file torccontrol.h.

QMap<QObject*,bool> TorcControl::m_inputValids
protected

Definition at line 75 of file torccontrol.h.

QMap<QObject*,double> TorcControl::m_inputValues
protected

Definition at line 73 of file torccontrol.h.

QMap<QObject*,double> TorcControl::m_lastInputValues
protected

Definition at line 74 of file torccontrol.h.

QStringList TorcControl::m_outputList
protected

Definition at line 70 of file torccontrol.h.

QMap<QObject*,QString> TorcControl::m_outputs
protected

Definition at line 72 of file torccontrol.h.

bool TorcControl::m_parsed
protected

Definition at line 67 of file torccontrol.h.

bool TorcControl::m_validated
protected

Definition at line 68 of file torccontrol.h.


The documentation for this class was generated from the following files: