private static DbGlucoTransferRecord getTransferInfo(List <byte> data) { DbGlucoTransferRecord transfer = new DbGlucoTransferRecord(); // glucoResponse.operationResult = GlucoOperationResultEnum.Failed; try { if (data == null || data.Count == 0) { return(transfer); } int count = data.Count; uint[] numArray = new uint[data.Count]; for (int index = 0; index < data.Count; ++index) { numArray[index] = (uint)data[index]; } DbGlucoTransferRecord glucoTransferRecord = new DbGlucoTransferRecord(); glucoTransferRecord.Status = (uint)((int)numArray[0] | (int)numArray[1] << 8 | (int)numArray[2] << 16 | (int)numArray[3] << 24); glucoTransferRecord.Code = numArray[8] | numArray[9] << 8; glucoTransferRecord.Version = (uint)((int)numArray[count - 6] | (int)numArray[count - 7] << 8 | (int)numArray[count - 8] << 16 | (int)numArray[count - 9] << 24); glucoTransferRecord.Dcont_ID = (uint)((int)numArray[count - 5] | (int)numArray[count - 4] << 8 | (int)numArray[count - 3] << 16 | (int)numArray[count - 2] << 24); // SOFTWARE_VERSION = (int)numArray[count - 9]; what the f**k return(glucoTransferRecord); } catch (Exception ex) { // glucoResponse.error = ex.ToString(); return(transfer); } // glucoResponse.operationResult = GlucoOperationResultEnum.Success; // return transfer; }
static uint getSoftVer(List <byte> data) { DbGlucoTransferRecord glucoTransferRecord = new DbGlucoTransferRecord(); uint SoftwareVersion = 0; try { if (data == null || data.Count == 0) { // return glucoResponse; Console.WriteLine("data is null!"); return(0); } int count = data.Count; uint[] numArray = new uint[data.Count]; for (int index = 0; index < data.Count; ++index) { numArray[index] = (uint)data[index]; } glucoTransferRecord.Status = (uint)((int)numArray[0] | (int)numArray[1] << 8 | (int)numArray[2] << 16 | (int)numArray[3] << 24); glucoTransferRecord.Code = numArray[8] | numArray[9] << 8; glucoTransferRecord.Version = (uint)((int)numArray[count - 6] | (int)numArray[count - 7] << 8 | (int)numArray[count - 8] << 16 | (int)numArray[count - 9] << 24); glucoTransferRecord.Dcont_ID = (uint)((int)numArray[count - 5] | (int)numArray[count - 4] << 8 | (int)numArray[count - 3] << 16 | (int)numArray[count - 2] << 24); SoftwareVersion = numArray[count - 9]; // glucoTransferRecord.returnValue = (object)data; } catch (Exception ex) { Console.WriteLine("Exception4: " + ex); } return(SoftwareVersion); }
static void Main(string[] args) { //todo: // //auto com port selector, xml serializer, cli input - output, argument commands (u-pload, d-ump), more cs files for the helper functions and the classes //init string username, password; XmlDocument connCheckResponse = invokeService("checkConnection"); SERVER_TIME = DateTime.Parse(extractTag(connCheckResponse, "ServerDate")); username = ""; password = ""; if (username == "" || password == "") { handleError("no username or password given"); } XmlDocument loginResponse = invokeService("login", "<username>" + username + "</username><password>" + password + "</password><client_IPAddress>" + getRetardedIpAddress() + "</client_IPAddress>"); XmlDocument patientIdResponse = invokeService("getPatientId", "<userName>" + username + "</userName><password>" + password + "</password>"); string loginString = extractTag(loginResponse, "returnValue"); string patientId = extractTag(patientIdResponse, "returnValue"); //dump SerialPort comPort = new SerialPort(); List <string> usbPorts = GetUsbPorts(); GlucoResponse contents = dumpFromComPort(comPort, usbPorts[0]); //analyze float low; float high; int fieldSize; int softwareVersion = (int)getSoftVer((List <byte>)contents.returnValue); int dataLength = ((List <byte>)contents.returnValue).Count + 2; //wtf XmlDocument fieldSizeResponse = invokeService("getDcontFieldSize", "<deviceType>0</deviceType><softwareVersion>" + softwareVersion + "</softwareVersion><dataLength>" + dataLength + "</dataLength>"); float[] fieldSizes = getFieldSizes(extractTag(fieldSizeResponse, "returnValue")); low = fieldSizes[0]; high = fieldSizes[1]; fieldSize = (int)fieldSizes[2]; DbGlucoTransferRecord transferInfo = getTransferInfo(((List <byte>)contents.returnValue)); GlucoResponse measurements = analyze(fieldSize, softwareVersion, low, high, ((List <byte>)contents.returnValue)); dumpToXmlFile((List <DbMeasurementRecord>)measurements.returnValue); measurements.returnValue = xmlFileToObject([MODDED XML PATH]); //i know, it will fail, a reminder to change the path