private void buttonScadaStatusChangedNotification_Click(object sender, RoutedEventArgs e) { const int MAX_NUM_STATUS = 10; Random rand = new Random(); try { SCADAStatusChangedNotificationRequest request = new SCADAStatusChangedNotificationRequest(); request.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); request.MultiSpeakMsgHeader.UserID = "dcs"; request.MultiSpeakMsgHeader.Pwd = "dcs1"; request.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; request.MultiSpeakMsgHeader.TimeStampSpecified = true; request.scadaStatuses = new scadaStatus[MAX_NUM_STATUS]; for (int i = 0; i < MAX_NUM_STATUS; i++) { request.scadaStatuses[i] = new scadaStatus(); request.scadaStatuses[i].objectID = "SCADAPoint"; request.scadaStatuses[i].objectName = String.Format("Status{0:0000}", i); request.scadaStatuses[i].quality = qualityDescription1.Measured; request.scadaStatuses[i].status = new statusIdentifiers(); request.scadaStatuses[i].changeCounter = 0; } SCADAStatusChangedNotificationResponse response = _Proxy.SCADAStatusChangedNotification(request); if (response == null) { DisplayMsg("response is null - SUCCESS"); return; } if (response.SCADAStatusChangedNotificationResult == null) { DisplayMsg("response.SCADAStatusChangedNotificationResult is null - SUCCESS"); return; } for (int i = 0; i < response.SCADAStatusChangedNotificationResult.Length; i++) { DisplayMsg(String.Format("{0} {1}", response.SCADAStatusChangedNotificationResult[i].objectID, response.SCADAStatusChangedNotificationResult[i].Value)); } } catch (Exception ex) { DisplayMsg(String.Format("ex: {0}", ex.Message)); } }
public SCADAStatusChangedNotificationResponse SCADAStatusChangedNotification(SCADAStatusChangedNotificationRequest request) { LogInfo("SCADAStatusChangedNotification() Entered"); SCADAStatusChangedNotificationResponse response = null; String message = String.Empty; try { if (_UdpClient == null) { String path = @"C:\\DCSystems\Logs\"; ConfigurationList cl = new ConfigurationList(); cl.Add("Process Name", "MockNotServerService"); cl.Add("Log Output Directory", path); _Logger = new Logger(cl); LogInfo("()"); _UdpClient = new UdpClient(); _UdpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7373)); } response = new SCADAStatusChangedNotificationResponse(); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.SCADAStatusChangedNotificationResult = null; Byte[] sendBytes = Encoding.ASCII.GetBytes(message); _UdpClient.Send(sendBytes, sendBytes.Length); return(response); } catch (Exception ex) { LogError(String.Format("SCADAStatusChangedNotification() ex:{0}", ex)); response.SCADAStatusChangedNotificationResult = new errorObject[1]; response.SCADAStatusChangedNotificationResult[0] = new errorObject(); response.SCADAStatusChangedNotificationResult[0].Value = ex.Message; return(response); } }