Register    Login
 
Professional OPC Development Tools
And Services
 
 
SupportOnline Forums
 
Links: Related Pages
 
Links: Related Services
 
Links: Related Support
 
Links: Related Resources
 
Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see link in upper right corner) in order to Post questions. You do not have to be a licensed user.

OPC Labs team is actively monitoring the forums, and provides answers as soon as possible. For your convenience, we have also assembled a Frequently Asked Questions page.

Please do not use the Contact page for technical support.

HINT: You may use the Search feature (magnifier icon below) in the forums to locate the information you need. You can also search our entire Web site (the search box in the upper right corner of every page).

 
 
SupportSupportDiscussions (re...Discussions (re...OPC Runtime KitOPC Runtime KitOPC writingOPC writing
Previous Previous
 
Next
 Disabled
New Post
 12/15/2011 4:57 AM
 

From: .....
Sent: Thursday, December 15, 2011 8:58 AM
To: Zbynek Zahradnik
Subject: OPC writing

Zbynek,

I’m little unsure here about writing and OPC Classic in general.

In reading you have VTQ. I want to have TQ and especially Q when writing. How to signal to the client if the writing doesn’t succeed. The protocols answer with some type of acknowledgements when the writing is OK. I want to have this as a type of write quality in the client.

I’m sure I have missed something for this should be there in a standard like OPC.

Best regards
/B.

New Post
 12/15/2011 4:58 AM
 

B.,

The success of the write operation should be indicated by the error code of the Write operation itself, not by quality.
I can explain to you how to do it inside the OPC server. Do you need this?

On the client side, with use of QuickOPC, the error/success from the OPC Server will be passed to the client code by either exception/success of the WriteItem[Value] method, or as appropriate null or non-null Exception in the objects returned by WriteMultipleItem[Value]s.

New Post
 12/15/2011 4:58 AM
 

From: ....
Sent: Thursday, December 15, 2011 11:41 AM
To: Zbynek Zahradnik
Subject: RE: OPC writing

Zbynek,

I should really appreciate if you could explain how to make it in the OPC Server.

Best regards
/B.

New Post
 12/15/2011 4:59 AM
 

B.,
The precise answer may depend on how you have implemented the writing in your code, but in the basic case, you need to report the error code in the output argument Error of the overridden Write method in your class derived from CORKLeaf. For example, below is a code that does in in one of my own classes. Storing S_OK into the Error makes a successful Write; storing some failed HRESULT into it indicates an unsuccessful Write.
void CORKExecuteLeaf::Write(CVTQ& VTQ, BYTE Flags, HRESULT& Error)
{
ENSURE_VALID(this);
ENSURE((Flags & ORK_VTQ_VALUE_PRESENT) != 0);
UNREFERENCED_PARAMETER(Flags);
VARIANT& Value(VTQ.GetRefValue());
HRESULT hr;
if (FAILED(hr = VariantChangeType(&Value, &Value, 0, VT_BOOL)))
{
Error = hr;
return;
}
ENSURE(Value.vt == VT_BOOL);
if (Value.boolVal)
{
ENSURE_VALID(m_pExecutable);
m_pExecutable->Execute();
}
Error = S_OK;
}
Best regards,
New Post
 12/18/2011 9:18 AM
 

B.,

I think that everything is done right.
The only point for consideration is whether it wouldn’t be better to create your own error code, rather than re-using OPC_E_BADRIGHTS. My opinion is that since OPC_E_BADRIGHTS is already generated inside the OPC Server in appropriate situations (such as Writing to a read-only item), using a different error code could help in distinguishing where the errors come from.
Best regards,
Zbynek Zahradnik
From: B.
Sent: Saturday, December 17, 2011 5:15 PM
To: Zbynek Zahradnik
Subject: RE: OPC writing
Zbynek,
It seems o work as expected now. My goal is to have around three or four different write errors depending of different things. My name of the class is:
void CMBusTagLeaf::Write(CVTQ& VTQ, BYTE Flags, HRESULT& Error)
I have during tests forced that this error will occur in the server.
Error = OPC_E_BADRIGHTS;
Here is the client code. The idea is to cache the different errors and write out a specific detailed text. If it should be a big exception it will be catched by the maincatch Exception exc.
Is this handled OK from your point of you?
EasyDAClient easyDa = new EasyDAClient();
DAItemDescriptor dai = new DAItemDescriptor(tag.ChannelName + "." + tag.GroupName + (tag.GroupName != "" ? "_" : "") + tag.DeviceName + "." + tag.TagName);
OpcLabs.EasyOpc.ServerDescriptor server = new OpcLabs.EasyOpc.ServerDescriptor(ApplicationModel.ServerId);
easyDa.HoldPeriods.TopicWrite = 9000;
try
{
easyDa.WriteItemValue(server, dai, val);
}
catch (OpcLabs.EasyOpc.OpcException ce)
{
switch ((uint)ce.ErrorCode)
{
case 0xc0040006://OPC_E_BADRIGHTS;
break;
default:
break;
}
}
catch (Exception exc)
{
//Dialogs.ShowError(ResourceLanguageHandler.getValue(2407) + " " + exc.Message);
Dialogs.ShowError(exc.Message);
}
Best Regards

/B.

Previous Previous
 
Next
 Disabled
SupportSupportDiscussions (re...Discussions (re...OPC Runtime KitOPC Runtime KitOPC writingOPC writing

 
 
 
 
 

 
 
 
 
Home|Services|Products|Purchase|Downloads|Support|Resources|Company|Contact
Copyright 2007-2012 by OPC Labs Terms Of Use Privacy Statement May 18, 2012