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

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

- automatically print runstate info in silecs-diagnostic-gui
parent 605d60b6
No related branches found
No related tags found
No related merge requests found
......@@ -251,7 +251,10 @@ void diagnosticToolMainView::on_connectButton_clicked()
Utils::displayPLCInformation(plc,ui->InformationMessage);
//highlight PLC background in green
ui->treeWidget->currentItem()->setBackgroundColor(0,Qt::green);
currentItem->setBackgroundColor(0,Qt::green);
//show the run-state of the PLC
mysilecs->updatePLCRunState(currentItem);
// Increment number of connected PLC
mysilecs->counterConnectedPLC++;
......@@ -284,6 +287,9 @@ void diagnosticToolMainView::on_disconnectButton_clicked()
// Cast the linked object PLC type
Silecs::PLC* plc = (Silecs::PLC*)(currentItem->getLinkedObject());
//update the runstate
mysilecs->updatePLCRunState(currentItem);
// Disconnect
plc->disconnect();
......
......@@ -79,6 +79,39 @@ void silecsModule::enableDebugLog()
debugLoggingEnabled_ = true;
}
void silecsModule::updatePLCRunState(Item *plcItem)
{
int index = 1;
try
{
Silecs::PLC* plc = (Silecs::PLC*)(plcItem->getLinkedObject());
if( !plc->isConnected() )
{
plcItem->setText(index,"");
plcItem->setBackgroundColor(index,Qt::white);
}
if( plc->isRunning() )
{
plcItem->setText(index,"running");
plcItem->setBackgroundColor(index,Qt::green);
}
else
{
plcItem->setText(index,"stopped");
plcItem->setBackgroundColor(index,Qt::yellow);
}
}
catch(const Silecs::SilecsException& ex2)
{
plcItem->setText(index,"state unknown");
plcItem->setBackgroundColor(index,Qt::red);
std::string message = "Failed to obtain plc run-state: ";
message += ex2.what();
Utils::logError(messageConsole_,message);
}
}
Item *silecsModule::generateTree(string className, string deployFile)
{
Item *root = NULL;
......@@ -912,6 +945,7 @@ void silecsModule::updateClusterItem(Item *Cluster,bool updateInputBufferOnly)
void silecsModule::updatePLCItem(Item *PLCItem,bool updateInputBufferOnly)
{
updatePLCRunState(PLCItem);
Silecs::PLC* plc = (Silecs::PLC*)(PLCItem->getLinkedObject());
Utils::logInfo(messageConsole_,std::string("updating controller: '") + plc->getName() + "'");
int numberOfdevice = PLCItem->childCount();
......
......@@ -68,6 +68,8 @@ public:
*/
~silecsModule();
void updatePLCRunState(Item *plcItem);
/**
*Generate the empty entire tree
*/
......
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