Ejemplo n.º 1
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            var segment = (e as VMSParsedDataEventArgs).messageSegment;

            if (segment == null)
            {
                return;
            }
            if (segment.Pid == TrackedValuePID)
            {
                TrackedValue       = segment.StandardValue;
                TrackedMetricValue = segment.MetricValue;
            }
            else if (segment.Pid == SecondTrackedValuePID)
            {
                SecondTrackedValue       = segment.StandardValue;
                SecondTrackedMetricValue = segment.MetricValue;
            }

            if (!double.IsNaN(TrackedValue) && !double.IsNaN(SecondTrackedValue) && SecondTrackedValue != 0)
            {
                Value       = (TrackedValue / SecondTrackedMetricValue);
                MetricValue = (TrackedMetricValue / SecondTrackedMetricValue);
                PublishValues();
            }
        }
Ejemplo n.º 2
0
            /// <summary>
            /// The ParameterWrapper consumes a VMSParsedDataEventArg. If the data is parsed, it will store the value and publish
            /// a PidValueEventArg. If the data is not parsed, it will publish a RawDataEventArg. This raw data will either be discarded
            /// or caught by a advanced parser. If the advanced parser manipulates standard PID data, it will republish the VMSParsedDataEventArg,
            /// which will then be caught again here.
            /// </summary>
            /// <param name="e"></param>
            public void ConsumeEvent(VMSEventArgs e)
            {
                var segment = (e as VMSParsedDataEventArgs).messageSegment;

                switch (segment.DataSource)
                {
                case VMSDataSource.J1708:
                    if (segment.ParseStatus == ParseStatus.Parsed)
                    {
                        UpdateWithJ1708(segment);
                    }
                    break;

                case VMSDataSource.J1939:
                    if (segment.ParseStatus == ParseStatus.Parsed)
                    {
                        UpdateWithJ1939(segment);
                    }
                    break;

                case VMSDataSource.Inferred:
                    if (segment.ParseStatus == ParseStatus.Parsed)
                    {
                        UpdateWithInferred(segment);
                    }
                    break;
                }
            }
        public void ConsumeEvent(VMSEventArgs e)
        {
            var record = (e as DiagnosticEventArgs)?.message;

            if (record != null)
            {
                AddLogEntry(record);
            }
        }
Ejemplo n.º 4
0
        protected override void HandleNewData(VMSEventArgs e)
        {
            //TODO - get this to work properly if there are any issues with performance
            Action action = () => HandleNewData((e as VMSPidValueEventArgs).value);

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
            //var value = (e as VMSPidValueEventArgs)?.value;
            //HandleNewData((double)value);
        }
Ejemplo n.º 5
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            var segment = (e as VMSRawDataEventArgs)?.messageSegment;

            if (segment != null)
            {
                Parse(segment);
            }
        }
Ejemplo n.º 6
0
 public void ConsumeEvent(VMSEventArgs e)
 {
     try
     {
         HandleMessage((e as VMSCommDataEventArgs));
     }
     catch (Exception ex)
     {
         throw new RawDataParsingException((e as VMSCommDataEventArgs), ex);
     }
 }
Ejemplo n.º 7
0
 public void ConsumeEvent(VMSEventArgs e)
 {
     if (Enabled)
     {
         var CommDataEvent = (e as VMSCommDataEventArgs);
         if (CommDataEvent != null)
         {
             MessagesToWrite.Enqueue(CommDataEvent);
         }
     }
 }
        protected override void HandleNewData(VMSEventArgs e)
        {
            Tire tire = (e as TireEventArgs)?.tire;

            if (tire != null && tire.index == tireIndex)
            {
                currentPressure = tire.DisplayPressure;
                lastStatus      = currentStatus;
                currentStatus   = tire.TireStatus;
                Update();
            }
        }
Ejemplo n.º 9
0
 public virtual void ConsumeEvent(VMSEventArgs e)
 {
     try
     {
         Action action = () => HandleNewData(e);
         Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
     }
     catch (Exception ex)
     {
         ErrorLogger.GenerateErrorRecord(ex);
     }
 }
Ejemplo n.º 10
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            switch (e.eventID & EventIDs.EVENT_BASE_MASK)
            {
            case EventIDs.DIAGNOSTIC_BASE:
                Update(e as DiagnosticEventArgs);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 11
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            var newValue       = (e as VMSPidValueEventArgs).segment.StandardValue;
            var newMetricValue = (e as VMSPidValueEventArgs).segment.MetricValue;

            counter++;
            TimeValuePair recordStruct = new TimeValuePair(counter, newMetricValue, newValue);

            if (recordStruct.value > MaxValue)
            {
                return;
            }
            if (recordStruct.value >= ValueArray[Right].value)
            {
                ValueArray[Left] = recordStruct;
                Right            = Left;
                Value            = ValueArray[Right].value;
                MetricValue      = ValueArray[Right].valueMetric;
                PublishValues();
                return;
            }
            bool roomForMore = (ValueArray[Left].value < recordStruct.value);

            while (ValueArray[Left].value < recordStruct.value)
            {
                Constants.SafeIndexAdd(ref Left, 1, BufferSize);
            }
            Constants.SafeIndexAdd(ref Left, -1, BufferSize);

            if (Left != Right)
            {
                roomForMore = true;
            }
            if (roomForMore)
            {
                ValueArray[Left] = recordStruct;
            }
            else
            {
                Constants.SafeIndexAdd(ref Left, 1, BufferSize);
                if (ValueArray[Left].time < (counter - TimeSpan))
                {
                    ValueArray[Left] = recordStruct;
                }
            }
            if (counter > TimeSpan)
            {
                while (ValueArray[Right].time < (counter - TimeSpan))
                {
                    Constants.SafeIndexAdd(ref Right, -1, BufferSize);
                }
            }
        }
