diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp index ea562aacb40311a201aa25a30f4013635cea89d0..6f91e021fd6c84ed8c4dfd7b45e2475c4fc59eb9 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp @@ -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) diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.h b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.h index 740dc9bd4cde83420920c53c20383dd6d5093dff..1a86cc943d4a36b6bc29807a24309c38cc409d78 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.h @@ -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); diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp index d89db59b1108b9658020d1699905dbca78af283a..1cf18425468f6c6b07af9e89784d0896bff537dd 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp @@ -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()); diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h index ed9d0177af471602dd917d46873d8f04142ea5ba..0cc27ee12f37d9da1e33e31172d4ef4f14200e7c 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h @@ -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); diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp index 4f92638884add44201c6ec8ebf9de0c95b4f41c9..48e00f9ed01e91c7d29c20dfff4a91c95ccf6f6c 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp @@ -259,6 +259,11 @@ namespace Silecs return getConnection()->readUnitStatus(this, dataStruct); } + bool PLC::isRunning() + { + return getConnection()->isRunning(this); + } + int PLC::recvCPUInfo(CPUInfoType& dataStruct) { diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.h b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.h index 43f513e06a638b703046a8b4baad57620aa8e6b5..b3327be3673cc99ab5d04b653d780e9c2f688264 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.h @@ -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(); /*!