Example #1
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

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

            if (requestMessage.DailyReportingTime.HasValue)
            {
                var messageEvent = _dataPopulator.ConstructDataOutEvent <FirstDailyReportStartTimeUtcChangedEvent>(deviceDetails);
                messageEvent.DailyReportTimeUTC = new DateTime() + requestMessage.DailyReportingTime.Value;
                var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "DailyReportingTime");
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(messageEvent, dvcDetails));
            }

            if (requestMessage.DailyLocationReportingFrequency.HasValue)
            {
                var messageEvent = _dataPopulator.ConstructDataOutEvent <SetDailyReportFrequencyEvent>(deviceDetails);
                messageEvent.Value = (int)requestMessage.DailyLocationReportingFrequency.Value;
                var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "DailyLocationReportingFrequency");
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(messageEvent, dvcDetails));
            }

            //doubt
            if (requestMessage.DailyLocationReportingFrequency.HasValue)
            {
                var messageEvent = _dataPopulator.ConstructDataOutEvent <ReportingFrequencyChangedEvent>(deviceDetails);
                messageEvent.Frequency = 1;
                messageEvent.Interval  = (int)requestMessage.DailyLocationReportingFrequency.Value; //doubt
                var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "DailyLocationReportingFrequency");
                dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(messageEvent, dvcDetails));
            }
            _loggingService.Info("Reporting Schedule Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "ReportingScheduleMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Example #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);
        }
Example #3
0
        public IEnumerable <Tuple <IOutMessageEvent, DeviceDetails> > GetDataOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails)
        {
            var dataOutMessages = new List <Tuple <IOutMessageEvent, DeviceDetails> >();

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

            if (requestMessage.SingleStateSwitches != null)
            {
                foreach (var singleSwitch in requestMessage.SingleStateSwitches)
                {
                    if (_validator.NullCheck(RequestMessageType, singleSwitch.SwitchActiveState, singleSwitch.SwitchMonitoringStatus))
                    {
                        var dataOutMessageEvent = _dataPopulator.ConstructDataOutEvent <DigitalSwitchConfigurationEvent>(deviceDetails);
                        dataOutMessageEvent.DefaultState        = _dataPopulator.GetEventEnumValue <SwitchState>(singleSwitch.SwitchActiveState);
                        dataOutMessageEvent.MonitoredWhen       = _dataPopulator.GetEventEnumValue <DigitalInputMonitoringConditions>(singleSwitch.SwitchMonitoringStatus);
                        dataOutMessageEvent.Sensitivity         = singleSwitch.SwitchSensitivity;
                        dataOutMessageEvent.SwitchNumber        = singleSwitch.SwitchNumber;
                        dataOutMessageEvent.SwitchOnDescription = singleSwitch.SwitchName;
                        var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, singleSwitch.SwitchParameterName);
                        dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(dataOutMessageEvent, dvcDetails));
                    }
                }
            }
            if (requestMessage.DualStateSwitches != null)
            {
                foreach (var dualSwitch in requestMessage.DualStateSwitches)
                {
                    var dataOutMessageEvent = _dataPopulator.ConstructDataOutEvent <DiscreteInputConfigurationEvent>(deviceDetails);
                    dataOutMessageEvent.Name              = dualSwitch.SwitchName;
                    dataOutMessageEvent.MonitoredWhen     = string.IsNullOrEmpty(dualSwitch.SwitchMonitoringStatus) ? (DigitalInputMonitoringConditions?)null : _dataPopulator.GetEventEnumValue <DigitalInputMonitoringConditions>(dualSwitch.SwitchMonitoringStatus);
                    dataOutMessageEvent.Sensitivity       = dualSwitch.SwitchSensitivity;
                    dataOutMessageEvent.SwitchNumber      = dualSwitch.SwitchNumber;
                    dataOutMessageEvent.OpenDescription   = dualSwitch.SwitchOpen;
                    dataOutMessageEvent.ClosedDescription = dualSwitch.SwitchClosed;
                    dataOutMessageEvent.Enabled           = dualSwitch.SwitchEnabled;
                    var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, dualSwitch.SwitchParameterName);
                    dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(dataOutMessageEvent, dvcDetails));
                }
            }
            _loggingService.Info("Switches Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "SwitchesMessageEventBuilder.GetDataOutMessageEvent");
            return(dataOutMessages);
        }
Example #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 PL Device " + deviceDetails.DeviceUid, "MetersMessageEventBuilder.GetPlOutMessageEvent");
            var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigMetersRequest>(requestBase);

            if (requestMessage.OdoMeter != null)
            {
                if (requestMessage.OdoMeter.ProposedValue.HasValue)
                {
                    _loggingService.Info("Recieved OdometerModifiedEvent Message" + requestMessage + " for Device " + deviceDetails.DeviceUid + " and DeviceType" + deviceDetails.DeviceType, "MetersMessageEventBuilder.GetPlOutMessageEvent");
                    var odometerModifiedEvent = _dataPopulator.ConstructDataOutEvent <OdometerModifiedEvent>(deviceDetails);
                    if (requestMessage.OdoMeter.CurrentValue.HasValue)
                    {
                        odometerModifiedEvent.MilesBefore = NumericHelper.ConvertKilometersToMiles(requestMessage.OdoMeter.CurrentValue.Value);
                    }
                    odometerModifiedEvent.MilesAfter = NumericHelper.ConvertKilometersToMiles(requestMessage.OdoMeter.ProposedValue.Value);
                    var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "Odometer");
                    dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(odometerModifiedEvent, dvcDetails));
                    _loggingService.Info("OdometerModifiedEvent message Event Construction for Device" + deviceDetails.DeviceUid + " completed !!" + JsonConvert.SerializeObject(requestBase), "MetersMessageEventBuilder.GetPlOutMessageEvent");
                }
                if (requestMessage.HoursMeter != null)
                {
                    if (requestMessage.HoursMeter.ProposedValue.HasValue)
                    {
                        _loggingService.Info("Recieved HourMeterModifiedEvent Message" + requestMessage + " for Device " + deviceDetails.DeviceUid + " and DeviceType" + deviceDetails.DeviceType, "MetersMessageEventBuilder.GetPlOutMessageEvent");
                        var hourmeterModifiedEvent = _dataPopulator.ConstructDataOutEvent <HourMeterModifiedEvent>(deviceDetails);
                        if (requestMessage.HoursMeter.CurrentValue.HasValue)
                        {
                            hourmeterModifiedEvent.HoursBefore = requestMessage.HoursMeter.CurrentValue.Value;
                        }
                        hourmeterModifiedEvent.HoursAfter = Convert.ToDouble(requestMessage.HoursMeter.ProposedValue);
                        var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "HoursMeter");
                        dataOutMessages.Add(new Tuple <IOutMessageEvent, DeviceDetails>(hourmeterModifiedEvent, dvcDetails));
                        _loggingService.Info("HourMeterModifiedEvent message Event Construction for Device" + deviceDetails.DeviceUid + " completed !!" + JsonConvert.SerializeObject(requestBase), "MetersMessageEventBuilder.GetPlOutMessageEvent");
                    }
                }
            }
            return(dataOutMessages);
        }
Example #5
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);
        }
Example #6
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);
        }
Example #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);
        }