public RUSEMCModuleDevice(WordSerializator serializator) : base(serializator) { _serial = 100; _status16 = 0; _calibrationFile = deserialize(Properties.Resources.V01_RUS40_Cal, FileType.CALIBRATION); _factorySettingsFile = deserialize(Properties.Resources.V01_RUS40_FSet, FileType.FACTORY_SETTINGS); _dataPacketFormatFile = generateDataPacketFormatFile(); byte[] generateDataPacketFormatFile() { var body = new Enumerable <byte>() { "EMC_Mdl_0101DDMMYYF_".GetASCIIBytes(), serializator.Serialize(_serial), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Reserved }; var i = new SmartInt().Add(1); addEntity("STAT", i, i.Add(2).DValue, 0); addEntity("STAT", i, i.Add(2).DValue, 0); addEntity("TST1", i, i.Add(2).DValue, 0); addEntity("TST2", i, i.Add(2).DValue, 0); return(body.ToArray()); void addEntity(string mnemonicName, int position, int length, byte numOfBits) { body.Add(mnemonicName.GetASCIIBytes()); body.Add(_serializator.Serialize((ushort)position)); body.Add((byte)length); body.Add(numOfBits); } } }
public void Parse_SmartDouble() { for (int i = 0; i < N; i++) { sd_doubles[i] = SmartInt.Parse(s_doubles[i]); } }
/// <summary> /// Implicit conversion between SmartInt and System.Decimal. /// </summary> public static void AssignmentDecimal() { try { SmartInt v1 = 7; System.Decimal v2 = 5; Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); v2 = v1; // Implicit conversion Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); v2 = 4; v1 = (SmartInt)v2; // Only explicit conversion allowed Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); } catch (Exception ex) { Console.Write("Exception:"); Console.Write(ex.Message); Console.WriteLine(); } }
/// <summary> /// Use SmartInt in for cycle and as indexer in place where System.Int32 is used. /// </summary> public static void IteratorIndexer() { try { String shello = "Hello !"; Char[] chello = { 'H', 'e', 'l', 'l', 'o', ' ', '!' }; for (SmartInt i = 0; i < shello.Length; i++) { Console.Write(shello[i]); } Console.WriteLine(); for (SmartInt i = 0; i < chello.Length; i++) { Console.Write(chello[i]); } Console.WriteLine(); } catch (Exception ex) { Console.Write("Exception:"); Console.Write(ex.Message); Console.WriteLine(); } }
/// <summary> /// Implicit conversion between SmartInt and System.Int16. /// </summary> public static void AssignmentSingle() { try { SmartInt v1 = 7; System.Int16 v2 = 5; Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); v2 = (System.Int16)v1; // Explicit conversion Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); v2 = 4; v1 = v2; // Implicit conversion Console.Write(v1.ToString()); // Use v1.ToString() instead of single v1 to avoid implicit conversion to int Console.Write(", "); Console.WriteLine(v2); } catch (Exception ex) { Console.Write("Exception:"); Console.Write(ex.Message); Console.WriteLine(); } }
public void ToString_SmartDouble() { for (int i = 0; i < N; i++) { d_strings[i] = SmartInt.ToStringValue(ints[i]); } }
public override bool Equals(object obj) { if (obj is SmartInt) { SmartInt other = (SmartInt)obj; return((int)this == (int)other); } return(base.Equals(obj)); }
static void ParsePropertyValue <T>(T obj, FieldInfo fieldInfo, string valueStr) { System.Object value = valueStr; if (fieldInfo.FieldType.IsEnum) { value = Enum.Parse(fieldInfo.FieldType, valueStr); } else { if (fieldInfo.FieldType == typeof(int)) { value = int.Parse(valueStr); } else if (fieldInfo.FieldType == typeof(byte)) { value = byte.Parse(valueStr); } else if (fieldInfo.FieldType == typeof(SmartInt)) { value = new SmartInt(int.Parse(valueStr)); } else if (fieldInfo.FieldType == typeof(float)) { value = float.Parse(valueStr); } else if (fieldInfo.FieldType == typeof(double)) { value = double.Parse(valueStr); } else { if (valueStr.Contains("\"\"")) { valueStr = valueStr.Replace("\"\"", "\""); } // process the excel string. if (valueStr.Length > 2 && valueStr[0] == '\"' && valueStr[valueStr.Length - 1] == '\"') { valueStr = valueStr.Substring(1, valueStr.Length - 2); } value = valueStr; } } if (value == null) { return; } fieldInfo.SetValue(obj, value); }
public InclinometrVirtualDevice(WordSerializator serializator) : base(serializator) { _serial = 999; _calibrationFile = deserialize(Properties.Resources.V01_RUS03_Cal, FileType.CALIBRATION); _factorySettingsFile = deserialize(Properties.Resources.V01_RUS03_FSet, FileType.FACTORY_SETTINGS); _dataPacketFormatFile = generateDataPacketFormatFile(); _flashDataPacketFormatFile = _dataPacketFormatFile; _temperatureCalibrationFile = deserialize(Properties.Resources.V01_RUS03_TCal, FileType.TEMPERATURE_CALIBRATION); byte[] generateDataPacketFormatFile() { var body = new Enumerable <byte>() { "INCL____0101DDMMYYF_".GetASCIIBytes(), serializator.Serialize(_serial), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Reserve }; var i = new SmartInt().Add(1); addEntity("STAT", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("INC_", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("AZI_", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("GTF_", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("XGpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("YGpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("ZGpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("XMpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("YMpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("ZMpr", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("TGad", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("TMad", (ushort)i, (byte)i.Add(2).DValue, 0, true); return(body.ToArray()); void addEntity(string mnemonicName, ushort position, byte length, byte numOfBits, bool isSigned) { body.Add(mnemonicName.GetASCIIBytes()); body.Add(_serializator.Serialize(position)); body.Add(length); body.Add((isSigned ? (1 << 7) : 0).ToByte().BitOR(numOfBits)); } } }
public RotationSensorVirtualDevice(WordSerializator serializator) : base(serializator) { _calibrationFile = deserialize(Properties.Resources.V01_RUS07_Cal, FileType.CALIBRATION); _factorySettingsFile = deserialize(Properties.Resources.V01_RUS07_FSet, FileType.FACTORY_SETTINGS); _dataPacketFormatFile = generateDataPacketFormatFile(); _flashDataPacketFormatFile = generateDataPacketFormatFile(); _temperatureCalibrationFile = deserialize(Properties.Resources.V01_RUS07_TCal, FileType.TEMPERATURE_CALIBRATION); byte[] generateDataPacketFormatFile() { var body = new Enumerable <byte>() { "Bl_Gyro_0101DDMMYYF_".GetASCIIBytes(), serializator.Serialize(_serial), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Reserve }; var i = new SmartInt().Add(1); addEntity("STAT", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("SGY1", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("SRO1", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("ANG1", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("TEM1", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("SGY2", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("SRO2", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("ANG2", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("TEM2", (ushort)i, (byte)i.Add(2).DValue, 0, true); addEntity("ADSG", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("ADH1", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("ADH2", (ushort)i, (byte)i.Add(2).DValue, 0, false); addEntity("ADTM", (ushort)i, (byte)i.Add(2).DValue, 0, true); return(body.ToArray()); void addEntity(string mnemonicName, ushort position, byte length, byte numOfBits, bool isSigned) { body.Add(mnemonicName.GetASCIIBytes()); body.Add(_serializator.Serialize(position)); body.Add(length); body.Add((isSigned ? 1 : 0).ToByte().BitLShift(7).BitOR(numOfBits)); } } }
public void SmartInt_Parse_BruteForce_Test() { int test_count = 10000000; Random rnd = new Random(); for (int i = 0; i < test_count; i++) { int v = rnd.Next(); string s = v.ToString(); string sp = "+" + s; string sn = "-" + s; SmartInt siv = SmartInt.Parse(s); SmartInt sipv = SmartInt.Parse(sp); SmartInt sinv = SmartInt.Parse(sn); Assert.IsTrue((siv == v) && (sipv == v) && (sinv == -v), "Parsing " + v.ToString()); } }
/// <summary> /// Parse and error control of SmartInt and System.Int32. /// SmartInt takes SmartInt.BadValue value. /// System.Int32.Parse throws exception. /// </summary> public static void Parse1Error() { try { SmartInt i = SmartInt.Parse("abc"); Console.Write("SmartInt:"); Console.Write(i.ToString()); // Use i.ToString() instead of single i to avoid implicit conversion to int Console.Write(" IsBad:"); Console.WriteLine(i.isBad()); System.Int32 i2 = System.Int32.Parse("abc"); Console.Write("System.Int32:"); Console.WriteLine(i2); } catch (Exception ex) { Console.Write("Exception:"); Console.Write(ex.Message); Console.WriteLine(); } }
/// <summary> /// Compare sizes of arrays of int, int?s and SmartInt /// </summary> public static void ArraySize() { int objects_count = 1000; long memory1 = GC.GetTotalMemory(true); int[] ai = new int[objects_count]; long memory2 = GC.GetTotalMemory(true); int?[] ani = new int?[objects_count]; long memory3 = GC.GetTotalMemory(true); SmartInt[] asi = new SmartInt[objects_count]; long memory4 = GC.GetTotalMemory(true); // Compiler can optimize and do not allocate arrays if they are not used // So we write their lengths Console.WriteLine("Array sizes {0}, {1}, {2}", ai.Length, ani.Length, asi.Length); Console.WriteLine("Memory for int \t {0}", memory2 - memory1); Console.WriteLine("Memory for int? \t {0}", memory3 - memory2); Console.WriteLine("Memory for SmartInt \t {0}", memory4 - memory3); }
public void SmartInt_ToString_BruteForce_Test() { int test_count = 10000000; Random rnd = new Random(); for (int i = 0; i < test_count; i++) { int v = rnd.Next(); int vn = -v; string s = v.ToString(); string sn = vn.ToString(); SmartInt siv = v; SmartInt sivn = vn; string sis = siv.ToString(); string sisn = sivn.ToString(); Assert.IsTrue((sis == s) && (sisn == sn), "ToString " + v.ToString()); } }
public static RequestInfo GetRequestDescription(RUSDeviceId deviceId, Command request) { var info = (deviceId, request); if (info.request.IsOneOf(Command.KEEP_MTF, Command.ROTATE_WITH_CONSTANT_SPEED, Command.DRILL_DIRECTLY, Command.TURN_ON_AZIMUTH)) { var i = new SmartInt(); return(new RequestInfo(deviceId, request, new EntityDescriptor[] { new EntityDescriptor("Inc", i, i.Add(2).DValue, DataEntityFormat.INT16), new EntityDescriptor("Azi", i, i.Add(2).DValue, DataEntityFormat.INT16), new EntityDescriptor("MTF", i, i.Add(2).DValue, DataEntityFormat.INT16), })); } else if (info == (RUSDeviceId.LWD_LINK, Command.PBP_SETTINGS)) { return(new RequestInfo(deviceId, request, new EntityDescriptor[] { new EntityDescriptor("Количество секторов", 0, 1, DataEntityFormat.UINT8), new EntityDescriptor("Время молчания", 1, 1, DataEntityFormat.UINT8) })); }
public RUSTechnologicalModuleDevice(WordSerializator serializator) : base(serializator) { _serial = 100; _status32 = Global.Random.NextUInt(); _calibrationFile = deserialize(Properties.Resources.V01_RUS24_Cal, FileType.CALIBRATION); _factorySettingsFile = deserialize(Properties.Resources.V01_RUS24_FSet, FileType.FACTORY_SETTINGS); _dataPacketFormatFile = generateDataPacketFormatFile(); _flashDataPacketFormatFile = generateDataPacketFormatFile(); _temperatureCalibrationFile = deserialize(Properties.Resources.V01_RUS24_TCal, FileType.TEMPERATURE_CALIBRATION); _workModeFile = deserialize(Properties.Resources.V01_RUS24_WMode, FileType.WORK_MODE); byte[] generateDataPacketFormatFile() { var body = new Enumerable <byte>() { "TEXMODUL0101DDMMYYF_".GetASCIIBytes(), serializator.Serialize(_serial), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Reserved }; var i = new SmartInt().Add(1); addEntity("STAT", i, i.Add(2).DValue, 0); addEntity("STAT", i, i.Add(2).DValue, 0); addEntity("TST1", i, i.Add(2).DValue, 0); addEntity("TST2", i, i.Add(2).DValue, 0); return(body.ToArray()); void addEntity(string mnemonicName, int position, int length, byte numOfBits) { body.Add(mnemonicName.GetASCIIBytes()); body.Add(_serializator.Serialize((ushort)position)); body.Add((byte)length); body.Add(numOfBits); } } }
static Files() { var pos = new SmartInt(); var dpedPos = new SmartInt(); RUSDeviceId id = 0; string name = null; var descriptors = new Dictionary <FileDescriptorsTarget, FileStructure>(); BaseFileTemplate = new FBED[] { new FBED("Краткое название прибора", pos, pos.Add(8).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.ANOTHER), new FBED("Модификация", pos, pos.Add(2), DataEntityFormat.ASCII_STRING, FileEntityType.MODIFICATION), new FBED("Версия ПО или пакета данных", pos, pos.Add(2).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.FORMAT_VERSION), new FBED("Дата составления файла", pos, pos.Add(2).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.BURN_DAY), new FBED("Месяц составления файла", pos, pos.Add(2).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.BURN_MONTH), new FBED("Год составления файла", pos, pos.Add(2).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.BURN_YEAR), new FBED("Указатель типа файла", pos, pos.Add(2).DValue, DataEntityFormat.ASCII_STRING, FileEntityType.FILE_TYPE_POINTER), new FBED("Серийный номер прибора", pos, pos.Add(2).DValue, DataEntityFormat.UINT16, FileEntityType.SERIAL_NUMBER), }; #region Telemetry 0b00000001 name = "________"; id = RUSDeviceId.TELEMETRY; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region RUSModule 0b00000010 name = "________"; id = RUSDeviceId.RUS_MODULE; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region DriveControll 0b00000110 name = "________"; id = RUSDeviceId.DRIVE_CONTROL; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region Telesystem 0b00001000 name = "________"; id = RUSDeviceId.TELESYSTEM; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region RUSEMCModule 0b01010000 name = "EMC_Mdl_"; id = RUSDeviceId.EMC_MODULE; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region TechnologicalModule 0b00001000 name = "TexModul"; id = RUSDeviceId.RUS_TECHNOLOGICAL_MODULE; pos.Value = 0; { pos.Value = 0; var v01Target = new FileDescriptorsTarget(FileType.FACTORY_SETTINGS, "01", id); var v01 = new Enumerable <FED> { createHeader(name, FileType.FACTORY_SETTINGS.GetInfo().FileTypePointerName), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), new FED("Массив UInt8[36]", pos, pos.Add(36).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), }.ToArray(); descriptors.Add(v01Target, new FileStructure(v01)); } registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); { pos.Value = 0; var v01CalibrationTarget = new FileDescriptorsTarget(FileType.CALIBRATION, "01", id); var v01Calibration = new Enumerable <FED> { createHeader(name, FileType.CALIBRATION.GetInfo().FileTypePointerName), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), new FED("Калибровки", pos, pos.Add(36).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), }.ToArray(); descriptors.Add(v01CalibrationTarget, new FileStructure(v01Calibration)); } { pos.Value = 0; var v01TemperatureCalibrationTarget = new FileDescriptorsTarget(FileType.TEMPERATURE_CALIBRATION, "01", id); var v01TemperatureCalibration = new Enumerable <FED> { createHeader(name, FileType.TEMPERATURE_CALIBRATION.GetInfo().FileTypePointerName), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), new FED("Калибровки", pos, pos.Add(36).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]), }.ToArray(); descriptors.Add(v01TemperatureCalibrationTarget, new FileStructure(v01TemperatureCalibration)); } pos.Value = 0; var v01CalibrationFileForTechnologicalModuleTarget = new FileDescriptorsTarget(FileType.WORK_MODE, "01", id); var v01CalibrationFileForTechnologicalModule = new Enumerable <FED> { createHeader(name, FileType.WORK_MODE.GetInfo().FileTypePointerName), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Режим работы", pos, pos.Add(36).DValue, DataEntityFormat.BYTE_ARRAY, new byte[pos.DValue]) }.ToArray(); descriptors.Add(v01CalibrationFileForTechnologicalModuleTarget, new FileStructure(v01CalibrationFileForTechnologicalModule)); #endregion #region RUSLWDLink 0b00001001 name = "SNAPUNIT"; id = RUSDeviceId.LWD_LINK; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); registerStandard(FileType.CALIBRATION); registerStandard(FileType.DATA_PACKET_CONFIGURATION); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); #endregion #region ShockSensor 0b00000101 name = "SHOCK___"; id = RUSDeviceId.SHOCK_SENSOR; registerStandard(FileType.FACTORY_SETTINGS); pos.Value = 0; var v01DataPacketConfigurationFileForShockSensorTarget = new FileDescriptorsTarget(FileType.DATA_PACKET_CONFIGURATION, "01", id); var v01DataPacketConfigurationFileForShockSensor = new Enumerable <FED> { createHeader(name, "F_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Массив описаний пакета данных", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.DATA_PACKET_ENTITIES_ARRAY, new DataPacketEntityDescriptor[] { new DataPacketEntityDescriptor("SH5O", 2, 1, false), new DataPacketEntityDescriptor("SH1O", 2, 3, false), new DataPacketEntityDescriptor("SH2O", 2, 5, false), new DataPacketEntityDescriptor("SH3O", 2, 7, false), new DataPacketEntityDescriptor("SH5R", 2, 9, false), new DataPacketEntityDescriptor("SH1R", 2, 11, false), new DataPacketEntityDescriptor("SH2R", 2, 13, false), new DataPacketEntityDescriptor("SH3R", 2, 15, false), new DataPacketEntityDescriptor("ARAD", 2, 17, false), new DataPacketEntityDescriptor("AOSV", 2, 19, false), }), }.ToArray(); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); pos.Value = 0; var v01CalibrationFileForShockSensorTarget = new FileDescriptorsTarget(FileType.CALIBRATION, "01", id); var v01CalibrationFileForShockSensor = new Enumerable <FED> { createHeader(name, "K_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Калибровки", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.CALIBRATION_PACKET_ENTITIES_ARRAY, new CalibrationFileEntity[] { CalibrationFileEntity.CreateConstantsTable("G0_", DataTypes.UINT16, new ushort[] { 517, 517, 517 }), CalibrationFileEntity.CreateConstantsTable("POR_", DataTypes.UINT16, new ushort[] { 41, 82, 164, 246 }), CalibrationFileEntity.CreateConstantsTable("TMR", DataTypes.UINT16, new ushort[] { 2 }), }), }.ToArray(); descriptors.Add(v01CalibrationFileForShockSensorTarget, new FileStructure(v01CalibrationFileForShockSensor)); descriptors.Add(v01DataPacketConfigurationFileForShockSensorTarget, new FileStructure(v01DataPacketConfigurationFileForShockSensor)); #endregion #region RotationSensor 0b00000111 name = "Bl_Gyro_"; id = RUSDeviceId.ROTATIONS_SENSOR; pos.Value = 0; dpedPos.Value = 1; registerStandard(FileType.FACTORY_SETTINGS); pos.Value = 0; var v01DataPacketConfigurationFileForRotationSensorTarget = new FileDescriptorsTarget(FileType.DATA_PACKET_CONFIGURATION, "01", id); var v01DataPacketConfigurationFileForRotationSensor = new Enumerable <FED> { createHeader(name, "F_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Массив описаний пакета данных", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.DATA_PACKET_ENTITIES_ARRAY, new DataPacketEntityDescriptor[] { new DataPacketEntityDescriptor("STAT", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("SGY1", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("SRO1", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("ANG1", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("TEM1", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("SGY2", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("SRO2", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("ANG2", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("TEM2", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), new DataPacketEntityDescriptor("ADSG", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("ADH1", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("ADH2", dpedPos.Add(2).DValue, dpedPos.PreviousValue, false), new DataPacketEntityDescriptor("ADTM", dpedPos.Add(2).DValue, dpedPos.PreviousValue, true), }), }.ToArray(); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); registerStandardCalibrationFile(CalibrationFileEntity.CreateConstantsTable("dTe", DataTypes.INT16, new short[] { 0 })); pos.Value = 0; var v01TemperatureCalibrationFileForRotationSensorTarget = new FileDescriptorsTarget(FileType.TEMPERATURE_CALIBRATION, "01", id); var v01TemperatureCalibrationFileForRotationSensor = new Enumerable <FED> { createHeader(name, "T_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Калибровки", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.CALIBRATION_PACKET_ENTITIES_ARRAY, new CalibrationFileEntity[] { CalibrationFileEntity.CreateArray("AH1", DataTypes.UINT16, Enumerable.Repeat((ushort)32498, 156).ToArray()), CalibrationFileEntity.CreateArray("AH2", DataTypes.UINT16, Enumerable.Repeat((ushort)32715, 156).ToArray()), CalibrationFileEntity.CreateArray("ASG", DataTypes.UINT16, Enumerable.Repeat((ushort)32809, 156).ToArray()), CalibrationFileEntity.CreateArray("Kgy", DataTypes.FLOAT, Enumerable.Repeat((float)0.12947888, 156).ToArray()) }), }.ToArray(); descriptors.Add(v01DataPacketConfigurationFileForRotationSensorTarget, new FileStructure(v01DataPacketConfigurationFileForRotationSensor)); descriptors.Add(v01TemperatureCalibrationFileForRotationSensorTarget, new FileStructure(v01TemperatureCalibrationFileForRotationSensor)); #endregion #region Izmeritel 0b00000100 name = "Izmeritl"; id = RUSDeviceId.IZMERITEL; pos.Value = 0; registerStandard(FileType.FACTORY_SETTINGS); pos.Value = 0; var v01DataPacketConfigurationFileForIzmeritelTarget = new FileDescriptorsTarget(FileType.DATA_PACKET_CONFIGURATION, "01", id); var v01DataPacketConfigurationFileForIzmeritel = new Enumerable <FED> { createHeader(name, "F_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Массив описаний пакета данных", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.DATA_PACKET_ENTITIES_ARRAY, new DataPacketEntityDescriptor[] { new DataPacketEntityDescriptor("TimP", 2, 0x07, false), new DataPacketEntityDescriptor("DD1_", 2, 0x09, false), new DataPacketEntityDescriptor("DD2_", 2, 0x0B, false), new DataPacketEntityDescriptor("TDD1", 2, 0x0D, false), new DataPacketEntityDescriptor("TDD2", 2, 0x0F, false), new DataPacketEntityDescriptor("TACD", 2, 0x11, false), new DataPacketEntityDescriptor("+INC", 2, 0x13, false), new DataPacketEntityDescriptor("-INC", 2, 0x14, false), new DataPacketEntityDescriptor("GK__", 2, 0x15, false), new DataPacketEntityDescriptor("TIME", 2, 0x17, false), new DataPacketEntityDescriptor("URTC", 2, 0x19, false), new DataPacketEntityDescriptor("REZ_", 2, 0x1B, false), new DataPacketEntityDescriptor("SerN", 2, 0x23, false), }), }.ToArray(); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); registerStandard(FileType.CALIBRATION); descriptors.Add(v01DataPacketConfigurationFileForIzmeritelTarget, new FileStructure(v01DataPacketConfigurationFileForIzmeritel)); #endregion #region Inclinometr 0b00000011 name = "INCL____"; id = RUSDeviceId.INCLINOMETR; pos.Value = 0; dpedPos.Value = 1; registerStandard(FileType.FACTORY_SETTINGS); pos.Value = 0; var v01DataPacketConfigurationFileForInclinometrTarget = new FileDescriptorsTarget(FileType.DATA_PACKET_CONFIGURATION, "01", id); var v01DataPacketConfigurationFileForInclinometr = new Enumerable <FED> { createHeader("INCL____", "F_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Массив описаний пакета данных", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.DATA_PACKET_ENTITIES_ARRAY, new DataPacketEntityDescriptor[] { new DataPacketEntityDescriptor("STAT", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("INC_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("GTF_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("MTF_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("AZI_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("DIP_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("GTOT", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("BTOT", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("GCNT", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("Taks", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("Tmag", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("XGrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("YGrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("ZGrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("XMrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("YMrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("ZMrp", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("XGad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("YGad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("ZGad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("XMad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("YMad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("ZMad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x8F), new DataPacketEntityDescriptor("TGad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("Tmad", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("UHV_", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("UHAL", dpedPos.Add(2).DValue, dpedPos.PreviousValue, 0x10), new DataPacketEntityDescriptor("RSRV", dpedPos.Add(2).DValue, 59, 0x10), }), }.ToArray(); registerStandard(FileType.FLASH_DATA_PACKET_CONFIGURATION); registerStandard(FileType.CALIBRATION); pos.Value = 0; var v01TemperatureCalibrationFileForInclinometrTarget = new FileDescriptorsTarget(FileType.TEMPERATURE_CALIBRATION, "01", id); var v01TemperatureCalibrationFileForInclinometr = new Enumerable <FED> { createHeader(name, "T_"), new FED("Резерв", pos, pos.Add(14).DValue, DataEntityFormat.BYTE_ARRAY, new byte[14]), new FED("Калибровки", pos, EntityLength.TILL_THE_END_OF_A_PACKET, DataEntityFormat.CALIBRATION_PACKET_ENTITIES_ARRAY, new CalibrationFileEntity[] { CalibrationFileEntity.CreateLinearInterpolationTable("G1x", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), CalibrationFileEntity.CreateLinearInterpolationTable("G1y", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), CalibrationFileEntity.CreateLinearInterpolationTable("G1z", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), CalibrationFileEntity.CreateLinearInterpolationTable("M1x", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), CalibrationFileEntity.CreateLinearInterpolationTable("M1y", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), CalibrationFileEntity.CreateLinearInterpolationTable("M1z", DataTypes.FLOAT, 140.Range().Select(_ => (0F, 1F)).ToArray()), }),
public void SmartInt_Parse_String_Test() { #region General Assert.AreEqual(1, (int)SmartInt.Parse("1"), "Parsing \"1\""); Assert.AreEqual(73, (int)SmartInt.Parse("73"), "Parsing \"73\""); Assert.AreEqual(9462, (int)SmartInt.Parse("9462"), "Parsing \"9462\""); Assert.AreEqual(123456789, (int)SmartInt.Parse("123456789"), "Parsing \"123456789\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-1"), "Parsing \"-1\""); Assert.AreEqual(-73, (int)SmartInt.Parse("-73"), "Parsing \"-73\""); Assert.AreEqual(-9462, (int)SmartInt.Parse("-9462"), "Parsing \"-9462\""); Assert.AreEqual(-123456789, (int)SmartInt.Parse("-123456789"), "Parsing \"-123456789\""); #endregion #region Leading zeros // Positive Sihned Leading zeros Assert.AreEqual(0, (int)SmartInt.Parse("0"), "Parsing \"0\""); Assert.AreEqual(1, (int)SmartInt.Parse("01"), "Parsing \"01\""); Assert.AreEqual(1, (int)SmartInt.Parse("001"), "Parsing \"001\""); Assert.AreEqual(1, (int)SmartInt.Parse("0001"), "Parsing \"0001\""); Assert.AreEqual(1, (int)SmartInt.Parse("00001"), "Parsing \"00001\""); Assert.AreEqual(1, (int)SmartInt.Parse("000001"), "Parsing \"000001\""); Assert.AreEqual(1, (int)SmartInt.Parse("0000001"), "Parsing \"0000001\""); Assert.AreEqual(123, (int)SmartInt.Parse("0123"), "Parsing \"0123\""); Assert.AreEqual(123, (int)SmartInt.Parse("00123"), "Parsing \"00123\""); Assert.AreEqual(123, (int)SmartInt.Parse("000123"), "Parsing \"000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("0000123"), "Parsing \"0000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("00000123"), "Parsing \"00000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("000000123"), "Parsing \"000000123\""); // Negative Leading zeros Assert.AreEqual(0, (int)SmartInt.Parse("-0"), "Parsing \"-0\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-01"), "Parsing \"-01\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-001"), "Parsing \"-001\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-0001"), "Parsing \"-0001\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-00001"), "Parsing \"-00001\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-000001"), "Parsing \"-000001\""); Assert.AreEqual(-1, (int)SmartInt.Parse("-0000001"), "Parsing \"-0000001\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-0123"), "Parsing \"-0123\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-00123"), "Parsing \"-00123\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-000123"), "Parsing \"-000123\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-0000123"), "Parsing \"-0000123\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-00000123"), "Parsing \"-00000123\""); Assert.AreEqual(-123, (int)SmartInt.Parse("-000000123"), "Parsing \"-000000123\""); // Positively Sihned Leading zeros Assert.AreEqual(0, (int)SmartInt.Parse("+0"), "Parsing \"+0\""); Assert.AreEqual(1, (int)SmartInt.Parse("+01"), "Parsing \"+01\""); Assert.AreEqual(1, (int)SmartInt.Parse("+001"), "Parsing \"+001\""); Assert.AreEqual(1, (int)SmartInt.Parse("+0001"), "Parsing \"+0001\""); Assert.AreEqual(1, (int)SmartInt.Parse("+00001"), "Parsing \"+00001\""); Assert.AreEqual(1, (int)SmartInt.Parse("+000001"), "Parsing \"+000001\""); Assert.AreEqual(1, (int)SmartInt.Parse("+0000001"), "Parsing \"+0000001\""); Assert.AreEqual(123, (int)SmartInt.Parse("+0123"), "Parsing \"+0123\""); Assert.AreEqual(123, (int)SmartInt.Parse("+00123"), "Parsing \"+00123\""); Assert.AreEqual(123, (int)SmartInt.Parse("+000123"), "Parsing \"+000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("+0000123"), "Parsing \"+0000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("+00000123"), "Parsing \"+00000123\""); Assert.AreEqual(123, (int)SmartInt.Parse("+000000123"), "Parsing \"+000000123\""); #endregion #region With Spaces Assert.AreEqual(0, (int)SmartInt.Parse(" 0 "), "Parsing \" 0 \""); Assert.AreEqual(1, (int)SmartInt.Parse(" 01 "), "Parsing \" 01 \""); Assert.AreEqual(123, (int)SmartInt.Parse(" 0123 "), "Parsing \" 0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse(" -0 "), "Parsing \" -0 \""); Assert.AreEqual(-1, (int)SmartInt.Parse(" -01 "), "Parsing \" -01 \""); Assert.AreEqual(-123, (int)SmartInt.Parse(" -0123 "), "Parsing \" -0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse(" +0 "), "Parsing \" +0 \""); Assert.AreEqual(1, (int)SmartInt.Parse(" +01 "), "Parsing \" +01 \""); Assert.AreEqual(123, (int)SmartInt.Parse(" +0123 "), "Parsing \" +0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse(" 0 "), "Parsing \" 0 \""); Assert.AreEqual(1, (int)SmartInt.Parse(" 01 "), "Parsing \" 01 \""); Assert.AreEqual(123, (int)SmartInt.Parse(" 0123 "), "Parsing \" 0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse(" -0 "), "Parsing \" -0 \""); Assert.AreEqual(-1, (int)SmartInt.Parse(" -01 "), "Parsing \" -01 \""); Assert.AreEqual(-123, (int)SmartInt.Parse(" -0123 "), "Parsing \" -0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse(" +0 "), "Parsing \" +0 \""); Assert.AreEqual(1, (int)SmartInt.Parse(" +01 "), "Parsing \" +01 \""); Assert.AreEqual(123, (int)SmartInt.Parse(" +0123 "), "Parsing \" +0123 \""); // Leading Spaces Assert.AreEqual(0, (int)SmartInt.Parse(" 0"), "Parsing \" 0\""); Assert.AreEqual(1, (int)SmartInt.Parse(" 01"), "Parsing \" 01\""); Assert.AreEqual(123, (int)SmartInt.Parse(" 0123"), "Parsing \" 0123\""); Assert.AreEqual(0, (int)SmartInt.Parse(" -0"), "Parsing \" -0\""); Assert.AreEqual(-1, (int)SmartInt.Parse(" -01"), "Parsing \" -01\""); Assert.AreEqual(-123, (int)SmartInt.Parse(" -0123"), "Parsing \" -0123\""); Assert.AreEqual(0, (int)SmartInt.Parse(" +0"), "Parsing \" +0\""); Assert.AreEqual(1, (int)SmartInt.Parse(" +01"), "Parsing \" +01\""); Assert.AreEqual(123, (int)SmartInt.Parse(" +0123"), "Parsing \" +0123\""); Assert.AreEqual(0, (int)SmartInt.Parse(" 0"), "Parsing \" 0\""); Assert.AreEqual(1, (int)SmartInt.Parse(" 01"), "Parsing \" 01\""); Assert.AreEqual(123, (int)SmartInt.Parse(" 0123"), "Parsing \" 0123\""); Assert.AreEqual(0, (int)SmartInt.Parse(" -0"), "Parsing \" -0\""); Assert.AreEqual(-1, (int)SmartInt.Parse(" -01"), "Parsing \" -01\""); Assert.AreEqual(-123, (int)SmartInt.Parse(" -0123"), "Parsing \" -0123\""); Assert.AreEqual(0, (int)SmartInt.Parse(" +0"), "Parsing \" +0\""); Assert.AreEqual(1, (int)SmartInt.Parse(" +01"), "Parsing \" +01\""); Assert.AreEqual(123, (int)SmartInt.Parse(" +0123"), "Parsing \" +0123\""); // Finaling Spaces Assert.AreEqual(0, (int)SmartInt.Parse("0 "), "Parsing \"0 \""); Assert.AreEqual(1, (int)SmartInt.Parse("01 "), "Parsing \"01 \""); Assert.AreEqual(123, (int)SmartInt.Parse("0123 "), "Parsing \"0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse("-0 "), "Parsing \"-0 \""); Assert.AreEqual(-1, (int)SmartInt.Parse("-01 "), "Parsing \"-01 \""); Assert.AreEqual(-123, (int)SmartInt.Parse("-0123 "), "Parsing \"-0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse("+0 "), "Parsing \"+0 \""); Assert.AreEqual(1, (int)SmartInt.Parse("+01 "), "Parsing \"+01 \""); Assert.AreEqual(123, (int)SmartInt.Parse("+0123 "), "Parsing \"+0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse("0 "), "Parsing \"0 \""); Assert.AreEqual(1, (int)SmartInt.Parse("01 "), "Parsing \"01 \""); Assert.AreEqual(123, (int)SmartInt.Parse("0123 "), "Parsing \"0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse("-0 "), "Parsing \"-0 \""); Assert.AreEqual(-1, (int)SmartInt.Parse("-01 "), "Parsing \"-01 \""); Assert.AreEqual(-123, (int)SmartInt.Parse("-0123 "), "Parsing \"-0123 \""); Assert.AreEqual(0, (int)SmartInt.Parse("+0 "), "Parsing \"+0 \""); Assert.AreEqual(1, (int)SmartInt.Parse("+01 "), "Parsing \"+01 \""); Assert.AreEqual(123, (int)SmartInt.Parse("+0123 "), "Parsing \"+0123 \""); #endregion #region Values that shall be parsed to SmartDouble.BadValue without throwing Assert.AreEqual(true, SmartInt.Parse("").isBad(), "Parsing \"\""); Assert.AreEqual(true, SmartInt.Parse(" ").isBad(), "Parsing \" \""); Assert.AreEqual(true, SmartInt.Parse(" ").isBad(), "Parsing \" \""); Assert.AreEqual(true, SmartInt.Parse(" -").isBad(), "Parsing \" -\""); Assert.AreEqual(true, SmartInt.Parse(" +").isBad(), "Parsing \" +\""); Assert.AreEqual(true, SmartInt.Parse("- ").isBad(), "Parsing \"- \""); Assert.AreEqual(true, SmartInt.Parse("- ").isBad(), "Parsing \"+ \""); Assert.AreEqual(true, SmartInt.Parse(" - ").isBad(), "Parsing \" - \""); Assert.AreEqual(true, SmartInt.Parse(" + ").isBad(), "Parsing \" + \""); Assert.AreEqual(true, SmartInt.Parse("-").isBad(), "Parsing \"-\""); Assert.AreEqual(true, SmartInt.Parse("+").isBad(), "Parsing \"+\""); string null_str = null; Assert.AreEqual(true, SmartInt.Parse(null_str).isBad(), "Parsing null"); Assert.AreEqual(true, SmartInt.Parse("abrakadabra").isBad(), "Parsing \"abrakadabra\""); Assert.AreEqual(true, SmartInt.Parse("1.0").isBad(), "Parsing \"1.0\""); Assert.AreEqual(true, SmartInt.Parse("1 m.").isBad(), "Parsing \"1 m.\""); Assert.AreEqual(true, SmartInt.Parse("x1").isBad(), "Parsing \"x1\""); #endregion #region Extremal values that shall be parsed to SmartDouble.BadValue without throwing // 8 bills Assert.AreEqual(true, SmartInt.Parse("8123123123").isBad(), "Parsing \"8123123123\""); // Digits { int strlen = 16 * 1024; StringBuilder sb = new StringBuilder(strlen); for (int i = 0; i < strlen; i++) { sb.Append((i % 10).ToString()); } Assert.AreEqual(true, SmartInt.Parse(sb.ToString()).isBad(), "Parsing \"Extremal, Digits\""); } // Letters { int strlen = 16 * 1024; StringBuilder sb = new StringBuilder(strlen); for (int i = 0; i < strlen; i++) { sb.Append("A" + (i % 10)); } Assert.AreEqual(true, SmartInt.Parse(sb.ToString()).isBad(), "Parsing \"Extremal, Letters\""); } #endregion }