Beispiel #1
0
        private void UpdateDeviceCatalogue(object stateInfo)
        {
            CANFrame frame = (CANFrame)stateInfo;

            DeviceCatalogueInfo dci = frame.ToDeviceCatalogueInfo();

            if (dci == null)
            {
                return;
            }

            CNXLog.InfoFormat("DeviceCataloge {0}", dci.ToString());
            DeviceCatalogue.CatalogueChangeType catalogeUpdated = mDeviceCatalogue.UpdateDeviceCatalogue(dci);
            if (catalogeUpdated != DeviceCatalogue.CatalogueChangeType.NONE)
            {
                CNXLog.InfoFormat("DeviceCataloge Updating calalogue.");
                if (catalogeUpdated == DeviceCatalogue.CatalogueChangeType.EQUIPMENT)
                {
                    // persist the catalogue
                    PersistCatalogue();
                }

                EquipmentChangedEventArgs a = new EquipmentChangedEventArgs(mDeviceCatalogue.EquipmentMask, mDeviceCatalogue.EquipmentStatus);
                OnRaiseEquipmentChangedEvent(a);
            }
        }
Beispiel #2
0
        private void OnTimedEvent(object sourcea)
        {
            CANFrame frame = new CANFrame();

            try
            {
                // now config Block Requests
                frame.MailboxId = (uint)CNXMsgIds.BlockQuery + (uint)Block.RouteConfig;
                mCANClient.Send(frame);
                frame.MailboxId = (uint)CNXMsgIds.BlockQuery + (uint)Block.VehicleConfig;
                mCANClient.Send(frame);
                frame.MailboxId = (uint)CNXMsgIds.BlockQuery + (uint)Block.ServiceAlert;
                mCANClient.Send(frame);
                frame.MailboxId = (uint)CNXMsgIds.BlockQuery + (uint)Block.DriverConfig;
                mCANClient.Send(frame);

                // test the status every few cycles
                if (++mTestCatalogueCount > TestCatalogueCycles)
                {
                    // age the device catalogue states
                    if (mDeviceCatalogue.AgeCatalogue() == CANLib.DeviceCatalogue.CatalogueChangeType.STATUS)
                    {
                        EquipmentChangedEventArgs args = new EquipmentChangedEventArgs(mDeviceCatalogue.EquipmentMask, mDeviceCatalogue.EquipmentStatus);
                        OnRaiseEquipmentChangedEvent(args);
                    }
                    mTestCatalogueCount = 0;
                }
            }
            catch (Exception e)
            {
                CNXLog.Error(e.ToString());
            }
        }
Beispiel #3
0
 /// <summary>
 /// Event firing method.
 /// </summary>
 /// <param name="frame">Equipment Mask/Status.</param>
 protected virtual void OnRaiseEquipmentChangedEvent(EquipmentChangedEventArgs catalogeEvent)
 {
     ThreadPool.QueueUserWorkItem((o) =>
     {
         // copy the event handler to avoid mid process subscribe/un-subscribe
         RaiseEquipmentChangedEvent?.Invoke(this, catalogeEvent);
     }
                                  );
 }
Beispiel #4
0
 public void OnEquipmentChangedEventHandler(object o, EquipmentChangedEventArgs catalogeEvent)
 {
     CNXLog.WarnFormat("TrackingState Equipment event {0} <{1}> ", catalogeEvent.Mask, catalogeEvent.Status, ((CANCommsServer)o).DeviceCatalogue.ToString());
     try
     {
         mDeviceMask   = catalogeEvent.Mask;
         mDeviceStatus = catalogeEvent.Status;
         CANCommsServer canServer = (CANCommsServer)o;
         mCatalogue = canServer.DeviceCatalogue.Catalogue;
         StateMachine(TrackingEvent.CATALOGUE);
     }
     catch (Exception ex)
     {
         CNXLog.Error("TrackerState Equipment error.", ex);
     }
 }
Beispiel #5
0
        public void ForceEquipmentChangedEvent()
        {
            EquipmentChangedEventArgs args = new EquipmentChangedEventArgs(mDeviceCatalogue.EquipmentMask, mDeviceCatalogue.EquipmentStatus);

            OnRaiseEquipmentChangedEvent(args);
        }