Пример #1
0
		public ZoneTable(FlashDatabase flashDatabase, BinaryZone binaryZone)
			: base(flashDatabase, "Зона " + binaryZone.Zone.PresentationName)
		{
			binaryZone.TableBase = this;
			BinaryZone = binaryZone;
			Zone = binaryZone.Zone;
		}
Пример #2
0
		public EffectorDeviceTable(FlashDatabase panelDatabase, BinaryDevice binaryDevice, bool isRemote)
			: base(panelDatabase, isRemote ? "Внешнее устройство " : "" + binaryDevice.Device.DottedPresentationAddressAndName)
		{
			binaryDevice.TableBase = this;
			BinaryDevice = binaryDevice;
			Device = binaryDevice.Device;
			IsRemote = isRemote;
		}
Пример #3
0
		public RemoteZoneTable(FlashDatabase panelDatabase, BinaryZone binaryZone)
			: base(panelDatabase, "Внешеяя зона " + binaryZone.Zone.PresentationName)
		{
			binaryZone.IsRemote = true;
			BinaryZone = binaryZone;
			binaryZone.TableBase = this;
			Zone = binaryZone.Zone;
		}
Пример #4
0
		public TableBase(FlashDatabase panelDatabase, string name = null)
		{
			PanelDatabase = panelDatabase;
			BytesDatabase = new BytesDatabase(name);
		}
Пример #5
0
		public DirectionTable(FlashDatabase flashDatabase, Direction direction)
			: base(flashDatabase, direction.Name)
		{
			Direction = direction;
		}
Пример #6
0
		public SensorDeviceTable(FlashDatabase flashDatabase, Device device)
			: base(flashDatabase, device.PresentationAddressAndName)
		{
			Device = device;
		}
Пример #7
0
		public PanelDatabase(Device parentDevice, int offset)
		{
			ParentPanel = parentDevice;
			FlashDatabase = new FlashDatabase(parentDevice);
			RomDatabase = new RomDatabase(FlashDatabase, offset);
		}
Пример #8
0
		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);
		}