zip.zip (1.11 KB)
From: Zbynek Zahradnik
Sent: Friday, September 17, 2010 5:04 PM
To: B.
Subject: RE: Time for shutdown [...] server
B.,
Here is what I think you should do:
1) Enhance the server so that it can accept command to shutdown itself (this will in turn cause QuickOPC to disconnect, and there is a way to have it reconnect immediately afterwards – see further below).
To achieve this, add code identical or similar to what I have attached (CORKServerCommandLeaf.h and .cpp) and:
void CxxxxComponent::BeforeLoadConfiguration()
{
ENSURE_VALID(this);
__super::BeforeLoadConfiguration();
AddServerControlBranch();
}
void CxxxxComponent::AddServerControlBranch()
{
ENSURE_VALID(this);
CORKBranchBase* pBranchBase = NULL;
switch (m_Organization)
{
case OPC_NS_HIERARCHIAL:
pBranchBase = new CORKBranch;
ENSURE_VALID(pBranchBase);
pBranchBase->SetName(_T("$ServerControl"));
m_pRoot->AddBranch(pBranchBase);
break;
case OPC_NS_FLAT:
pBranchBase = m_pRoot;
break;
default:
ENSURE(false);
}
CORKLeaf* pServerCommandLeaf;
pServerCommandLeaf = new CORKServerCommandLeaf;
ENSURE_VALID(pBranchBase);
pBranchBase->AddLeaf(pServerCommandLeaf);
}
If your current version of [.../our] OPC Toolkit contains ORKRichRichComponent.h and .cpp, look there, the code might be there already, and you just need to use that as a base class.
In effect, you get an OPC Item ($ServerControl.Command) of string type, and when you write “REQUESTSHUTDOWN()” to it, the server will tell all its clients to disconnect.
You may hide the $ServerControl branch if you like, but still keep it functional.
2) When you want the server to restart from your [...] configuration app, use QuickOPC to write that special value above described item.
3) At the beginning of your code, in order to tell QuickOPC to reconnect immediately, set the ClientParameters.ServerShutdownReconnectDelay of EasyDAClient class to 0 (zero).
This should do it.
Best regards,
Zbynek Zahradnik
From: B.
Sent: Thursday, September 16, 2010 11:00 AM
To: Zbynek Zahradnik
Subject: RE: Time for shutdown [...] server
Zbynek,
Yes we are doing point 1 today. I think more or less 95% are running the server local. If they are using WinCC etc the Scada is running as Service and therefore the Server is running as service indirectly via the handle.
I’m agree that the point 2 is what we wishes. We have already internally Statistics parameters implemented so it should not be so big step to implement some more I think.
/B.
From: Zbynek Zahradnik [mailto:ZbynekZ@opclabs.com]
Sent: den 16 september 2010 10:31
To: B.
Subject: RE: Time for shutdown [...] server
B.,
Before I go into answering the details, let’s step back and look at what you want to achieve. What is it? Is it that you want the server to pick up a new configuration?
If so, there are generally two ways:
1) Disconnect from it, let it shut down, and then reconnect. This is I think what you are doing now.
2) Instruct it to shut down and reconnect. This can be done when it is running as Service by controlling the service itself. In addition, for BOTH Service and Local server, I have a code for a “trick”, whereby writing to a special OPC item in the server you will instruct it to shut down.
I have feeling that the approached under (2) might be better. Please comment.
Zbynek Zahradnik
From: B.
Sent: Thursday, September 16, 2010 9:40 AM
To: Zbynek Zahradnik
Subject: Time for shutdown [...] server
Zbynek,
[...a question about how to cause the OPC server restart (and pick up a new configuration) quickly]
B.