private IMessageBuilder WithImmediatePulses(ushort pulse_count, int pulse_speed = 16, int delivery_delay = 2) { var commandBody = new Bytes().Append(0x02); var bodyForChecksum = new Bytes().Append(0x01); var pulse_span = (ushort)(pulse_speed * pulse_count); bodyForChecksum.Append(pulse_span); bodyForChecksum.Append(pulse_count); bodyForChecksum.Append(pulse_count); var checksum = getChecksum(bodyForChecksum); commandBody.Append(checksum); commandBody.Append(bodyForChecksum); WithPart(new ErosRequest(PartType.RequestInsulinSchedule, commandBody, true)); commandBody = new Bytes().Append(0x00); ushort p10 = (ushort)(pulse_count * 10); commandBody.Append(p10); uint dd = (uint)delivery_delay * (uint)100000; commandBody.Append(dd); commandBody.Append(new byte[] { 0, 0, 0, 0, 0, 0 }); return(WithPart(new ErosRequest(PartType.RequestBolusSchedule, commandBody))); }
// Token: 0x06000259 RID: 601 RVA: 0x0000AFD4 File Offset: 0x00009FD4 private static Bytes ROW(Row row) { Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(row.RowIndex - 1)); bytes.Append(BitConverter.GetBytes(row.MinCellCol - 1)); bytes.Append(BitConverter.GetBytes(row.MaxCellCol)); bytes.Append(new byte[] { 8, 1 }); Bytes bytes2 = bytes; byte[] byteArray = new byte[2]; bytes2.Append(byteArray); Bytes bytes3 = bytes; byte[] byteArray2 = new byte[2]; bytes3.Append(byteArray2); Bytes bytes4 = bytes; byte[] array = new byte[4]; array[1] = 1; array[2] = 15; bytes4.Append(array); return(Record.GetBytes(RID.ROW, bytes)); }
private Bytes RK(bool trueFalse) { Bytes rk = new Bytes(); //Index to row rk.Append(BitConverter.GetBytes((ushort)(Row - 1))); //Index to column rk.Append(BitConverter.GetBytes((ushort)(Column - 1))); //Index to XF record rk.Append(BitConverter.GetBytes((ushort)_xfIdx)); //RK Value if (Type == CellTypes.Integer) { rk.Append(RKIntegerValue(Value, trueFalse)); } else if (Type == CellTypes.Float) { rk.Append(RKDecimalValue(Value, trueFalse)); } return(Record.GetBytes(RID.RK, rk)); }
// Token: 0x0600016B RID: 363 RVA: 0x00007F54 File Offset: 0x00006F54 private Bytes WINDOW2() { Bytes bytes = new Bytes(); if (this._doc.Workbook.Worksheets.GetIndex(this.Name) == 0) { bytes.Append(new byte[] { 182, 6 }); } else { bytes.Append(new byte[] { 182, 4 }); } Bytes bytes2 = bytes; byte[] array = new byte[16]; array[4] = 64; bytes2.Append(array); return(Record.GetBytes(RID.WINDOW2, bytes)); }
// Token: 0x0600029E RID: 670 RVA: 0x0000C7E4 File Offset: 0x0000B7E4 private Bytes GetFormatRecord(ushort id, string format) { Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(id)); bytes.Append(XlsDocument.GetUnicodeString(format, 16)); return(Record.GetBytes(RID.FORMAT, bytes)); }
// Token: 0x06000147 RID: 327 RVA: 0x000073C0 File Offset: 0x000063C0 private Bytes LABEL() { Bytes bytes = new Bytes(); bytes.Append(this.LABELBase()); bytes.Append(XlsDocument.GetUnicodeString(((string)this.Value) ?? string.Empty, 16)); return(Record.GetBytes(RID.LABEL, bytes)); }
// Token: 0x06000148 RID: 328 RVA: 0x0000740C File Offset: 0x0000640C private Bytes LABELSST() { Bytes bytes = new Bytes(); bytes.Append(this.LABELBase()); bytes.Append(BitConverter.GetBytes((uint)this._value)); return(Record.GetBytes(RID.LABELSST, bytes)); }
public IMessageBuilder WithTempBasal(decimal basal_rate_iuhr, decimal duration_hours) { var half_hour_count = (int)(duration_hours * 2.0m); var hh_units = new decimal[half_hour_count]; for (int i = 0; i < half_hour_count; i++) { hh_units[i] = basal_rate_iuhr / 2.0m; } var pulseList = getPulsesForHalfHours(hh_units); var iseList = getInsulinScheduleTableFromPulses(pulseList); var iseBody = getBodyFromTable(iseList); var pulseBody = getBodyFromTable(pulseList); var cmd_body = new Bytes(); cmd_body.Append(0x01); var body_checksum = new Bytes(); body_checksum.Append((byte)half_hour_count); ushort b1 = 0x3840; body_checksum.Append(b1); body_checksum.Append(pulseList[0]); var checksum = getChecksum(new Bytes(body_checksum, pulseBody)); cmd_body.Append(checksum); cmd_body.Append(body_checksum); cmd_body.Append(iseBody); WithPart(new ErosRequest(PartType.RequestInsulinSchedule, cmd_body, true)); byte reminders = 0; //#if confidenceReminder: //# reminders |= 0x40 cmd_body = new Bytes(); cmd_body.Append(reminders).Append(0x00); var pulseEntries = getPulseIntervalEntries(hh_units); var firstPte = pulseEntries[0]; cmd_body.Append(firstPte.Item1); cmd_body.Append(firstPte.Item2); foreach (var pte in pulseEntries) { cmd_body.Append(pte.Item1); cmd_body.Append(pte.Item2); } return(WithPart(new ErosRequest(PartType.RequestTempBasalSchedule, cmd_body))); }
internal static Bytes GetUnicodeString(string text, int lengthBits) { int textLength; int limit = lengthBits == 8 ? byte.MaxValue : ushort.MaxValue; byte[] binaryLength = new byte[0]; byte[] compression; byte[] compressedText = new byte[0]; textLength = text.Length; if (textLength > limit) { text = text.Substring(0, limit); //NOTE: Should throw Exception here? } if (limit == 255) { binaryLength = new byte[1] { (byte)text.Length } } ; else if (limit == 65535) { binaryLength = BitConverter.GetBytes((ushort)text.Length); } if (IsCompressible(text)) { compression = new byte[1]; char[] chars = text.ToCharArray(); compressedText = new byte[chars.Length]; for (int i = 0; i < chars.Length; i++) { compressedText[i] = (byte)chars[i]; } } else { compression = new byte[1] { 1 }; } Bytes bytes = new Bytes(); bytes.Append(binaryLength); bytes.Append(compression); if (compressedText.Length > 0) { bytes.Append(compressedText); } else { bytes.Append(Encoding.Unicode.GetBytes(text)); } return(bytes); }
// Token: 0x06000149 RID: 329 RVA: 0x0000744C File Offset: 0x0000644C private Bytes LABELBase() { Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(this.Row - 1)); bytes.Append(BitConverter.GetBytes(this.Column - 1)); bytes.Append(BitConverter.GetBytes((ushort)this._xfIdx)); return(bytes); }
// Token: 0x06000146 RID: 326 RVA: 0x00007368 File Offset: 0x00006368 private Bytes BLANK() { Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(this.Row - 1)); bytes.Append(BitConverter.GetBytes(this.Column - 1)); bytes.Append(BitConverter.GetBytes((ushort)this._xfIdx)); return(Record.GetBytes(RID.BLANK, bytes)); }
public Bytes get_data() { var data = new Bytes().Append(this.address); data.Append((byte)(((int)this.type << 5) | this.sequence)); data.Append(this.body); data.Append(CrcUtil.Crc8(data.ToArray())); return(data); }
private static Bytes BinUniStr(string text, int limit) { int textLength; byte[] binaryLength = new byte[0], compression, compressedText = new byte[0]; textLength = text.Length; if (textLength > limit) { text = text.Substring(0, limit); // textLength = limit; } if (limit == 255) { binaryLength = new byte[1] { (byte)text.Length } } ; else if (limit == 65535) { binaryLength = BitConverter.GetBytes((ushort)text.Length); } if (IsCompressible(text)) { compression = new byte[1]; char[] chars = text.ToCharArray(); compressedText = new byte[chars.Length]; for (int i = 0; i < chars.Length; i++) { compressedText[i] = (byte)chars[i]; } } else { compression = new byte[1] { 1 }; } Bytes bytes = new Bytes(); bytes.Append(binaryLength); bytes.Append(compression); if (compressedText.Length > 0) { bytes.Append(compressedText); } else { bytes.Append(Encoding.Unicode.GetBytes(text)); } return(bytes); }
// Token: 0x06000086 RID: 134 RVA: 0x00004B3C File Offset: 0x00003B3C internal static Bytes GetUnicodeString(string text, int lengthBits) { int num = (lengthBits == 8) ? 255 : 65535; byte[] byteArray = new byte[0]; byte[] array = new byte[0]; int length = text.Length; if (length > num) { text = text.Substring(0, num); } if (num == 255) { byteArray = new byte[] { (byte)text.Length }; } else if (num == 65535) { byteArray = BitConverter.GetBytes((ushort)text.Length); } byte[] byteArray2; if (XlsDocument.IsCompressible(text)) { byteArray2 = new byte[1]; char[] array2 = text.ToCharArray(); array = new byte[array2.Length]; for (int i = 0; i < array2.Length; i++) { array[i] = (byte)array2[i]; } } else { byteArray2 = new byte[] { 1 }; } Bytes bytes = new Bytes(); bytes.Append(byteArray); bytes.Append(byteArray2); if (array.Length > 0) { bytes.Append(array); } else { bytes.Append(Encoding.Unicode.GetBytes(text)); } return(bytes); }
private Bytes LABELSST() { Bytes labelsst = new Bytes(); labelsst.Append(LABELBase()); //Index of string value in Shared String Table labelsst.Append(BitConverter.GetBytes((uint)_value)); return(Record.GetBytes(RID.LABELSST, labelsst)); }
private Bytes LABEL() { Bytes label = new Bytes(); label.Append(LABELBase()); //Unicode string, 16-bit string length label.Append(XlsDocument.GetUnicodeString((string)Value ?? string.Empty, 16)); return(Record.GetBytes(RID.LABEL, label)); }
// Token: 0x0600014B RID: 331 RVA: 0x0000752C File Offset: 0x0000652C private Bytes NUMBER() { double val = Convert.ToDouble(this.Value); Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(this.Row - 1)); bytes.Append(BitConverter.GetBytes(this.Column - 1)); bytes.Append(BitConverter.GetBytes((ushort)this._xfIdx)); bytes.Append(Cell.NUMBERVal(val)); return(Record.GetBytes(RID.NUMBER, bytes)); }
public IMessageBuilder WithSetupPod(uint lot, uint tid, uint address, int year, byte month, byte day, byte hour, byte minute) { var cmd_body = new Bytes(); cmd_body.Append(address); cmd_body.Append(new byte[] { 0x14, 0x04 }); cmd_body.Append(new byte[] { month, day, (byte)(year - 2000), hour, minute }); cmd_body.Append(lot); cmd_body.Append(tid); return(WithPart(new ErosRequest(PartType.RequestSetupPod, cmd_body))); }
private void AddStrings(List <string> stringList, ref int remainingRecordBytes, ref Bytes bytes, Bytes sst, ref bool isFirstContinue) { foreach (string sharedString in stringList) { Bytes stringBytes = XlsDocument.GetUnicodeString(sharedString, 16); //per excelfileformat.pdf sec. 5.22, can't split a //Unicode string to another CONTINUE record before //the first character's byte/s are written, and must //repeat string option flags byte if it is split //OPTIM: For smaller filesize, handle the possibility of compressing continued portion of uncompressed strings (low ROI!) byte stringOptionFlag = 0xFF; bool charsAre16Bit = false; int minimumToAdd = int.MaxValue; if (stringBytes.Length > remainingRecordBytes) { stringOptionFlag = stringBytes.Get(2, 1).ByteArray[0]; charsAre16Bit = (stringOptionFlag & 0x01) == 0x01; minimumToAdd = charsAre16Bit ? 5 : 4; } while (stringBytes != null) { if (stringBytes.Length > remainingRecordBytes) //add what we can and continue { bool stringWasSplit = false; if (remainingRecordBytes > minimumToAdd) { int overLength = (stringBytes.Length - remainingRecordBytes); bytes.Append(stringBytes.Get(0, remainingRecordBytes)); stringBytes = stringBytes.Get(remainingRecordBytes, overLength); remainingRecordBytes -= remainingRecordBytes; stringWasSplit = true; } bytes = Continue(sst, bytes, out remainingRecordBytes, ref isFirstContinue); if (stringWasSplit) { bytes.Append(stringOptionFlag); remainingRecordBytes--; } } else //add what's left { bytes.Append(stringBytes); remainingRecordBytes -= stringBytes.Length; stringBytes = null; //exit loop to continue to next sharedString } } } }
// Token: 0x060000CB RID: 203 RVA: 0x000063BC File Offset: 0x000053BC private static Bytes BOUNDSHEET(Worksheet sheet, int basePosition) { Bytes bytes = new Bytes(); Bytes unicodeString = XlsDocument.GetUnicodeString(sheet.Name, 8); bytes.Append(WorksheetVisibility.GetBytes(sheet.Visibility)); bytes.Append(WorksheetType.GetBytes(sheet.SheetType)); bytes.Append(unicodeString); bytes.Prepend(BitConverter.GetBytes(basePosition)); bytes.Prepend(BitConverter.GetBytes((ushort)bytes.Length)); bytes.Prepend(RID.BOUNDSHEET); return(bytes); }
private Bytes SectorBinData(int sectorIndex) { if (0 > sectorIndex || sectorIndex > SectorCount) { throw new ArgumentOutOfRangeException(string.Format("sectorIndex must be >= 0 and <= SectorCount {0}", SectorCount)); } int satSectors, satSid0, startSector, stopSector; Bytes bytes = new Bytes(); satSectors = _doc.SAT.SectorCount; satSid0 = _doc.SAT.SID0; if (sectorIndex == 0) { startSector = 1; stopSector = 109; } else { startSector = 110 + ((sectorIndex - 1) * 127); stopSector = startSector + 126; } for (int i = startSector; i <= stopSector; i++) { if (i < (satSectors + 1)) { bytes.Append(BitConverter.GetBytes((int)(satSid0 + (i - 1)))); } else { bytes.Append(BitConverter.GetBytes((int)-1)); } } if (sectorIndex > 0) { if (stopSector >= satSectors) { bytes.Append(BitConverter.GetBytes((int)-2)); } else { bytes.Append(BitConverter.GetBytes((int)(SID0 + sectorIndex))); } } return(bytes); }
private Bytes CellRangeAddress(ushort minRow, ushort maxRow, ushort minCol, ushort maxCol) { minRow--; maxRow--; minCol--; maxCol--; Bytes rangeAddress = new Bytes(); rangeAddress.Append(BitConverter.GetBytes(minRow)); rangeAddress.Append(BitConverter.GetBytes(maxRow)); rangeAddress.Append(BitConverter.GetBytes(minCol)); rangeAddress.Append(BitConverter.GetBytes(maxCol)); return(rangeAddress); }
internal static Bytes Get(byte[] rid, Bytes data) { if (rid.Length != 2) { throw new ArgumentException("must be 2 bytes", "rid"); } ushort len = (ushort)data.Length; Bytes record = new Bytes(); record.Append(rid); record.Append(BitConverter.GetBytes(len)); record.Append(data); return(record); }
// Token: 0x0600016F RID: 367 RVA: 0x000080F0 File Offset: 0x000070F0 private Bytes CellRangeAddress(ushort minRow, ushort maxRow, ushort minCol, ushort maxCol) { minRow -= 1; maxRow -= 1; minCol -= 1; maxCol -= 1; Bytes bytes = new Bytes(); bytes.Append(BitConverter.GetBytes(minRow)); bytes.Append(BitConverter.GetBytes(maxRow)); bytes.Append(BitConverter.GetBytes(minCol)); bytes.Append(BitConverter.GetBytes(maxCol)); return(bytes); }
private Bytes LABELBase() { Bytes labelBase = new Bytes(); //Index to row labelBase.Append(BitConverter.GetBytes((ushort)(Row - 1))); //Index to column labelBase.Append(BitConverter.GetBytes((ushort)(Column - 1))); //Index to XF record labelBase.Append(BitConverter.GetBytes((ushort)_xfIdx)); return(labelBase); }
private Bytes BLANK() { Bytes blank = new Bytes(); //Index to row blank.Append(BitConverter.GetBytes((ushort)(Row - 1))); //Index to column blank.Append(BitConverter.GetBytes((ushort)(Column - 1))); //Index to XF record blank.Append(BitConverter.GetBytes((ushort)_xfIdx)); return(Record.GetBytes(RID.BLANK, blank)); }
public async Task <Bytes> GetPacket(uint timeout = 5000) { try { await Connect(); var cmdParams = new Bytes((byte)0); cmdParams.Append(timeout); var result = await this.SendCommand(RileyLinkCommandType.SendAndListen, cmdParams, (int)timeout + 500); if (result != null) { return(result.Sub(0, 2).Append(ManchesterEncoding.Decode(result.Sub(2)))); } else { return(null); } } catch (OmniCoreException) { throw; } catch (Exception e) { throw new PacketRadioException("Error while receiving data with RL", e); } }
// Token: 0x0600016A RID: 362 RVA: 0x00007EC4 File Offset: 0x00006EC4 private Bytes INDEX(int baseLength) { Bytes bytes = new Bytes(); Bytes bytes2 = bytes; byte[] byteArray = new byte[4]; bytes2.Append(byteArray); bytes.Append(BitConverter.GetBytes(this._rows.MinRow - 1U)); bytes.Append(BitConverter.GetBytes(this._rows.MaxRow)); bytes.Append(BitConverter.GetBytes(0U)); for (int i = 1; i < this._dbCellOffsets.Length; i++) { bytes.Append(BitConverter.GetBytes((uint)(baseLength + this._dbCellOffsets[i]))); } return(Record.GetBytes(RID.INDEX, bytes)); }
private static Bytes BOUNDSHEET(Worksheet sheet, int basePosition) { Bytes bytes = new Bytes(); Bytes sheetName = XlsDocument.BinUniStr1(sheet.Name); bytes.Append(WorksheetVisibility.GetBytes(sheet.Visibility)); bytes.Append(WorksheetType.GetBytes(sheet.SheetType)); bytes.Append(sheetName); bytes.Prepend(BitConverter.GetBytes((int)basePosition)); //TODO: this should probably be unsigned 32 instead bytes.Prepend(BitConverter.GetBytes((ushort)bytes.Length)); bytes.Prepend(RID.BOUNDSHEET); return(bytes); }
private Bytes MERGEDCELLS() { Bytes mergedcells = new Bytes(); int areaIndex = 0; int mergeAreaCount = _mergeAreas.Count; long areasPerRecord = 1027; int recordsRequired = (int)Math.Ceiling(_mergeAreas.Count / (double)areasPerRecord); for (int recordIndex = 0; recordIndex < recordsRequired; recordIndex++) { ushort blockAreaIndex = 0; Bytes rangeAddresses = new Bytes(); while (areaIndex < mergeAreaCount && blockAreaIndex < areasPerRecord) { rangeAddresses.Append(CellRangeAddress(_mergeAreas[areaIndex])); blockAreaIndex++; areaIndex++; } rangeAddresses.Prepend(BitConverter.GetBytes(blockAreaIndex)); mergedcells.Append(Record.GetBytes(RID.MERGEDCELLS, rangeAddresses)); } return(mergedcells); }