Skip to content
Snippets Groups Projects
Commit a19969a9 authored by al.schwinn's avatar al.schwinn
Browse files

Bug 1201 - Add possibility to read out PLC run-state

parent 4b48bfdb
No related branches found
No related tags found
No related merge requests found
......@@ -160,6 +160,17 @@ namespace Silecs
return 0;
}
bool SNAP7Connection::isRunning(PLC* thePLC)
{
UnitStatusType statusStruct;
this->readUnitStatus(thePLC, statusStruct);
switch (statusStruct.status)
{
case S7CpuStatusRun : return true;
case S7CpuStatusStop: return false;
default : throw SilecsException(__FILE__, __LINE__, UNKNOWN_ERROR,std::string("PLC Status is: UNKNOWN"));
}
}
//-------------------------------------------------------------------------------------------------------------------
int SNAP7Connection::readData(PLC* thePLC, unsigned long DBn, unsigned long offset, unsigned long size, unsigned char* pBuffer)
......
......@@ -40,6 +40,8 @@ namespace Silecs
int readCPUInfo(PLC* thePLC, CPUInfoType& dataStruct);
int readCPInfo(PLC* thePLC, CPInfoType& dataStruct);
bool isRunning(PLC* thePLC);
int readData(PLC* thePLC, unsigned long DBn, unsigned long offset, unsigned long size, unsigned char* pBuffer);
int writeData(PLC* thePLC, unsigned long DBn, unsigned long offset, unsigned long size, unsigned char* pBuffer);
......
......@@ -263,7 +263,12 @@ namespace Silecs
return -1;
}
//PERFORM COLD RESTART
bool Connection::isRunning(PLC* thePLC)
{
throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
return -1;
}
int Connection::coldRestart(PLC* thePLC)
{
throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
......
......@@ -89,6 +89,10 @@ namespace Silecs
virtual int readUnitStatus(PLC* thePLC, UnitStatusType& dataStruct);
virtual int readCPUInfo(PLC* thePLC, CPUInfoType& dataStruct);
virtual int readCPInfo(PLC* thePLC, CPInfoType& dataStruct);
// true if the "recvUnitStatus" is RUN, false otherwise. Throws exception on failure
virtual bool isRunning(PLC* thePLC);
//SET PLC COLD RESTART
virtual int coldRestart(PLC* thePLC);
virtual int plcStop(PLC* thePLC);
......
......@@ -259,6 +259,11 @@ namespace Silecs
return getConnection()->readUnitStatus(this, dataStruct);
}
bool PLC::isRunning()
{
return getConnection()->isRunning(this);
}
int PLC::recvCPUInfo(CPUInfoType& dataStruct)
{
......
......@@ -270,7 +270,9 @@ namespace Silecs
int recvCPUInfo(CPUInfoType& dataStruct);
int recvCPInfo(CPInfoType& dataStruct);
//Cold RESTART
// true if the "recvUnitStatus" is RUN, false otherwise. Throws exception on failure
bool isRunning();
int sendColdRestart();
int sendPlcStop();
/*!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment