Hello, During my tests with the Sampleruntime project, I noticed that always I make a project download in PLCNext Engineer using the “Write and start Project changes” , the SampleRuntime log shows the error “ISubscriptionService::ReadValues returned error” and stops only after to stop e start the PLC. Others log files show the error too. runtime.log 09.04.20 17:42:14.931 root ERROR - ISubscriptionService::ReadValues returned error Output.log 09.04.20 17:22:59.302 Arp.Plc.Gds.Internal.Subscription.SubscriptionManager ERROR - Subscription 9 not exist! Is there someway to avoid this error in this situation (download changes) ? Thank you, Sidnei
Hi Sidnei, It looks like the Subscription Thread is attempting to read GDS variables that don’t exist, or from a GDS subscription that has been reset. Looking at the source code for the SampleRuntime example, the Subscription Thread should stop reading values when the PLC goes into one of the states “Stop”, “Reset” or “Unload”. Perhaps none of these states are entered during a “Download Changes” event, and so the Subscription Thread attempts to continue reading GDS variables when it shouldn’t. It would be interesting to know what happens when you stop the PLC (from the PLCnext Engineer “cockpit”) before doing the download - this should stop the Subscription Thread from reading the values, and it should (hopefully) start up again OK when the PLC restarts. There is a chance that the ANSI-C callback function needs to include some additional states to handle “download change” events from the PLC. Or perhaps the Subscription Thread must set up the complete subscription again after the PLC restarts, rather than just attempting to start reading the same subscription again. I hope this have given you some hints where to look for a solution. ~ Martin.
Hi Martin, Thank you for your hints. I would like to share my conclusion. I took a look in the Output.log file and I found the following line: 10.04.20 19:06:22.093 Arp.Plc.Gds.Internal.Subscription.SubscriptionBase INFO - Subscription 9 unsubscribed It seems that the PLC unsubscribes the Subscription after the Download Changes. Is there a reason for the PLC does this or it could be a bug in the firmware ? Anyway, to avoid the error, I have to call the Start_Processing again to create a new subscription. I dind´t find a option to handle Download Change in PlcOperationHandler. But I have found the PlcState::Changing option in enum PlcState. Then I used the function ArpPlcDomain_GetPlcstate() to read the PLC state and to identify the change mode.The method Start_Processing is called after the Download Change finish. Follow below my code: void CSampleSubscriptionThread::Cycle()
{while(true)
{
TPlcState plcstate = ArpPlcDomain_GetPlcState();
boolean plcStateChanging = ((int32(plcstate) >> 16) & 0x00000001);
// Execute StartProcessing on the fall of plcStateChanging
if (plcStateChanging == false && plcStateChangingAnt == true)
{
plcStateChangingAnt = false;
m_bDoCycle = false;
StartProcessing();
}
else
{
plcStateChangingAnt = plcStateChanging;
}if(m_bDoCycle)
{
ReadSubscription();
}WAIT1s;
}
}This is working well. Sidnei Marcondes
Hi Sidnei, I’m glad you found a solution. That is very interesting and useful information. I will open an issue on the SampleRuntime GitHub project and hopefully the sample code will be updated to account for the situation you described. ~ Martin.