Beispiel #1
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);
        }
Beispiel #2
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

            _loggingService.Info("Recieved Maintenance Mode Message for Device " + deviceDetails.DeviceType, "MaintenanceModeMessageEventBuilder.GetDataOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigMaintenanceModeRequest>(requestBase);

            if (_validator.NullCheck(RequestMessageType, requestMessage.Status))
            {
                if (requestMessage.Status.Value)
                {
                    var enableMessageEvent = _dataPopulator.ConstructDataOutEvent <EnableMaintenanceModeEvent>(deviceDetails);
                    enableMessageEvent.Duration = _validator.NullCheck(RequestMessageType, requestMessage.MaintenanceModeDuration) ? new TimeSpan(requestMessage.MaintenanceModeDuration.Value, 0, 0) : new TimeSpan();
                    enableMessageEvent.StartUtc = requestMessage.StartTime;
                    dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(enableMessageEvent, deviceDetails));
                }
                else
                {
                    var disableMessageEvent = _dataPopulator.ConstructDataOutEvent <DisableMaintenanceModeEvent>(deviceDetails);
                    dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(disableMessageEvent, deviceDetails));
                }
            }
            _loggingService.Info("Maintenance Mode Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "MaintenanceModeMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

            _loggingService.Info("Recieved MovingThresholds Message for A5N2 Device " + deviceDetails.DeviceUid, "MovingThresholdMessageEventBuilder.GetDataOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigMovingThresholdRequest>(requestBase);
            var messageEvent   = _dataPopulator.ConstructDataOutEvent <MovingCriteriaConfigurationChangedEvent>(deviceDetails);

            messageEvent.MovementDurationSeconds = requestMessage.MovingThresholdsDuration.HasValue ? requestMessage.MovingThresholdsDuration.Value : 30;
            messageEvent.MovementRadiusInFeet    = requestMessage.Radius.HasValue ? NumericHelper.ConvertMetersToFeet(requestMessage.Radius.Value) : 30;
            messageEvent.MovementSpeedMPH        = requestMessage.MovingOrStoppedThreshold.HasValue ? NumericHelper.ConvertKilometersToMiles((double)requestMessage.MovingOrStoppedThreshold.Value) : 0.2;
            dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(messageEvent, deviceDetails));
            _loggingService.Info("Moving Thresholds Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "MovingThresholdMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        private RuntimeHoursOffset GetHourMeterOffsetMessageEvent(DeviceConfigRequestBase requestBase)
        {
            _loggingService.Info("Started processing hour meter offset values", "MetersMessageBuilder.GetHourMeterOffsetMessageEvent");
            var hourmeterOffsetEvent = new RuntimeHoursOffset();
            var requestMessage       = _dataPopulator.GetRequestModel <DeviceConfigMetersRequest>(requestBase);

            if (requestMessage.HoursMeter != null)
            {
                if (requestMessage.HoursMeter.ProposedValue.HasValue)
                {
                    hourmeterOffsetEvent.Offset = Math.Round(Convert.ToDouble(requestMessage.HoursMeter.ProposedValue - Convert.ToDouble(requestMessage.HoursMeter.CurrentValue)), 1);
                }
            }
            _loggingService.Info("Ended processing hour meter offset values", "MetersMessageBuilder.GetHourMeterOffsetMessageEvent");
            return(hourmeterOffsetEvent);
        }
Beispiel #7
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

            _loggingService.Info("Recieved SpeedingThresholds Message for A5N2 Device " + deviceDetails.DeviceUid, "SpeedingThresholdMessageEventBuilder.GetDataOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigSpeedingThresholdsRequest>(requestBase);

            if (_validator.NullCheck(RequestMessageType, requestMessage.SpeedThresholdEnabled.Value))
            {
                var messageEvent = _dataPopulator.ConstructDataOutEvent <MovingCriteriaConfigurationChangedEvent>(deviceDetails);
                if (requestMessage.SpeedThresholdEnabled.Value)
                {
                    messageEvent.MovementDurationSeconds = requestMessage.SpeedThresholdDuration.HasValue ? requestMessage.SpeedThresholdDuration.Value : 3600;
                    messageEvent.MovementSpeedMPH        = requestMessage.SpeedThreshold.HasValue ? NumericHelper.ConvertKilometersToMiles(requestMessage.SpeedThreshold.Value) : 150;
                }
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(messageEvent, deviceDetails));
            }
            _loggingService.Info("Speeding Threshold Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "SpeedingThresholdMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Beispiel #8
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

            _loggingService.Info("Received Asset Security Message for Device " + deviceDetails.DeviceType, "AssetSecurityMessageEventBuilder.GetDataOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigAssetSecurityRequest>(requestBase);

            if (requestMessage.SecurityMode.HasValue)
            {
                var setTamperLevelEvent = _dataPopulator.ConstructDataOutEvent <SetTamperLevelEvent>(deviceDetails);
                setTamperLevelEvent.TamperLevel = requestMessage.SecurityMode.Value == true ? TamperResistanceStatus.TamperResistanceLevel1 : TamperResistanceStatus.Off;
                var securityModeDeviceDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "SecurityMode");
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(setTamperLevelEvent, securityModeDeviceDetails));
            }
            if (requestMessage.SecurityStatus.HasValue)
            {
                var setStartModeEvent = _dataPopulator.ConstructDataOutEvent <SetStartModeEvent>(deviceDetails);
                switch (requestMessage.SecurityStatus.Value)
                {
                case AssetSecurityStatus.NormalOperation:
                    setStartModeEvent.StartMode = MachineStartStatus.NormalOperation;
                    break;

                case AssetSecurityStatus.Derated:
                    setStartModeEvent.StartMode = MachineStartStatus.Derate;
                    break;

                case AssetSecurityStatus.Disable:
                    setStartModeEvent.StartMode = MachineStartStatus.Disable;
                    break;
                }

                var securityStatusDeviceDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "SecurityStatus");
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(setStartModeEvent, securityStatusDeviceDetails));
            }
            _loggingService.Info("Asset Security Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "AssetSecurityMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Beispiel #9
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);
        }