Пример #1
0
    public SCADAAnalogChangedNotificationResponse SCADAAnalogChangedNotification(SCADAAnalogChangedNotificationRequest request)
    {
        LogInfo("SCADAAnalogChangedNotification() Entered");
        String message = String.Empty;
        SCADAAnalogChangedNotificationResponse response = new SCADAAnalogChangedNotificationResponse();

        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));
            }
            for (int i = 0; i < request.scadaAnalogs.Length; i++)
            {
                if (i == 0)
                {
                    message += String.Format("{0},{1:0.000} {2}   {3} GMT", request.scadaAnalogs[i].objectID, request.scadaAnalogs[i].value.Value, request.scadaAnalogs[i].value.units, request.scadaAnalogs[i].timeStamp);
                }
                else
                {
                    message += String.Format(";{0},{1:0.000} {2}   {3} GMT", request.scadaAnalogs[i].objectID, request.scadaAnalogs[i].value.Value, request.scadaAnalogs[i].value.units, request.scadaAnalogs[i].timeStamp);
                }
            }
            Byte[] sendBytes = Encoding.ASCII.GetBytes(message);
            _UdpClient.Send(sendBytes, sendBytes.Length);

            response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader();
            response.MultiSpeakMsgHeader.TimeStampSpecified = true;
            response.MultiSpeakMsgHeader.TimeStamp          = DateTime.Now;
            response.SCADAAnalogChangedNotificationResult   = null;
            return(response);
        }
        catch (Exception ex)
        {
            LogError(String.Format("SCADAAnalogChangedNotification() ex:{0}", ex));
            response.SCADAAnalogChangedNotificationResult          = new errorObject[1];
            response.SCADAAnalogChangedNotificationResult[0]       = new errorObject();
            response.SCADAAnalogChangedNotificationResult[0].Value = ex.Message;
            return(response);
        }
    }
        private void buttonScadaAnalogChangedNotification_Click(object sender, RoutedEventArgs e)
        {
            const int MAX_NUM_ANALOGS = 21;
            Int32     numAnalogs      = 0;

            try
            {
                Random rand = new Random();
                SCADAAnalogChangedNotificationRequest request = new SCADAAnalogChangedNotificationRequest();
                request.MultiSpeakMsgHeader        = new MultiSpeakMsgHeader();
                request.MultiSpeakMsgHeader.UserID = "dcs";
                request.MultiSpeakMsgHeader.Pwd    = "dcs1";
                //request.MultiSpeakMsgHeader.TimeStamp = DateTime.Now;
                //request.MultiSpeakMsgHeader.TimeStampSpecified = true;

                //numAnalogs = rand.Next(1, MAX_NUM_ANALOGS);
                //request.scadaAnalogs = new scadaAnalog[numAnalogs];
                //for (int i = 0; i < numAnalogs; i++) {
                //    request.scadaAnalogs[i] = new scadaAnalog();
                //    request.scadaAnalogs[i].objectID = "SCADAPoint"; ;
                //    request.scadaAnalogs[i].objectName = String.Format("Analog{0:0000}", i);
                //    request.scadaAnalogs[i].unitID = String.Format("An{0:0000}", i);
                //    request.scadaAnalogs[i].quality = new qualityDescription1();
                //    request.scadaAnalogs[i].quality = qualityDescription1.Measured;
                //    request.scadaAnalogs[i].value = new value();
                //    request.scadaAnalogs[i].value.Value = 0.1F;
                //    request.scadaAnalogs[i].value.units = uom.Amps;
                //    request.scadaAnalogs[i].value.unitsSpecified = true;
                //    request.scadaAnalogs[i].timeStamp = DateTime.Now;
                //    request.scadaAnalogs[i].timeStampSpecified = true;
                //}
                numAnalogs           = 1;
                request.scadaAnalogs = new scadaAnalog[numAnalogs];
                for (int i = 0; i < numAnalogs; i++)
                {
                    request.scadaAnalogs[i]          = new scadaAnalog();
                    request.scadaAnalogs[i].objectID = "LR1234";;
                    //request.scadaAnalogs[i].objectName = String.Format("Analog{0:0000}", i);
                    //request.scadaAnalogs[i].unitID = String.Format("An{0:0000}", i);
                    //request.scadaAnalogs[i].quality = new qualityDescription1();
                    //request.scadaAnalogs[i].quality = qualityDescription1.Measured;
                    request.scadaAnalogs[i].value                = new value();
                    request.scadaAnalogs[i].value.Value          = 0.1F;
                    request.scadaAnalogs[i].value.units          = uom.Amps;
                    request.scadaAnalogs[i].value.unitsSpecified = true;
                    request.scadaAnalogs[i].timeStamp            = DateTime.Now;
                    request.scadaAnalogs[i].timeStampSpecified   = true;
                }
                SCADAAnalogChangedNotificationResponse response = _Proxy.SCADAAnalogChangedNotification(request);
                if (response == null)
                {
                    DisplayMsg("response is null - SUCCESS");
                    return;
                }
                if (response.SCADAAnalogChangedNotificationResult == null)
                {
                    DisplayMsg("response.SCADAAnalogChangedNotificationResult is null - SUCCESS");
                    return;
                }
                for (int i = 0; i < response.SCADAAnalogChangedNotificationResult.Length; i++)
                {
                    DisplayMsg(String.Format("{0} {1}", response.SCADAAnalogChangedNotificationResult[i].objectID, response.SCADAAnalogChangedNotificationResult[i].Value));
                }
            }
            catch (Exception ex)
            {
                DisplayMsg(String.Format("ex: {0}", ex.Message));
            }
        }