Exemplo n.º 1
0
        /// <summary>
        /// Sent Meter Ping Response, this usually is called if the server send a MeterPingRequest,
        /// For demo purpose, send the PingResponse without the PingRequest
        /// </summary>
        public void SendMeterPingResponse()
        {
            MeterPingResponseAmiV1 msg = new MeterPingResponseAmiV1();

            msg.MeterStatuses = new List <MeterStatusAmiV1>();
            // Create a Meter Status out message
            // This will be shows in NetClient as red round marker around the Customer to indicate the Meter is out.
            // To verify, copy and paste the following url in the NetClient viewer
            // NETVIEW://RT/VIEW/DETAIL/RAVEN?ZOOM=15.4730346034505&X=940905.512911328&Y=813055.594137977&FORCENONMAINON&AUTOLABELS&ADJACENT=1&SHOWPOTENTIALFAULTHALOS&CUSTOMERLAYERS=(ALL)&CREWLAYERS=(ALL)&FLTINDHALOS=(BOTH)
            //MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
            //{

            //    MeterId = ConfigurationManager.AppSettings["MeterId"].ToString(),
            //    Status = (int)eAmiQueryResult.Out,
            //    LastCommunicationTime = DateTime.Now
            //};

            // msg.MeterStatuses.Add(meterStatusAmi);
            msg.Sequence = _sequence++;
            callConnector.SendMessageToIdms(msg);   // Call the CallConnector to send the message to server
        }
Exemplo n.º 2
0
        public void MeterPingQuery(List <MeterIdType> meterids)
        {
            try
            {
                MeterPingResponseAmiV1 msg = new MeterPingResponseAmiV1();
                if (callIndex >= meterids.Count)
                {
                    callIndex = 0;
                    // sts = false;
                    // return;
                }
                for (int i = 0; i < meterids.Count; i++)
                {
                    try
                    {
                        string meterno = meterids[i].value.ToString();

                        createTestLogFile("MeterPingRequestAmiV1 - sending meter ping request to the Genus Service.Meter No :" + meterno);

                        MeterPingStatusEntity lst = GenusMeterService.GetLatestPingTimeForMeter(meterno);

                        if (lst == null)
                        {
                            createTestLogFile("MeterPingRequestAmiV1 - meter ping response from genus service is null ");
                        }
                        else
                        {
                            createTestLogFile("MeterPingRequestAmiV1 - meter ping response from genus service is : Status -" + lst.Status);
                        }

                        if (lst.LastCommunication.Trim() == "")
                        {
                            lst.LastCommunication = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
                        }

                        DateTime dt = DateTime.ParseExact(lst.LastCommunication, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

                        MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
                        {
                            MeterId = lst.MeterID,
                            Status  = (int)lst.Status,
                            LastCommunicationTime = dt
                                                    // LastCommunicationTime = Convert.ToDateTime(DateTime.Now)
                        };
                        msg.MeterStatuses.Add(meterStatusAmi);
                        msg.Sequence = _sequence++;
                        callIndex++;  // mark the next call Index
                    }
                    catch (Exception ex)
                    {
                    }
                }

                callConnector.SendMessageToIdms(msg);
                createTestLogFile("MeterPingRequestAmiV1 - meter ping response sent to the call server");

                //Console.WriteLine("MeterPingResponse");
                //Console.WriteLine("==========================================================");
                //Console.WriteLine(Environment.NewLine + "Meter ID=" + pingAttribute.MeterID);
                //Console.WriteLine(Environment.NewLine + "Last Comm=" + pingAttribute.LastCommunication);
                //Console.WriteLine(Environment.NewLine + "Status=" + pingAttribute.Status);
                //Console.WriteLine("==========================================================");

                //Console.WriteLine("{0}","Meter ID=" +pingAttribute.MeterID + "Last Comm=" + pingAttribute.LastCommunication + "Status=" + pingAttribute.Status);
                // Console.ReadLine();
                //MeterPingResponseAmiV1 msg = new MeterPingResponseAmiV1();
                //MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
                //{

                //    MeterId = ConfigurationManager.AppSettings["MeterId"].ToString(),
                //    Status = (int)eAmiQueryResult.Out,
                //    LastCommunicationTime = DateTime.Now
                //};

                //msg.MeterStatuses.Add(meterStatusAmi);
                //msg.Sequence = _sequence++;
                //callConnector.SendMessageToIdms(msg);   // Call the CallConnector to send the message to server
            }
            catch (Exception ex)
            {
            }
        }