Hi There, im trying to handle fail over for opc server connection if server is down i want to switch to the backup. but i want to handle this on the subscription. With AE , there is exception handling when trying to subscribe to an event but with DA and UA is different, I'm failing to catch the server and node connection error while adding subscription. If opc server and node are not available i want to switch to back up before even trying to attempt to read the data. Can you please provide me with an example.
This is where i get the data and handling the connection here is not working , because it check per tag.
private void Client_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
SubscriptionTagStateItem stateItem = (SubscriptionTagStateItem)e.Arguments.State;
if (e.Succeeded)
{
if (e.Vtq != null)
{
TagDataItem tag = new TagDataItem()
{
TagID = stateItem.TagID,
TimeStamp = (e.Vtq.Timestamp < (DateTime)SqlDateTime.MinValue)
? (DateTime)SqlDateTime.MinValue
: e.Vtq.TimestampLocal,
Quality = e.Vtq.Quality.InternalValue.ToString(),
QualityCode = ((int)e.Vtq.Quality.InternalValue).ToString(),
Value = e.Vtq.Value.ToString()
};
UpdateTagData(stateItem, tag);
}
}
else
{
//_logger.LogError("[{0}] - DataChangeNotification ({1} *** Type: {2} *** Failure: {2})", DateTime.Now, e.Arguments.ItemDescriptor.NodeId, e.Exception.GetType().ToString(), e.ErrorMessage);
if ((e.Exception is OpcLabs.EasyOpc.Engine.NetApiException || e.Exception is OpcLabs.EasyOpc.Engine.NetApiResultException) && !_restarting)
{
_hasShutdown = true;
_logger.LogWarning("Server has shut down. Needs to restart.");
}
}
}