Esempio n. 1
0
        public IEnumerable <Tuple <IPLOutMessageEvent, DeviceDetails> > GetPlOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var plOutMessages = new List <Tuple <IPLOutMessageEvent, DeviceDetails> >();

            _loggingService.Info("Recieved ReportingSchedule Message for PL Device " + deviceDetails.DeviceUid, "ReportingScheduleMessageEventBuilder.GetPlOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigReportingScheduleRequest>(requestBase);

            if (deviceDetails.DeviceType == "PL121")
            {
                if (requestMessage.DailyReportingTime != null || requestMessage.DailyLocationReportingFrequency != null || requestMessage.GlobalGram != null)
                {
                    var messageEvent = _dataPopulator.ConstructPlEvent <SendReportIntervalsConfig>(deviceDetails);
                    messageEvent.EventIntervals = (TimeSpan?)null;
                    messageEvent.Level1TransmissionFrequency     = (EventFrequency?)null;
                    messageEvent.Level2TransmissionFrequency     = (EventFrequency?)null;
                    messageEvent.Level3TransmissionFrequency     = (EventFrequency?)null;
                    messageEvent.NextMessageInterval             = (TimeSpan?)null;
                    messageEvent.GlobalGramEnable                = requestMessage.GlobalGram.HasValue ? requestMessage.GlobalGram.Value : (bool?)null;
                    messageEvent.ReportStartTimeUTC              = requestMessage.DailyReportingTime.HasValue ? new DateTime() + requestMessage.DailyReportingTime.Value : (DateTime?)null; //doubt
                    messageEvent.DiagnosticTransmissionFrequency = (EventFrequency?)null;
                    messageEvent.SmuFuelReporting                = (SMUFuelReporting?)null;
                    messageEvent.StartStopConfigEnabled          = (bool?)null;
                    // messageEvent.DiagnosticTransmissionFrequency = requestMessage.DailyLocationReportingFrequency.HasValue ? _dataPopulator.GetEventEnumValue<EventFrequency>(requestMessage.DailyLocationReportingFrequency.Value.ToString()) : (EventFrequency?)null; // doubt
                    plOutMessages.Add(new Tuple <IPLOutMessageEvent, DeviceDetails>(messageEvent, deviceDetails));
                }
            }
            else
            {
                {
                    var messageEvent = _dataPopulator.ConstructPlEvent <SendReportIntervalsConfig>(deviceDetails);
                    if (requestMessage.GlobalGram.HasValue)
                    {
                        messageEvent.GlobalGramEnable = requestMessage.GlobalGram.Value;
                    }
                    if (requestMessage.DailyReportingTime.HasValue)
                    {
                        messageEvent.ReportStartTimeUTC = new DateTime() + requestMessage.DailyReportingTime.Value;
                    }
                    if (requestMessage.ReportAssetStartStop.HasValue)
                    {
                        messageEvent.StartStopConfigEnabled = requestMessage.ReportAssetStartStop.Value;
                    }
                    //messageEvent.SmuFuelReporting = requestMessage.HourMeterFuelReport.Value;
                    //messageEvent.DiagnosticTransmissionFrequency = requestMessage.DailyLocationReportingFrequency.Value;
                    plOutMessages.Add(new Tuple <IPLOutMessageEvent, DeviceDetails>(messageEvent, deviceDetails));
                }
            }
            _loggingService.Info("Reporting Schedule Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "ReportingScheduleMessageEventBuilder.GetPlOutMessageEvent");
            return(plOutMessages);
        }
Esempio n. 2
0
        public IEnumerable <Tuple <IPLOutMessageEvent, DeviceDetails> > GetPlOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var plOutMessages        = new List <Tuple <IPLOutMessageEvent, DeviceDetails> >();
            var digitalConfigDetails = new List <DigitalInputConfigDetails>();

            _loggingService.Info("Recieved Switches Message for Device " + deviceDetails.DeviceType, "SwitchesMessageEventBuilder.GetPlOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigSwitchesRequest>(requestBase);

            if (requestMessage.SingleStateSwitches != null && requestMessage.SingleStateSwitches.Any())
            {
                foreach (var singleSwitch in requestMessage.SingleStateSwitches)
                {
                    var digitalInputConfigDetail = new DigitalInputConfigDetails();
                    digitalInputConfigDetail.InputConfig = string.IsNullOrEmpty(singleSwitch.SwitchActiveState) ? (InputConfig?)null : _dataPopulator.GetEventEnumValue <InputConfig>(singleSwitch.SwitchActiveState);
                    digitalInputConfigDetail.DigitalInputMonitoringCondition = string.IsNullOrEmpty(singleSwitch.SwitchMonitoringStatus) ? (DigitalInputMonitoringConditions?)null : _dataPopulator.GetEventEnumValue <DigitalInputMonitoringConditions>(singleSwitch.SwitchMonitoringStatus);
                    digitalInputConfigDetail.Description    = singleSwitch.SwitchName;
                    digitalInputConfigDetail.InputDelayTime = new TimeSpan(0, 0, 0, 0, (int)Math.Round(singleSwitch.SwitchSensitivity * 1000));
                    digitalConfigDetails.Add(digitalInputConfigDetail);
                }
                var plMessageEvent = _dataPopulator.ConstructPlEvent <SendDigitalInputConfig>(deviceDetails);
                plMessageEvent.Config1 = digitalConfigDetails[0];
                plMessageEvent.Config2 = digitalConfigDetails.Count >= 2 ? digitalConfigDetails[1] : new DigitalInputConfigDetails();
                plMessageEvent.Config3 = digitalConfigDetails.Count >= 3 ? digitalConfigDetails[2] : new DigitalInputConfigDetails();
                plMessageEvent.Config4 = digitalConfigDetails.Count >= 4 ? digitalConfigDetails[3] : new DigitalInputConfigDetails();
                plOutMessages.Add(new Tuple <IPLOutMessageEvent, DeviceDetails>(plMessageEvent, deviceDetails));
            }
            _loggingService.Info("Switches Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "SwitchesMessageEventBuilder.GetPlOutMessageEvent");
            return(plOutMessages);
        }
Esempio n. 3
0
        public IEnumerable <Tuple <IPLOutMessageEvent, DeviceDetails> > GetPlOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IPLOutMessageEvent, DeviceDetails> >();
            var requestMessage  = _dataPopulator.GetRequestModel <DeviceConfigMetersRequest>(requestBase);

            _loggingService.Info("Recieved SendRuntimeAdjustmentConfig Message" + requestMessage + " for Device " + deviceDetails.DeviceUid + " and DeviceType" + deviceDetails.DeviceType, "MetersMessageEventBuilder.GetPlOutMessageEvent");
            if (_validator.NullCheck(RequestMessageType, requestMessage.HoursMeter.ProposedValue))
            {
                var plMessageEvent = _dataPopulator.ConstructPlEvent <SendRuntimeAdjustmentConfig>(deviceDetails);
                plMessageEvent.NewRuntimeValue = new TimeSpan((int)requestMessage.HoursMeter.ProposedValue, 0, 0);
                dataOutMessages.Add(new Tuple <IPLOutMessageEvent, DeviceDetails>(plMessageEvent, deviceDetails));
            }
            _loggingService.Info("SendRuntimeAdjustmentConfig message Event Construction for Device" + deviceDetails + " completed !!" + JsonConvert.SerializeObject(requestBase), "");
            return(dataOutMessages);
        }
Esempio n. 4
0
        public IEnumerable <Tuple <IPLOutMessageEvent, DeviceDetails> > GetPlOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var plOutMessages = new List <Tuple <IPLOutMessageEvent, DeviceDetails> >();

            _loggingService.Info(string.Format("Received Fault code Reporting message for devicetype {0} ", deviceDetails.DeviceType), "FaultCodeReportingEventBuilder.GetPlOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigFaultCodeReportingRequest>(requestBase);
            var plMessageEvent = _dataPopulator.ConstructPlEvent <SendReportIntervalsConfig>(deviceDetails);

            if (requestMessage.EventDiagnosticFilterInterval.HasValue)
            {
                plMessageEvent.EventIntervals = new TimeSpan(days: 0, hours: requestMessage.EventDiagnosticFilterInterval.Value, minutes: 0, seconds: 0);
            }
            if (requestMessage.LowSeverityEvents.HasValue)
            {
                plMessageEvent.Level1TransmissionFrequency = (EventFrequency)requestMessage.LowSeverityEvents;
            }
            if (requestMessage.MediumSeverityEvents.HasValue)
            {
                plMessageEvent.Level2TransmissionFrequency = (EventFrequency)requestMessage.MediumSeverityEvents;
            }
            if (requestMessage.HighSeverityEvents.HasValue)
            {
                plMessageEvent.Level3TransmissionFrequency = (EventFrequency)requestMessage.HighSeverityEvents;
            }
            if (requestMessage.NextSentEventInHours.HasValue)
            {
                plMessageEvent.NextMessageInterval = new TimeSpan(days: 0, hours: requestMessage.NextSentEventInHours.Value, minutes: 0, seconds: 0);
            }
            if (requestMessage.DiagnosticReportFrequency.HasValue)
            {
                plMessageEvent.DiagnosticTransmissionFrequency = (EventFrequency)requestMessage.DiagnosticReportFrequency;
            }
            plOutMessages.Add(new Tuple <IPLOutMessageEvent, DeviceDetails>(plMessageEvent, deviceDetails));
            _loggingService.Info(string.Format("Fault code Reporting message event construction for devicetype {0} completed", deviceDetails.DeviceType), "FaultCodeReportingEventBuilder.GetPlOutMessageEvent");
            _loggingService.Debug(string.Format("Json payload {0}", JsonConvert.SerializeObject(requestBase)), "FaultCodeReportingEventBuilder.GetPlOutMessageEvent");
            return(plOutMessages);
        }