public BlockTransferManager(string resource, byte blockId, int version, CANClient client) { mResource = resource; mBlockId = blockId; mBlockVersion = version; mClient = client; Uri uri = new Uri(resource); if (uri.Scheme != "file") { mResDownLoader = new ResumableResourceDownload(mResource); } // first get the device version mState = BlockTransferState.AquiringDeviceVersion; // subscribe to CAN frame events mClient.RaiseFrameReceivedEvent += FrameReceivedEventHandler; CNXLog.WarnFormat("Starting BlockTransferManager url {0}, Id {1}, ver {2}", resource, blockId, version); SendBlockRequest(); // start time for cataloge and status reporting mBlockQueryTimer = new System.Threading.Timer(OnTimedEvent, null, 0, (2 * 60 * 1000)); }
private void InitCommon(CANClient client, byte blockId, byte[] blockData) { mBlockData = blockData; //calculate the crc mCrc = CRC16.CRCArray(ref mBlockData); mClient = client; mBlockId = blockId; }
public TransientBlock(CANClient client, byte blockId) { if (client == null) { throw new NullReferenceException(string.Format("TransientBlock {0} - client NULL", (Block)blockId)); } mBlockId = blockId; mClient = client; }
private void ResetModuleVariables() { mTrackingManager.ResetTimerVariable(); mCANServer.RaiseEquipmentChangedEvent -= mTrackingManager.OnEquipmentChangedEventHandler; mCANClient.RaiseFrameReceivedEvent -= mTrackingManager.FrameReceivedEventHandler; mCANClient.RaiseFrameReceivedEvent -= FrameReceivedEventHandler; mCANClient = null; mCANServer = null; mTrackingManager = null; trackingServiceStarted = false; }
public CANCommsServer(CANClient client, NMEAGPSClient.NMEAGPSClient gpsClient) { mCANClient = client; mGpsClient = gpsClient; // make a device catalogue mDeviceCatalogue = CreateCatalogue(TrackingService.VarPath + mCatalogueFilename); // start time for cataloge and status reporting mCatalogueTimer = new Timer(OnTimedEvent, null, CatalogueTime, CatalogueTime); // subscribe to gps events mGpsClient.RaiseGPSPositionChangedEvent += GPSPositionChangedEventHandler; // get the current gps status mGPSStatus = mGpsClient.Status; mGpsClient.RaiseGPSStatusChangedEvent += GPSStatusChangedEventHandler; // subscribe to CAN frame events mCANClient.RaiseFrameReceivedEvent += FrameReceivedEventHandler; }
public BlockInfo(CANClient client, byte blockId, byte[] blockData) { InitCommon(client, blockId, blockData); }
public BlockInfo(CANClient client, byte blockId, int repeat, byte[] blockData) { mRepeat = repeat; InitCommon(client, blockId, blockData); }
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; }