DCPlugin/src/ATBAPP/ATBMachineEvent.cpp

67 lines
1.7 KiB
C++
Raw Normal View History

2023-06-21 10:55:12 +02:00
/* 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
2023-06-26 19:46:22 +02:00
, timestampString(QDateTime::currentDateTime().toOffsetFromUtc(
2023-06-21 10:55:12 +02:00
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::NOT_DEFINED:
return "NOT_DEFINED";
break;
}
return "NOT_DEFINED";
}