本文整理汇总了C#中FiresecAPI.Models.Device类的典型用法代码示例。如果您正苦于以下问题:C# Device类的具体用法?C# Device怎么用?C# Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Device类属于FiresecAPI.Models命名空间,在下文中一共展示了Device类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDevice
public void AddDevice(Device fsDevice, XDevice kauDevice, byte shleifNo)
{
var driver = XManager.Drivers.FirstOrDefault(x => x.UID == fsDevice.DriverUID);
if (driver == null)
{
return;
}
var device = new XDevice()
{
UID = fsDevice.UID,
DriverUID = driver.UID,
Driver = driver,
IntAddress = (byte)(fsDevice.IntAddress & 0xff),
Description = fsDevice.Description
};
XManager.DeviceConfiguration.Devices.Add(device);
var shleifDevice = kauDevice.Children.FirstOrDefault(x => x.ShleifNo == shleifNo);
if (shleifDevice != null)
{
shleifDevice.Children.Add(device);
device.Parent = shleifDevice;
}
foreach (var fsChildDevice in fsDevice.Children)
{
AddDevice(fsChildDevice, device, shleifNo);
}
}
示例2: Run
public static void Run(Device device, bool isUsb)
{
_device = device;
_isUsb = isUsb;
ServiceFactory.ProgressService.Run(OnPropgress, OnCompleted, _device.PresentationAddressAndName + ". Чтение журнала");
}
示例3: SynchronizeChildern
public void SynchronizeChildern(Device device)
{
for (int i = device.Children.Count(); i > 0; i--)
{
var childDevice = device.Children[i - 1];
if (device.Driver.AvaliableChildren.Contains(childDevice.Driver.UID) == false)
{
device.Children.RemoveAt(i - 1);
}
}
foreach (var autoCreateChildUID in device.Driver.AutoCreateChildren)
{
var autoCreateDriver = DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == autoCreateChildUID);
for (int i = autoCreateDriver.MinAutoCreateAddress; i <= autoCreateDriver.MaxAutoCreateAddress; i++)
{
var newDevice = new Device()
{
DriverUID = autoCreateDriver.UID,
Driver = autoCreateDriver,
IntAddress = i
};
if (device.Children.Any(x => x.Driver.DriverType == newDevice.Driver.DriverType && x.IntAddress == newDevice.IntAddress) == false)
{
device.Children.Add(newDevice);
newDevice.Parent = device;
}
}
}
device.SynchronizeChildern();
}
示例4: DeviceDetailsViewModel
public DeviceDetailsViewModel(Device device)
{
ExecuteCommand = new RelayCommand(OnExecute);
DeviceCommands = new List<DeviceCommandViewModel>();
Device = device;
DeviceState = Device.DeviceState;
DeviceState.StateChanged += new Action(OnStateChanged);
DeviceState.ParametersChanged += new Action(OnParametersChanged);
OnStateChanged();
Title = Device.DottedPresentationAddressAndName;
TopMost = true;
var tableNo = MetadataHelper.GetDeviceTableNo(device);
var metadataDeviceCommands = MetadataHelper.Metadata.devicePropInfos.Where(x => x.tableType == tableNo);
foreach (var metadataDeviceCommand in metadataDeviceCommands)
{
var deviceCommandViewModel = new DeviceCommandViewModel()
{
Name = metadataDeviceCommand.name,
Caption = metadataDeviceCommand.caption,
};
DeviceCommands.Add(deviceCommandViewModel);
}
SelectedDeviceCommand = DeviceCommands.FirstOrDefault();
}
示例5: Run
public static void Run(Device device, bool isUsb)
{
_device = device;
_isUsb = isUsb;
ServiceFactory.ProgressService.Run(OnPropgress, OnCompleted, device.PresentationAddressAndName + ". Установка времени");
}
示例6: GetLocalForZone
public static List<DevicesOnShleif> GetLocalForZone(Device parentPanel, Zone zone)
{
var devicesOnShleifs = new List<DevicesOnShleif>();
for (int i = 1; i <= parentPanel.Driver.ShleifCount; i++)
{
var devicesOnShleif = new DevicesOnShleif()
{
ShleifNo = i
};
devicesOnShleifs.Add(devicesOnShleif);
}
var effectorDevices = GetDevicesInLogic(zone);
foreach (var device in effectorDevices.OrderBy(x => x.IntAddress))
{
if (device.ParentPanel.UID == parentPanel.UID)
{
var shleifNo = device.ShleifNo;
if (device.Driver.DriverType == DriverType.PumpStation)
shleifNo = 1;
var devicesOnShleif = devicesOnShleifs.FirstOrDefault(x => x.ShleifNo == shleifNo);
if (devicesOnShleif != null)
{
devicesOnShleif.Devices.Add(device);
}
}
}
return devicesOnShleifs;
}
示例7: MPTTimerViewModel
public MPTTimerViewModel(Device device)
{
Title = "Включение МПТ. Обратный отсчет" + device.DottedAddress;
TopMost = true;
Device = device;
_guid = device.UID;
}
示例8: IndicatorDeviceSelectionViewModel
public IndicatorDeviceSelectionViewModel(Device indicatorDevice, Device device)
{
Title = "Выбор устройства";
IndicatorDevice = indicatorDevice;
InitializeDevices();
SelectedDevice = device;
}
示例9: ClauseViewModel
public ClauseViewModel(ZoneLogicViewModel zoneLogicViewModel, Device device, Clause clause)
{
ShowZonesCommand = new RelayCommand(OnShowZones);
SelectDeviceCommand = new RelayCommand(OnSelectDevice);
_zoneLogicViewModel = zoneLogicViewModel;
Device = device;
Zones = new List<Guid>(
from zoneUID in clause.ZoneUIDs
select zoneUID);
Zones = clause.ZoneUIDs.ToList();
_selectedState = clause.State;
SelectedOperation = clause.Operation;
if (clause.DeviceUIDs == null)
{
clause.DeviceUIDs = new List<Guid>();
}
SelectedDevices = new List<Device>();
foreach (var deviceUID in clause.DeviceUIDs)
{
var deviceInClause = FiresecManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
if (deviceInClause != null)
{
SelectedDevices.Add(deviceInClause);
}
}
SelectedMROMessageNo = clause.ZoneLogicMROMessageNo;
SelectedMROMessageType = clause.ZoneLogicMROMessageType;
}
示例10: SetDevice
public static void SetDevice(ElementDevice element, Device device)
{
ResetDevice(element);
element.DeviceUID = device == null ? Guid.Empty : device.UID;
if (device != null)
device.PlanElementUIDs.Add(element.UID);
}
示例11: PDUPTTable
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], "Смещение");
}
}
示例12: UpdateRealChildrenStateOnPanelState
void UpdateRealChildrenStateOnPanelState(Device panelDevice, BitArray bitArray)
{
foreach (var device in panelDevice.GetRealChildren())
{
foreach (var metadataDeviceState in MetadataHelper.GetMetadataDeviceStates(device, true))
{
if (metadataDeviceState.leave != null)
{
foreach (var leaveDeviceState in metadataDeviceState.leave)
{
if (leaveDeviceState.panelState != null)
{
var pabelBitNo = Int32.Parse(leaveDeviceState.panelState);
var hasBit = bitArray[pabelBitNo];
if (!hasBit)
{
if (device.DeviceState.States.RemoveAll(x => x.DriverState.Code == metadataDeviceState.ID) > 0)
{
ForseUpdateDeviceStates(device);
}
}
}
}
}
}
}
}
示例13: Write
public static bool Write(Device device)
{
CallbackManager.AddProgress(new FS2ProgressInfo("Формирование базы данных устройств"));
var systemDatabaseCreator = new SystemDatabaseCreator();
systemDatabaseCreator.Create(0x3000);
Device parentPanel;
if ((device.Driver.DriverType == DriverType.IndicationBlock) || (device.Driver.DriverType == DriverType.PDU) || (device.Driver.DriverType == DriverType.PDU_PT))
{
var nonPanelDatabase = systemDatabaseCreator.NonPanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == device.UID);
if (nonPanelDatabase == null)
throw new FS2Exception("Не найдена сформированная для устройства база данных");
parentPanel = nonPanelDatabase.ParentPanel;
var bytes = nonPanelDatabase.BytesDatabase.GetBytes();
CallbackManager.AddProgress(new FS2ProgressInfo("Запись базы данных в прибор"));
return SetConfigurationOperationHelper.WriteNonPanelDeviceConfiguration(parentPanel, bytes);
}
var panelDatabase = systemDatabaseCreator.PanelDatabases.FirstOrDefault(x => x.ParentPanel.UID == device.UID);
if (panelDatabase == null)
throw new FS2Exception("Не найдена сформированная для устройства база данных");
parentPanel = panelDatabase.ParentPanel;
var bytes1 = panelDatabase.RomDatabase.BytesDatabase.GetBytes();
var bytes2 = panelDatabase.FlashDatabase.BytesDatabase.GetBytes();
CallbackManager.AddProgress(new FS2ProgressInfo("Запись базы данных в прибор"));
return SetConfigurationOperationHelper.WriteDeviceConfiguration(parentPanel, bytes2, bytes1);
}
示例14: PropertiesViewModel
public PropertiesViewModel(Device device)
{
Device = device;
StringProperties = new List<StringPropertyViewModel>();
BoolProperties = new List<BoolPropertyViewModel>();
EnumProperties = new List<EnumPropertyViewModel>();
foreach (var driverProperty in device.Driver.Properties)
{
if (driverProperty.IsHidden)
continue;
switch (driverProperty.DriverPropertyType)
{
case DriverPropertyTypeEnum.EnumType:
EnumProperties.Add(new EnumPropertyViewModel(driverProperty, device));
break;
case DriverPropertyTypeEnum.StringType:
case DriverPropertyTypeEnum.IntType:
case DriverPropertyTypeEnum.ByteType:
StringProperties.Add(new StringPropertyViewModel(driverProperty, device));
break;
case DriverPropertyTypeEnum.BoolType:
BoolProperties.Add(new BoolPropertyViewModel(driverProperty, device));
break;
}
}
}
示例15: AddDevice
public Device AddDevice(Device parentDevice, Driver driver, int intAddress)
{
var device = new Device()
{
DriverUID = driver.UID,
Driver = driver,
IntAddress = intAddress,
Parent = parentDevice
};
if (parentDevice.Driver.DriverType == DriverType.MPT)
{
device.ZoneUID = parentDevice.ZoneUID;
}
if (driver.DriverType == DriverType.Valve)
{
device.Properties.Add(new Property() { Name = "Action", Value = "1" });
}
parentDevice.Children.Add(device);
AddAutoCreateChildren(device);
AddAutoChildren(device);
parentDevice.OnChanged();
DeviceConfiguration.Update();
return device;
}