private Record CastRecord(WmDevice wmDevice, object data) { Record record = null; switch (wmDevice.Devicetype) { case DeviceType.WM5000LT: record = (WM5000LTRecord)data; break; case DeviceType.WM5000L5: record = (WM5000L5Record)data; break; case DeviceType.WM5000P5: record = (WM5000P5Record)data; break; case DeviceType.WM5000LG: record = (WM5000LGRecord)data; break; } return(record); }
private bool IsUnitReading(WmDevice wmDevice) { return( wmDevice.Devicetype == DeviceType.WM5000LT || wmDevice.Devicetype == DeviceType.WM5000L5 || wmDevice.Devicetype == DeviceType.WM5000P5 || wmDevice.Devicetype == DeviceType.WM5000LG ); }
public override void ExecuteCommand(GPRSSession session, BinaryCommandInfo commandInfo) { byte[] data = commandInfo.Data; WmDevice wmDevice = new WmDevice(); List <object> dataList = wmDevice.parseData(data, data.Length); Log.Test("Gprs Testing", "Stepping through GPRS testing..."); // Check that the Datatype is WM5000LT if (this.IsUnitReading(wmDevice)) { // Add necessary data GPRSData gprsData = new GPRSData(); gprsData.Agency = wmDevice.Agency; gprsData.RecorderSerial = wmDevice.ReaderNumber; gprsData.Imei = wmDevice.Imei; // Check that recorder authenticates if (gprsData.Authenticated) { if (dataList != null && dataList.Count > 0) { // Records for (int i = 0; i < dataList.Count; i++) { this.ProcessGPRSRecord(wmDevice, dataList[i], gprsData); } // send received data ok command session.SendResponse(wmDevice.ResponseBytes); } } else { // Log unauthenticated attempts Log.Warning( "Unauthenticated GPRS recorder attempted to connect to server.\r\n" + "=> Agent : " + wmDevice.Agency + "\r\n" + "=> Serial: " + wmDevice.ReaderNumber ); } } if (wmDevice.Devicetype == DeviceType.TIMING) { session.SendResponse(wmDevice.ResponseBytes); } }
private void ProcessGPRSRecord(WmDevice wmDevice, object data, GPRSData gprsData) { Record record = this.CastRecord(wmDevice, data); string recordType = record.Recordtype.ToString(); gprsData.Database = Hacks.AdjustDatabase(gprsData.Database); // GPS enabled recorders if (wmDevice.Devicetype == DeviceType.WM5000P5) { this.StoreGPSData(data, recordType); } else { this.StoreNonGPSData(gprsData, record); } }