Ejemplo n.º 12
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            switch (e.eventID)
            {
            case EventIDs.GUI_RESET_EVENT:
                GeneratePanels();
                DayNightToggle.Header = (ConfigManager.Screen.Contents.OnDayPalette) ? "Night" : "Day";
                break;

            default:
                break;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Parses all ParsedDataEvents, regardless of whether or not they are recognized. Because of this constraint, we keep the RecognizedPIDs List sorted
        /// so that we can perform a binary search at each event consumption.
        /// </summary>
        /// <param name="e"></param>
        public void ConsumeEvent(VMSEventArgs e)
        {
            var ev = (e as VMSParsedDataEventArgs);

            if (ev != null && ev.messageSegment != null)
            {
                var pid   = ev.messageSegment.Pid;
                var index = RecognizedPIDs.BinarySearch(pid);
                if (index < -1)
                {
                    //List.BinarySearch() returns the bitwise complement of the next largest element's index
                    //in the list when the value isn't found. This means that we can take the complement again
                    //for the insertion to avoid sorting every time a new value is added.
                    AddUnrecognizedParameter(~index, pid);
                }
            }
        }
Ejemplo n.º 14
0
        public void ConsumeEvent(VMSEventArgs e)
        {
            var message = (e as VMSPidValueEventArgs);

            switch (message.segment.Pid)
            {
            case 190:
                CurrentRPMs = message.segment.RawValue;
                break;

            case 92:
                CurrentLoadPercent = message.segment.StandardValue;
                break;
            }
            if (!double.IsNaN(CurrentRPMs) && !double.IsNaN(CurrentLoadPercent))
            {
                var HP            = EngineSpec.CalculateHorsepower(CurrentRPMs, CurrentLoadPercent);
                var Torque        = EngineSpec.CalculateTorque(CurrentRPMs, CurrentLoadPercent);
                var torqueSegment = message.segment.DeepCopy();
                torqueSegment.Pid           = 510;
                torqueSegment.StandardValue = Torque;
                var hpSegment = message.segment.DeepCopy();
                hpSegment.Pid           = 509;
                hpSegment.StandardValue = HP;
                RaiseVMSEvent?.Invoke(this, new VMSParsedDataEventArgs(510, torqueSegment));
                RaiseVMSEvent?.Invoke(this, new VMSParsedDataEventArgs(509, hpSegment));

                /*
                 * RaiseVMSEvent?.Invoke(this, new VMSPidValueEventArgs(
                 *  (EventIDs.PID_BASE | 510),
                 *  Torque
                 *  ));
                 * RaiseVMSEvent?.Invoke(this, new VMSPidValueEventArgs(
                 *  (EventIDs.PID_BASE | 509),
                 *  HP
                 *  ));
                 */
            }
        }
        public void ConsumeEvent(VMSEventArgs e)
        {
            var segment = (e as VMSRawDataEventArgs)?.messageSegment;

            switch (segment?.DataSource)
            {
            case VMSDataSource.J1708:
                var j1708Segment = (segment as J1708MessageSegment);
                if (j1708Segment.Mid == 0x80)
                {       //we only parse engine faults at MID 0x80
                    ProcessJ1708Diagnostic(j1708Segment.RawData);
                }
                break;

            case VMSDataSource.J1939:
                var j1939Segment = (segment as J1939MessageSegment);
                if (j1939Segment.SourceAddress == 0)
                {       //we only parse engine faults at SA 0
                    ProcessJ1939Diagnostic(j1939Segment.RawData);
                }
                break;
            }
        }
Ejemplo n.º 16
0
 public void ConsumeEvent(VMSEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
 protected abstract void HandleNewData(VMSEventArgs e);
 protected override void HandleNewData(VMSEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 19
0
 public void ConsumeEvent(VMSEventArgs e)
 {
     pidValue = (e as VMSPidValueEventArgs).value;
 }
Ejemplo n.º 20
0
 public void ConsumeEvent(VMSEventArgs e)
 {
     NewSpeed = (e as VMSPidValueEventArgs).segment.StandardValue;
     Calculate();
 }
Ejemplo n.º 21
0
 protected void PublishEvent(VMSEventArgs e)
 {
     RaiseVMSEvent?.Invoke(this, e);
 }