70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
/* Machine Event
|
|
*
|
|
* Used e.g. to send events to ISMAS
|
|
*
|
|
* Note: It's an Event, not a State!
|
|
* -> An Event may cause a transition to a different state, depending on the current state.
|
|
* -> Compare to edge/level trigger: Event is an "edge", State is a "level"
|
|
* => Do not mix both
|
|
*
|
|
*/
|
|
#include <QDateTime>
|
|
|
|
#include "ATBMachineEvent.h"
|
|
|
|
|
|
ATBMachineEvent::ATBMachineEvent(
|
|
const QString & id,
|
|
const QString & deviceName, // PTU/PRINTER/DC/...
|
|
EVENT_CLASS eventClass, // reason of event: Error/Warning/Alarm
|
|
const QString & name, // 'Event': "E001", "W003"
|
|
const int state,
|
|
const QString & parameter,
|
|
const QString & secondLevelInfo)
|
|
: QEvent(ATB_MACHINE_EVENT)
|
|
, eventId(id)
|
|
, deviceName(deviceName)
|
|
, machineEventClass(eventClass)
|
|
, eventName(name)
|
|
, eventState(state)
|
|
// timestamp including timezone offset
|
|
, timestampString(QDateTime::currentDateTime().toOffsetFromUtc(
|
|
QDateTime::currentDateTime().offsetFromUtc()).toString(Qt::ISODate)
|
|
)
|
|
, parameterString(parameter)
|
|
, secondLevelInfoString(secondLevelInfo)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
QString ATBMachineEvent::getEventClassString(EVENT_CLASS eventClass)
|
|
{
|
|
switch (eventClass) {
|
|
case EVENT_CLASS::WARNING:
|
|
return "WARNING";
|
|
break;
|
|
case EVENT_CLASS::ERROR:
|
|
return "ERROR";
|
|
break;
|
|
case EVENT_CLASS::ALARM:
|
|
return "ALARM";
|
|
break;
|
|
case EVENT_CLASS::DEBUG:
|
|
return "DEBUG";
|
|
break;
|
|
case EVENT_CLASS::STATE:
|
|
return "STATE";
|
|
break;
|
|
case EVENT_CLASS::OPERATE:
|
|
return "OPERATE";
|
|
break;
|
|
case EVENT_CLASS::NOT_DEFINED:
|
|
return "NOT_DEFINED";
|
|
break;
|
|
}
|
|
|
|
return "NOT_DEFINED";
|
|
}
|
|
|