public PDUPTTable(DevicePDUDirection devicePDUDirection, PanelDatabase panelDatabase) : base(null, devicePDUDirection.PDUGroupDevice.Device.DottedPresentationNameAndAddress) { Device = devicePDUDirection.PDUGroupDevice.Device; BytesDatabase = new BytesDatabase(Device.DottedPresentationNameAndAddress); BytesDatabase.AddByte(Device.AddressOnShleif, "Адрес"); BytesDatabase.AddByte((Device.ShleifNo - 1), "Шлейф"); BytesDatabase.AddByte(Device.Parent.IntAddress, "Адрес прибора"); var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(Device.Driver.DriverType); BytesDatabase.AddByte(deviceCode, "Тип ИУ"); var tableBase = panelDatabase.FlashDatabase.LocalZonesTableGroup.Tables.FirstOrDefault(x => x.UID == Device.Zone.UID); var localZoneNo = (tableBase as ZoneTable).BinaryZone.LocalNo; BytesDatabase.AddShort(localZoneNo, "Номер зоны"); BytesDatabase.AddByte(devicePDUDirection.Device.IntAddress, "Направление"); foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { tableBase = tableGroup.Tables.FirstOrDefault(x => x.UID == Device.UID); if (tableBase != null) { break; } } var offset = tableBase.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset + 3; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 4; i++) { BytesDatabase.AddByte(offsetBytes[i], "Смещение"); } }
void CreateTables() { FirstTable = new BytesDatabase(); for (int i = 0; i < 0x4000; i++) { FirstTable.AddByte(0); } FirstTable.AddShort(1, "Версия БД"); Crc16ByteDescription = FirstTable.AddShort(0, "CRC от ROM части базы", ignoreUnequal: true); var lengtByteDescription = FirstTable.AddInt(0, "Размер БД"); FirstTable.AddShort(PDUItems.Count, "Количество приборов"); var devicesCount = 0; foreach (var pduItem in PDUItems) { pduItem.DevicePDUDirections = pduItem.DevicePDUDirections.OrderBy(x => x.Device.IntAddress).ToList(); devicesCount += pduItem.DevicePDUDirections.Count; } FirstTable.AddShort(devicesCount, "Количество направлений"); BytesDatabase.Add(FirstTable); BytesDatabase.AddByte(1, "Хэш"); for (int i = 0; i < 16; i++) { BytesDatabase.AddByte(0, "Хэш", ignoreUnequal: true); } for (int i = 0; i < 47; i++) { BytesDatabase.AddByte(255, "Доп. информация"); } var emptyBytesDatabase1 = new BytesDatabase("Пусто"); var emptyBytesCount1 = 0x404C - BytesDatabase.ByteDescriptions.Count; for (int i = 0; i < emptyBytesCount1; i++) { emptyBytesDatabase1.AddByte(255, "Пустой байт 1"); } BytesDatabase.Add(emptyBytesDatabase1); foreach (var pduItem in PDUItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == pduItem.ParentPanel.UID); var paneBytesDatabase = new BytesDatabase("Прибор " + pduItem.ParentPanel.DottedPresentationNameAndAddress); paneBytesDatabase.AddByte(pduItem.ParentPanel.IntAddress, "Номер прибора"); for (int i = 0; i < 16; i++) { var value = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions[i + 1].Value; paneBytesDatabase.AddByte(value, "MD5", ignoreUnequal: true); } var offset = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset; var offsetBytes = BitConverter.GetBytes(offset + 1); for (int i = 0; i < 4; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение MD5"); } var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(pduItem.ParentPanel.Driver.DriverType); paneBytesDatabase.AddByte(deviceCode, "Тип прибора"); BytesDatabase.Add(paneBytesDatabase); } var emptyBytesDatabase2 = new BytesDatabase("Пусто"); var emptyBytesCount2 = 0x430C-BytesDatabase.ByteDescriptions.Count; for (int i = 0; i < emptyBytesCount2; i++) { emptyBytesDatabase2.AddByte(255, "Пустой байт 2"); } BytesDatabase.Add(emptyBytesDatabase2); var pduPTTables = new List<PDUPTTable>(); foreach (var pduItem in PDUItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == pduItem.ParentPanel.UID); foreach (var devicePDUDirection in pduItem.DevicePDUDirections) { var pduTable = new PDUPTTable(devicePDUDirection, panelDatabase); pduPTTables.Add(pduTable); devicePDUDirection.ReferenceToByteDescriptions = pduTable.BytesDatabase.ByteDescriptions.FirstOrDefault(); } } foreach (var pduItem in PDUItems) { foreach (var devicePDUDirection in pduItem.DevicePDUDirections) { var mptDevice = devicePDUDirection.PDUGroupDevice.Device; var paneBytesDatabase = new BytesDatabase("Направление " + devicePDUDirection.Device.DottedPresentationNameAndAddress); paneBytesDatabase.AddByte(devicePDUDirection.Device.IntAddress, "Номер направления"); paneBytesDatabase.AddShort(0, "Задержка запуска"); var uiCount = 1 + mptDevice.Children.Count; paneBytesDatabase.AddByte(uiCount, "Количество ИУ"); var offsetByteDescription = paneBytesDatabase.AddInt(0, "Смещение"); offsetByteDescription.AddressReference = devicePDUDirection.ReferenceToByteDescriptions; BytesDatabase.Add(paneBytesDatabase); } } var emptyBytesDatabase3 = new BytesDatabase("Пусто"); var emptyBytesCount3 = 0x4334 - BytesDatabase.ByteDescriptions.Count; for (int i = 0; i < emptyBytesCount3; i++) { emptyBytesDatabase3.AddByte(255, "Пустой байт 3"); } BytesDatabase.Add(emptyBytesDatabase3); //pduPTTables = pduPTTables.OrderBy(x => x.Device.IntAddress * 256 + x.Device.ParentPanel.IntAddress).ToList(); foreach (var pduTable in pduPTTables) { BytesDatabase.Add(pduTable.BytesDatabase); } Tables.Add(FirstTable); BytesDatabase.SetShort(lengtByteDescription, BytesDatabase.ByteDescriptions.Count - 0x404C); }
void CreateTables() { FirstTable = new BytesDatabase(); for (int i = 0; i < 0x4000; i++) { FirstTable.AddByte(0); } FirstTable.AddShort(5, "Версия БД"); Crc16ByteDescription = FirstTable.AddShort(0, "CRC от ROM части базы", ignoreUnequal: true); var lengtByteDescription = FirstTable.AddInt(0, "Размер БД"); FirstTable.AddShort(IndicatorItems.Count, "Число приборов"); BytesDatabase.Add(FirstTable); BytesDatabase.AddByte(1, "Хэш"); for (int i = 0; i < 16; i++) { BytesDatabase.AddByte(0, "Хэш", ignoreUnequal: true); } for (int i = 0; i < 47; i++) { BytesDatabase.AddByte(255, "Доп. информация"); } IndicatorItems = IndicatorItems.OrderBy(x => x.ParentPanel.IntAddress).ToList(); foreach (var indicatorItem in IndicatorItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == indicatorItem.ParentPanel.UID); var paneBytesDatabase = new BytesDatabase("Запись прибора"); paneBytesDatabase.AddByte(indicatorItem.ParentPanel.IntAddress, "Номер прибора"); for (int i = 0; i < 16; i++) { var value = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions[i + 1].Value; paneBytesDatabase.AddByte(value, "MD5", ignoreUnequal:true); } var offset = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset; var offsetBytes = BitConverter.GetBytes(offset + 1); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение MD5"); } paneBytesDatabase.AddShort(indicatorItem.ZoneIndicators.Count, "Количество зон"); indicatorItem.ZonesReference = paneBytesDatabase.AddReference(new ByteDescription(), "Смещение зон"); paneBytesDatabase.AddShort(indicatorItem.Devices.Count, "Количество ИУ"); indicatorItem.DevicesReference = paneBytesDatabase.AddReference(new ByteDescription(), "Смещение ИУ"); paneBytesDatabase.AddShort(indicatorItem.AM1_T_Devices.Count, "Количество ТМ"); indicatorItem.AM1_TReference = paneBytesDatabase.AddReference(new ByteDescription(), "Смещение ТМ"); paneBytesDatabase.AddShort(indicatorItem.PumpStations.Count, "Количество НС"); indicatorItem.PumpStationReference = paneBytesDatabase.AddReference(new ByteDescription(), "Смещение НС"); paneBytesDatabase.AddShort(indicatorItem.Pumps.Count, "Количество Насосов"); indicatorItem.PumpReference = paneBytesDatabase.AddReference(new ByteDescription(), "Смещение Насосов"); BytesDatabase.Add(paneBytesDatabase); } foreach (var indicatorItem in IndicatorItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == indicatorItem.ParentPanel.UID); var firstFlag = true; foreach (var zoneIndicator in indicatorItem.ZoneIndicators) { var paneBytesDatabase = new BytesDatabase("Зона " + zoneIndicator.Zone.PresentationName); var zoneTable = panelDatabase.FlashDatabase.LocalZonesTableGroup.Tables.FirstOrDefault(x => x.UID == zoneIndicator.Zone.UID) as ZoneTable; var offset = zoneTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение"); } paneBytesDatabase.AddShort(zoneTable.BinaryZone.LocalNo, "Локальный номер"); var zoneType = 0; if (zoneIndicator.Zone.ZoneType == ZoneType.Guard) zoneType = 1; paneBytesDatabase.AddByte(zoneType, "ID Зоны"); var deviceNo = (zoneIndicator.IndicatorDevice.Parent.IntAddress - 1) * 50 + zoneIndicator.IndicatorDevice.IntAddress; paneBytesDatabase.AddByte(deviceNo, "Номер светодиода"); BytesDatabase.Add(paneBytesDatabase); if (firstFlag) { indicatorItem.ZonesReference.AddressReference = paneBytesDatabase.ByteDescriptions.FirstOrDefault(); firstFlag = false; } } firstFlag = true; var sortedDevices = indicatorItem.Devices.OrderBy(x => x.Device.IntAddress).ToList(); foreach (var deviceIndicator in sortedDevices) { var paneBytesDatabase = new BytesDatabase("Устройство ИУ " + deviceIndicator.Device.DottedPresentationNameAndAddress); EffectorDeviceTable effectorDeviceTable = null; foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { effectorDeviceTable = tableGroup.Tables.FirstOrDefault(x => x.UID == deviceIndicator.Device.UID) as EffectorDeviceTable; if (effectorDeviceTable != null) { break; } } var offset = effectorDeviceTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset + 3; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение"); } paneBytesDatabase.AddByte(effectorDeviceTable.Device.AddressOnShleif, "Адрес"); paneBytesDatabase.AddByte(effectorDeviceTable.Device.ShleifNo - 1, "Шлейф"); var firstValue = 16 * (int)deviceIndicator.IndicatorDevice.IndicatorLogic.OnColor + (int)deviceIndicator.IndicatorDevice.IndicatorLogic.OffColor; var sectondValue = 16 * (int)deviceIndicator.IndicatorDevice.IndicatorLogic.FailureColor + (int)deviceIndicator.IndicatorDevice.IndicatorLogic.ConnectionColor; paneBytesDatabase.AddByte(firstValue, "Индикация"); paneBytesDatabase.AddByte(sectondValue, "Индикация"); for (int i = 0; i < 14; i++) { paneBytesDatabase.AddByte(0, "Индикация"); } var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(effectorDeviceTable.Device.Driver.DriverType); paneBytesDatabase.AddByte(deviceCode, "Тип ИУ"); var deviceNo = (deviceIndicator.IndicatorDevice.Parent.IntAddress - 1) * 50 + deviceIndicator.IndicatorDevice.IntAddress; paneBytesDatabase.AddByte(deviceNo, "Номер светодиода"); BytesDatabase.Add(paneBytesDatabase); if (firstFlag) { indicatorItem.DevicesReference.AddressReference = paneBytesDatabase.ByteDescriptions.FirstOrDefault(); firstFlag = false; } } firstFlag = true; var sortedAM1_T_Devices = indicatorItem.AM1_T_Devices.OrderBy(x => x.Device.IntAddress).ToList(); foreach (var deviceIndicator in sortedAM1_T_Devices) { var paneBytesDatabase = new BytesDatabase("Устройство АМ1-Т " + deviceIndicator.Device.DottedPresentationNameAndAddress); SensorDeviceTable sensorDeviceTable = null; foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { sensorDeviceTable = tableGroup.Tables.FirstOrDefault(x => x.UID == deviceIndicator.Device.UID) as SensorDeviceTable; if (sensorDeviceTable != null) { break; } } var offset = sensorDeviceTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset + 2; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение"); } paneBytesDatabase.AddByte(sensorDeviceTable.Device.AddressOnShleif, "Адрес"); paneBytesDatabase.AddByte(sensorDeviceTable.Device.ShleifNo - 1, "Шлейф"); var firstValue = 16 * (int)deviceIndicator.IndicatorDevice.IndicatorLogic.OnColor + (int)deviceIndicator.IndicatorDevice.IndicatorLogic.OffColor; var sectondValue = 16 * (int)deviceIndicator.IndicatorDevice.IndicatorLogic.FailureColor + (int)deviceIndicator.IndicatorDevice.IndicatorLogic.ConnectionColor; paneBytesDatabase.AddByte(firstValue, "Индикация"); paneBytesDatabase.AddByte(sectondValue, "Индикация"); for (int i = 0; i < 14; i++) { paneBytesDatabase.AddByte(0, "Индикация"); } var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(sensorDeviceTable.Device.Driver.DriverType); paneBytesDatabase.AddByte(deviceCode, "Тип ИУ"); var deviceNo = (deviceIndicator.IndicatorDevice.Parent.IntAddress - 1) * 50 + deviceIndicator.IndicatorDevice.IntAddress; paneBytesDatabase.AddByte(deviceNo, "Номер светодиода"); BytesDatabase.Add(paneBytesDatabase); if (firstFlag) { indicatorItem.AM1_TReference.AddressReference = paneBytesDatabase.ByteDescriptions.FirstOrDefault(); firstFlag = false; } } firstFlag = true; foreach (var deviceIndicator in indicatorItem.PumpStations) { var paneBytesDatabase = new BytesDatabase("НС " + deviceIndicator.Device.DottedPresentationNameAndAddress); EffectorDeviceTable effectorDeviceTable = null; foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { effectorDeviceTable = tableGroup.Tables.FirstOrDefault(x => x.UID == deviceIndicator.Device.UID) as EffectorDeviceTable; if (effectorDeviceTable != null) { break; } } var offset = effectorDeviceTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset + 3; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение"); } paneBytesDatabase.AddByte(effectorDeviceTable.Device.PumpAddress, "Адрес"); var deviceNo = (deviceIndicator.IndicatorDevice.Parent.IntAddress - 1) * 50 + deviceIndicator.IndicatorDevice.IntAddress; paneBytesDatabase.AddByte(deviceNo, "Номер светодиода"); BytesDatabase.Add(paneBytesDatabase); if (firstFlag) { indicatorItem.PumpStationReference.AddressReference = paneBytesDatabase.ByteDescriptions.FirstOrDefault(); firstFlag = false; } } firstFlag = true; var sortedPumps = indicatorItem.Pumps.OrderBy(x => x.Device.PumpAddress).ToList(); foreach (var deviceIndicator in sortedPumps) { var paneBytesDatabase = new BytesDatabase("Насос " + deviceIndicator.Device.DottedPresentationNameAndAddress); EffectorDeviceTable effectorDeviceTable = null; foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { effectorDeviceTable = tableGroup.Tables.FirstOrDefault(x => x.UID == deviceIndicator.Device.Parent.UID) as EffectorDeviceTable; if (effectorDeviceTable != null) { break; } } var offset = effectorDeviceTable.BytesDatabase.ByteDescriptions.FirstOrDefault(x => x.Description == "Адрес насоса " + deviceIndicator.Device.PumpAddress).Offset + 8; var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 3; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение"); } paneBytesDatabase.AddByte(deviceIndicator.Device.PumpAddress, "Адрес"); paneBytesDatabase.AddByte(0, "Шлейф"); var deviceNo = (deviceIndicator.IndicatorDevice.Parent.IntAddress - 1) * 50 + deviceIndicator.IndicatorDevice.IntAddress; paneBytesDatabase.AddByte(deviceNo, "Номер светодиода"); BytesDatabase.Add(paneBytesDatabase); if (firstFlag) { indicatorItem.PumpReference.AddressReference = paneBytesDatabase.ByteDescriptions.FirstOrDefault(); firstFlag = false; } } } Tables.Add(FirstTable); BytesDatabase.SetShort(lengtByteDescription, BytesDatabase.ByteDescriptions.Count - 0x4000 - 74); }
void CreateTables() { FirstTable = new BytesDatabase(); for (int i = 0; i < 0x4000; i++) { FirstTable.AddByte(0); } FirstTable.AddShort(4, "Версия БД"); Crc16ByteDescription = FirstTable.AddShort(0, "CRC от ROM части базы", ignoreUnequal: true); var lengtByteDescription = FirstTable.AddInt(0, "Размер БД"); FirstTable.AddShort(PDUItems.Count, "Количество приборов"); var devicesCount = 0; foreach (var pduItem in PDUItems) { devicesCount += pduItem.DevicePDUDirections.Count; } FirstTable.AddShort(devicesCount, "Количество ИУ"); FirstTable.AddByte(1, "Хэш"); for (int i = 0; i < 16; i++) { FirstTable.AddByte(0, "Хэш", ignoreUnequal: true); } for (int i = 0; i < 47; i++) { FirstTable.AddByte(255, "Доп. информация"); } BytesDatabase.Add(FirstTable); foreach (var pduItem in PDUItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == pduItem.ParentPanel.UID); var paneBytesDatabase = new BytesDatabase("Прибор " + pduItem.ParentPanel.DottedPresentationNameAndAddress); paneBytesDatabase.AddByte(pduItem.ParentPanel.IntAddress, "Номер прибора"); for (int i = 0; i < 16; i++) { var value = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions[i + 1].Value; paneBytesDatabase.AddByte(value, "MD5", ignoreUnequal: true); } var offset = panelDatabase.FlashDatabase.LastTable.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset; var offsetBytes = BitConverter.GetBytes(offset + 1); for (int i = 0; i < 4; i++) { paneBytesDatabase.AddByte(offsetBytes[i], "Смещение MD5"); } var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(pduItem.ParentPanel.Driver.DriverType); paneBytesDatabase.AddByte(deviceCode, "Тип прибора"); BytesDatabase.Add(paneBytesDatabase); } var emptyBytesDatabase = new BytesDatabase("Пусто"); var emptyBytesCount = 0x42CC-BytesDatabase.ByteDescriptions.Count + 64; for (int i = 0; i < emptyBytesCount; i++) { emptyBytesDatabase.AddByte(255, "Пустой байт"); } //emptyBytesDatabase.AddByte(0, "Пустой байт"); BytesDatabase.Add(emptyBytesDatabase); var pduTables = new List<PDUTable>(); foreach (var pduItem in PDUItems) { var panelDatabase = ConfigurationWriterHelper.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == pduItem.ParentPanel.UID); foreach (var devicePDUDirection in pduItem.DevicePDUDirections) { var pduTable = new PDUTable(devicePDUDirection, panelDatabase); pduTables.Add(pduTable); } } pduTables = pduTables.OrderBy(x => x.Device.IntAddress * 256 + x.Device.ParentPanel.IntAddress).ToList(); foreach (var pduTable in pduTables) { BytesDatabase.Add(pduTable.BytesDatabase); } Tables.Add(FirstTable); BytesDatabase.SetShort(lengtByteDescription, BytesDatabase.ByteDescriptions.Count - 0x4000 - 12 - 64); }
public PDUTable(DevicePDUDirection devicePDUDirection, PanelDatabase panelDatabase) : base(null, devicePDUDirection.PDUGroupDevice.Device.DottedPresentationNameAndAddress) { Device = devicePDUDirection.PDUGroupDevice.Device; BytesDatabase = new BytesDatabase(Device.DottedPresentationNameAndAddress); BytesDatabase.AddByte(Device.AddressOnShleif, "Адрес"); BytesDatabase.AddByte((Device.ShleifNo - 1), "Шлейф"); BytesDatabase.AddByte(Device.Parent.IntAddress, "Адрес прибора"); var deviceCode = FiresecAPI.Models.DriversHelper.GetCodeForDriver(Device.Driver.DriverType); BytesDatabase.AddByte(deviceCode, "Тип ИУ"); var option = 0; if (devicePDUDirection.PDUGroupDevice.IsInversion) option = 128; var anotherCount = devicePDUDirection.Device.Parent.Children.Count(x => x.PDUGroupLogic.Devices.Any(y => y.DeviceUID == Device.UID)); if (anotherCount > 1) option += 64; BytesDatabase.AddByte(option, "Опции"); BytesDatabase.AddByte(devicePDUDirection.Device.IntAddress, "Направление"); BytesDatabase.AddByte(0, "Пустой байт"); TableBase tableBase = null; foreach (var tableGroup in panelDatabase.FlashDatabase.DevicesTableGroups) { tableBase = tableGroup.Tables.FirstOrDefault(x => x.UID == Device.UID); if (tableBase != null) { break; } } var offset = tableBase.BytesDatabase.ByteDescriptions.FirstOrDefault().Offset; if (Device.Driver.IsZoneLogicDevice) { offset += 3; } else { offset += 2; } var offsetBytes = BitConverter.GetBytes(offset); for (int i = 0; i < 4; i++) { BytesDatabase.AddByte(offsetBytes[i], "Смещение"); } BytesDatabase.AddByte(devicePDUDirection.PDUGroupDevice.OnDelay, "Задержка на включение"); BytesDatabase.AddByte(devicePDUDirection.PDUGroupDevice.OffDelay, "Задержка на выключение"); for (int i = 0; i < 9; i++) { BytesDatabase.AddByte(255, "ПДУ привязки"); } BytesDatabase.AddByte(0, "ПДУ привязки"); }
void AddLocalDevicesHeadersPointers() { for (int i = 0; i < 16; i++) { BytesDatabase shleifBytesDatabase = null; if (i < LocalDevicesBytesDatabase.Count) shleifBytesDatabase = LocalDevicesBytesDatabase[i]; var bytesDatabase = new BytesDatabase("Указатель на указатели на локальное устройство шлейфа " + (i + 1).ToString()); bytesDatabase.AddReference(shleifBytesDatabase, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(0, "Длина записи в таблице"); var count = 0; if (shleifBytesDatabase != null) count = shleifBytesDatabase.ByteDescriptions.Count / 3; bytesDatabase.AddByte(count, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); } }
void AddRemoteZonesHeaders() { var tableBase = FlashDatabase.RemoteZonesTableGroup.Tables.FirstOrDefault(); if(tableBase == null) tableBase = FlashDatabase.LocalZonesTableGroup.Tables.FirstOrDefault(); var bytesDatabase = new BytesDatabase("Указатели Внешние зоны"); bytesDatabase.AddReferenceToTable(tableBase, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(FlashDatabase.RemoteZonesTableGroup.Length, "Длина записи в таблице"); bytesDatabase.AddShort(FlashDatabase.RemoteZonesTableGroup.Count, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); }
void AddServiceTablePointers() { var bytesDatabase = new BytesDatabase("Указатель Служебную таблицу"); bytesDatabase.AddReferenceToTable(FlashDatabase.AddressListTable, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(1, "Длина записи в таблице"); bytesDatabase.AddShort(FlashDatabase.AddressListTable.BytesDatabase.ByteDescriptions.Count, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); }
void AddDirectionsHeadersPointers() { var bytesDatabase = new BytesDatabase("Указатель на указатели на Направления"); bytesDatabase.AddReference(DirectionsBytesDatabase, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(0, "Длина записи в таблице"); bytesDatabase.AddShort(DirectionsBytesDatabase.ByteDescriptions.Count / 3, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); }
public RomDatabase(FlashDatabase flashDatabase, int startOffset) { FlashDatabase = flashDatabase; BytesDatabase = new BytesDatabase(); var headBytesDatabase = new BytesDatabase("Заголовок"); if (FlashDatabase.ParentPanel.Driver.DriverType == DriverType.BUNS || FlashDatabase.ParentPanel.Driver.DriverType == DriverType.USB_BUNS) { headBytesDatabase.AddString("BUNS", "Сигнатура базы", 4); } else { headBytesDatabase.AddString("BASE", "Сигнатура базы", 4); } headBytesDatabase.AddShort(5, "Версия базы"); headBytesDatabase.AddReference(FlashDatabase.BytesDatabase.ByteDescriptions.Last(), "Абсолютный указатель на конец базы во внешней энергонезависимой паияти"); var pointerToLast = headBytesDatabase.AddReference((ByteDescription)null, "Абсолютный указатель на конец блока, записываемого в память кристалла"); BytesDatabase.Add(headBytesDatabase); foreach (var tableGroup in FlashDatabase.DevicesTableGroups) { var bytesDatabase = new BytesDatabase(tableGroup.Name); bytesDatabase.AddReferenceToTable(tableGroup.Tables.FirstOrDefault(), tableGroup.Name); bytesDatabase.AddByte(tableGroup.ComputedLength, "Длина записи в таблице"); bytesDatabase.AddShort(tableGroup.Count, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); } var emptyBytesDatabase = new BytesDatabase(); for (int i = 0; i < 1542 - BytesDatabase.ByteDescriptions.Count; i++) { emptyBytesDatabase.AddByte(0); } BytesDatabase.Add(emptyBytesDatabase); CreateLocalZonesHeaders(); CreateRemoteDevicesHeaders(); CreateDirectionsHeaders(); CreateLocalDevicesHeaders(); AddLocalZonesHeaderPointers(); AddRemoteZonesHeaders(); AddRemoteDevicesHeadersPointers(); AddLocalDevicesHeadersPointers(); AddServiceTablePointers(); AddDirectionsHeadersPointers(); BytesDatabase.Add(DirectionsBytesDatabase); BytesDatabase.Add(LocalZonesBytesDatabase); BytesDatabase.Add(RemoteDevicesBytesDatabase); foreach (var localDevicesBytesDatabase in LocalDevicesBytesDatabase) { BytesDatabase.Add(localDevicesBytesDatabase); } pointerToLast.AddressReference = BytesDatabase.ByteDescriptions.LastOrDefault(); BytesDatabase.Order(startOffset); BytesDatabase.ResolveTableReferences(); foreach (var byteDescription in BytesDatabase.ByteDescriptions) { if (byteDescription.TableBaseReference != null) { byteDescription.AddressReference = FlashDatabase.BytesDatabase.ByteDescriptions.FirstOrDefault(x => x.TableHeader != null && x.TableHeader.ReferenceUID == byteDescription.TableBaseReference.ReferenceUID); } } BytesDatabase.ResolveReferences(); var allBytes = BytesDatabase.GetBytes(); var crc16Value = Crc16Helper.ComputeChecksum(allBytes); FlashDatabase.BytesDatabase.SetShort(FlashDatabase.Crc16ByteDescription, crc16Value); }
void AddRemoteDevicesHeadersPointers() { var bytesDatabase = new BytesDatabase("Указатель на указатели на Внешние устройства"); bytesDatabase.AddReference(RemoteDevicesBytesDatabase, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(0, "Длина записи в таблице"); bytesDatabase.AddShort(0, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); }
void AddLocalZonesHeaderPointers() { var bytesDatabase = new BytesDatabase("Указатель на указатели на локальные зоны"); bytesDatabase.AddReference(LocalZonesBytesDatabase, "Абсолютный указатель на таблицу"); bytesDatabase.AddByte(0, "Длина записи в таблице"); bytesDatabase.AddShort(FlashDatabase.LocalZonesTableGroup.Tables.Count, "Текущее число записей в таблице"); BytesDatabase.Add(bytesDatabase); }