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

Bug 1363 - Provide possibility to cold-restart PLC

parent 049919e1
No related branches found
No related tags found
No related merge requests found
......@@ -198,4 +198,37 @@ namespace Silecs
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//Puts the CPU in RUN mode performing a COLD START.
int SNAP7Connection::coldRestart(PLC* thePLC)
{
if(doOpen(thePLC))
{
Lock lock(writeMux_);
int error = Cli_PlcColdStart(sendClient_);
if(error)
throw SilecsException(__FILE__, __LINE__, UNEXPECTED_ERROR," SNAP7 Error: " + getSNAP7ErrorMessage(error));
}
return 0;
}
//Puts the CPU in STOP mode.
int SNAP7Connection::plcStop(PLC* thePLC)
{
if(doOpen(thePLC))
{
Lock lock(writeMux_);
int error = Cli_PlcStop(sendClient_);
if(error)
throw SilecsException(__FILE__, __LINE__, UNEXPECTED_ERROR," SNAP7 Error: " + getSNAP7ErrorMessage(error));
}
return 0;
}
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} // namespace
......@@ -43,6 +43,10 @@ namespace Silecs
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);
//Extension Silecs methods
int coldRestart(PLC* thePLC);
int plcStop(PLC* thePLC);
private:
S7Object recvClient_;
S7Object sendClient_;
......
......@@ -263,6 +263,20 @@ namespace Silecs
return -1;
}
//PERFORM COLD RESTART
int Connection::coldRestart(PLC* thePLC)
{
throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
return -1;
}
//PERFORM COLD RESTART
int Connection::plcStop(PLC* thePLC)
{
throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
return -1;
}
//-------------------------------------------------------------------------------------------------------------------
bool Connection::checkError(PLC* thePLC, int err, bool retry)
......
......@@ -89,6 +89,9 @@ namespace Silecs
virtual int readUnitStatus(PLC* thePLC, UnitStatusType& dataStruct);
virtual int readCPUInfo(PLC* thePLC, CPUInfoType& dataStruct);
virtual int readCPInfo(PLC* thePLC, CPInfoType& dataStruct);
//SET PLC COLD RESTART
virtual int coldRestart(PLC* thePLC);
virtual int plcStop(PLC* thePLC);
protected:
friend class Cluster;
......
......@@ -240,7 +240,7 @@ namespace Silecs
{
if( pDeviceIter->second->hasBlock((*blockIter)->getName()))
{
LOG(COMM) << "Updating block '" << (*blockIter)->getName() << "' for device '" << pDeviceIter->second->getLabel()<< "'";
LOG(COMM) << "Updating block '" << (*blockIter)->getName() << "' for device '" << pDeviceIter->second->getLabel()<< "'";
pDeviceIter->second->recv((*blockIter)->getName());
}
}
......@@ -270,8 +270,22 @@ namespace Silecs
{
return getConnection()->readCPInfo(this, dataStruct);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//Puts the CPU in RUN mode performing a COLD START.
int PLC::sendColdRestart()
{
return getConnection()->coldRestart(this);
//return getConnection()->coldRestart();
}
int PLC::sendPlcStop()
{
return getConnection()->plcStop(this);
//return getConnection()->coldRestart();
}
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int PLC::recv(std::string blockName)
{
//Synchronous data receive
......
......@@ -270,6 +270,9 @@ namespace Silecs
int recvCPUInfo(CPUInfoType& dataStruct);
int recvCPInfo(CPInfoType& dataStruct);
//Cold RESTART
int sendColdRestart();
int sendPlcStop();
/*!
* \brief Acquires one particular registers block of all devices of that PLC.
* The method tries to (re)connect the PLC if the connection is not established yet or unexpectedly interrupted (network failure, PLC down, etc.).
......
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