Hi All,
Im coding some methods with this approach in C#:
private void button1_Click(object sender, EventArgs e)
{
var client = new EasyDAClient();
client.ItemChanged += new System.EventHandler<OpcLabs.EasyOpc.DataAccess.EasyDAItemChangedEventArgs>(this.easyDAClient1_ItemChanged);
client.SubscribeItem(textBox1.Text, textBox2.Text, textBox5.Text, 5000)
}
private void easyDAClient1_ItemChanged(object sender, OpcLabs.EasyOpc.DataAccess.EasyDAItemChangedEventArgs rgs)
{
textBox4.AppendText(rgs.Vtq.Value.ToString() + " ----> " + rgs.Vtq.Quality.ToString() + " ----> " + rgs.Vtq.Timestamp.ToString());
textBox4.AppendText(Environment.NewLine);
}
However I would like to have an button to Unsubscribe the items. How can I do it? Its possible in the button1 to subscribe, read and then unsubscribe? Because for my approach I need only to read an item and don't need to subscribe it. My initial idea is to have an timer and then read some items with specific timespan and then process it.
I'm trying this approach because the ReadItem returns me after a few days an unhanded exceptions e.g.:
OpcLabs.EasyOpc.OpcException: An OPC operation failure with error code -2147024891 (0x80070005) occurred, originating from 'OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient'. The inner exception contains details about the problem. ---> System.UnauthorizedAccessException: Access is denied.
OpcLabs.EasyOpc.OpcException: An OPC operation failure with error code -1073430509 (0xC004C013) occurred, originating from 'OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient'. The inner exception contains details about the problem. ---> System.Runtime.InteropServices.COMException: Read not completed. This error indicates that it could not be verified that the requested read operation was completed during the timeout period. It is possible that the read operation will actually succeed or fail, but later. Increase the timeout period if you want to obtain positive or negative indication of the operation outcome. Other reason for this error may be that under heavy loads, topic request or response queue is overflowing. Check the event log for queue overflow errors (if event logging is supported by the product and enabled).
--- End of inner exception stack trace ---
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.CheckSuccess(OperationResult operationResult)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(ServerDescriptor serverDescriptor, DAItemDescriptor itemDescriptor, DAReadParameters readParameters)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(ServerDescriptor serverDescriptor, DAItemDescriptor itemDescriptor)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(String machineName, String serverClass, String itemId, VarType dataType)
at OpcLabs.EasyOpc.DataAccess.EasyDAClient.ReadItemValue(String machineName, String serverClass, String itemId)