Ejemplo n.º 1
0
        private void ResetModuleVariables()
        {
            mTrackingManager.ResetTimerVariable();
            mCANServer.RaiseEquipmentChangedEvent -= mTrackingManager.OnEquipmentChangedEventHandler;
            mCANClient.RaiseFrameReceivedEvent    -= mTrackingManager.FrameReceivedEventHandler;
            mCANClient.RaiseFrameReceivedEvent    -= FrameReceivedEventHandler;

            mCANClient             = null;
            mCANServer             = null;
            mTrackingManager       = null;
            trackingServiceStarted = false;
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 private static void ResetDeviceCatalogue(CANCommsServer canServer, DeviceCatalogueInfo.Product prodId, byte ver)
 {
     try
     {
         canServer.DeviceCatalogue.Clear();
         DeviceCatalogueInfo dci = new DeviceCatalogueInfo()
         {
             BuildNo   = ver,
             ProductId = (DeviceCatalogueInfo.Product)mProductCode
         };
         canServer.DeviceCatalogue.UpdateDeviceCatalogue(dci);
         canServer.PersistCatalogue();
     }
     catch (Exception e)
     {
         CNXLog.ErrorFormat("ResetDeviceCatalogue Error : {0}", e.ToString());
     }
 }
Ejemplo n.º 4
0
        private void StartTrackingService()
        {
            int n = 0;

            do
            {
                myIp = GetLocalIPAddressString();
                n++;

                if (myIp == String.Empty || myIp == null)
                {
                    Thread.Sleep(100);
                }
            } while (n < 10 && (myIp == String.Empty || myIp == null));


            if (myIp == String.Empty || myIp == null)
            {
                throw new Exception("Failed to retrieve the IP address of device");
            }

            // kick off GPS
            StartListeningToGPS();

            // start a CAN Client
            if (mUseCANBridge)
            {
                mCANClient = new CANLib.CANBridgeClient(mCANServerName, mInPort, mOutPort);
            }
            else
            {
                mCANClient = new CANLib.CANNativeClient(mCANServerName);
            }

            // create a GPS - CAN relay
            mCANServer = new CANCommsServer(mCANClient, mGPSClient);
            // kick off comms with the RTT server
            InitialiseCommsServer();

            //talk
            mTrackingManager = new TrackingStateManager(mCommsServer, mGPSClient);
            mCANServer.RaiseEquipmentChangedEvent += mTrackingManager.OnEquipmentChangedEventHandler;
            mCANClient.RaiseFrameReceivedEvent    += mTrackingManager.FrameReceivedEventHandler;
            mCANClient.RaiseFrameReceivedEvent    += FrameReceivedEventHandler;

            // add this modules device details to the device catalogue.
            AddSelfToCatalogue();

            // do APC
            APCWrapper apc = new APCWrapper(mRTTServer, mCommsAddress);

            mCANClient.RaiseFrameReceivedEvent      += apc.FrameReceivedEventHandler;
            mGPSClient.RaiseGPSPositionChangedEvent += apc.OnGPSChangedEventHandler;
            mGPSClient.RaiseGPSStatusChangedEvent   += apc.OnGPSChangedEventHandler;

            // prepare to recieve transient messages.
            mDriverIdReciever = new TransientBlockReciever((int)Block.DriverLogon, mCANClient);
            mDriverIdReciever.RaiseBlockStatusEvent += OnDriverIdEventHandler;
            mTxTMessageReciever = new TransientBlockReciever((int)Block.MessageToSystem, mCANClient);
            mTxTMessageReciever.RaiseBlockStatusEvent += OnTxTMessageEventHandler;

            // prepare block manager
            StartDeviceConfigurationManagement(new byte[] { 255, 255, 255, 255 });
            mCANServer.ForceEquipmentChangedEvent();

            trackingServiceStarted = true;
        }