本文整理汇总了C#中XFiresecAPI.XDevice类的典型用法代码示例。如果您正苦于以下问题:C# XDevice类的具体用法?C# XDevice怎么用?C# XDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XDevice类属于XFiresecAPI命名空间,在下文中一共展示了XDevice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetGKZones
public static IEnumerable<XZone> GetGKZones(XDevice device)
{
return from zone in DeviceConfiguration.Zones
where zone.GkDatabaseParent == device.GkDatabaseParent
orderby zone.No
select zone;
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:7,代码来源:XManager.PresentationZone.cs
示例2: ValidateIPAddress
static void ValidateIPAddress(XDevice device)
{
if (!XManager.IsValidIpAddress(device))
{
Errors.Add(new DeviceValidationError(device, "Не верно задан IP адрес", ValidationErrorLevel.CannotWrite));
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:Validator.Devices.cs
示例3: XDeviceState
public XDeviceState(XDevice device)
{
Device = device;
if (device.DriverType == XDriverType.System)
IsInitialState = false;
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:XDeviceState.cs
示例4: AddDevice
public void AddDevice(XDevice parentDevice, Device fsDevice)
{
var driver = XManager.DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == fsDevice.DriverUID);
if (driver == null)
{
return;
}
var shleifNo = ((shleifPairNo - 1) * 2) + (fsDevice.IntAddress >> 8);
var xDevice = new XDevice()
{
UID = fsDevice.UID,
DriverUID = driver.UID,
Driver = driver,
ShleifNo = (byte)shleifNo,
IntAddress = (byte)(fsDevice.IntAddress & 0xff),
Description = fsDevice.Description
};
XManager.DeviceConfiguration.Devices.Add(xDevice);
parentDevice.Children.Add(xDevice);
xDevice.Parent = parentDevice;
foreach (var fsChildDevice in fsDevice.Children)
{
AddDevice(xDevice, fsChildDevice);
}
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:27,代码来源:ConfigurationConverter.cs
示例5: DeviceBinaryObject
public DeviceBinaryObject(XDevice device, DatabaseType databaseType)
{
DatabaseType = databaseType;
ObjectType = ObjectType.Device;
Device = device;
Build();
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:7,代码来源:DeviceBinaryObject.cs
示例6: SynchronizeChildern
public static void SynchronizeChildern(XDevice xDevice)
{
for (int i = xDevice.Children.Count(); i > 0; i--)
{
var childDevice = xDevice.Children[i - 1];
if (xDevice.Driver.Children.Contains(childDevice.Driver.DriverType) == false)
{
xDevice.Children.RemoveAt(i - 1);
}
}
foreach (var autoCreateDriverType in xDevice.Driver.AutoCreateChildren)
{
var autoCreateDriver = XManager.DriversConfiguration.Drivers.FirstOrDefault(x => x.DriverType == autoCreateDriverType);
for (byte i = autoCreateDriver.MinAddress; i <= autoCreateDriver.MaxAddress; i++)
{
var newDevice = new XDevice()
{
DriverUID = autoCreateDriver.UID,
Driver = autoCreateDriver,
IntAddress = i
};
if (xDevice.Children.Any(x => x.Driver.DriverType == newDevice.Driver.DriverType && x.Address == newDevice.Address) == false)
{
xDevice.Children.Add(newDevice);
newDevice.Parent = xDevice;
}
}
}
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:31,代码来源:XManager.Device.cs
示例7: CopyDevice
public static XDevice CopyDevice(XDevice device, bool fullCopy)
{
var newDevice = new XDevice()
{
DriverUID = device.DriverUID,
Driver = device.Driver,
IntAddress = device.IntAddress,
Description = device.Description
};
if (fullCopy)
{
newDevice.UID = device.UID;
}
newDevice.Properties = new List<XProperty>();
foreach (var property in device.Properties)
{
newDevice.Properties.Add(new XProperty()
{
Name = property.Name,
Value = property.Value
});
}
newDevice.Children = new List<XDevice>();
foreach (var childDevice in device.Children)
{
var newChildDevice = CopyDevice(childDevice, fullCopy);
newChildDevice.Parent = newDevice;
newDevice.Children.Add(newChildDevice);
}
return newDevice;
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:35,代码来源:XManager.Device.cs
示例8: BaseAUPropertyViewModel
public BaseAUPropertyViewModel(XDriverProperty driverProperty, XDevice device)
{
DriverProperty = driverProperty;
Device = device;
if (!Device.Properties.Any(x => x.Name == driverProperty.Name))
{
Save(driverProperty.Default, false);
}
if (Device.DeviceProperties == null)
{
Device.DeviceProperties = new List<XProperty>();
}
var deviceProperty = Device.DeviceProperties.FirstOrDefault(x => x.Name == driverProperty.Name);
if (deviceProperty != null)
{
DeviceAUParameterValue = deviceProperty.Value.ToString();
//if ((deviceProperty.DriverProperty != null) && (deviceProperty.DriverProperty.DriverPropertyType == XDriverPropertyTypeEnum.EnumType))
//DeviceAUParameterValue = deviceProperty.DriverProperty.Parameters.FirstOrDefault(x => x.Value == deviceProperty.Value).Name;
}
else
DeviceAUParameterValue = "Неизвестно";
UpdateDeviceParameterMissmatchType();
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:27,代码来源:BaseAUPropertyViewModel.cs
示例9: DeviceExecutableCommandViewModel
public DeviceExecutableCommandViewModel(XDevice device, XStateBit stateType)
{
ExecuteControlCommand = new RelayCommand(OnExecuteControl);
Device = device;
StateBit = stateType;
Name = ((XStateBit)stateType).ToDescription();
if (Device.DriverType == XDriverType.Valve)
{
switch (stateType)
{
case XStateBit.TurnOn_InManual:
Name = "Открыть";
break;
case XStateBit.TurnOnNow_InManual:
Name = "Открыть немедленно";
break;
case XStateBit.TurnOff_InManual:
Name = "Закрыть";
break;
case XStateBit.Stop_InManual:
Name = "Остановить";
break;
}
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:25,代码来源:DeviceExecutableCommandViewModel.cs
示例10: GetDescriptorAddresses
bool GetDescriptorAddresses(XDevice device)
{
descriptorAddresses = new List<int>();
var startaddress = 0x078000;
while (true)
{
byte[] startAddressBytes = BitConverter.GetBytes(startaddress);
startaddress += 256;
var data = new List<byte>(startAddressBytes);
var sendResult = SendManager.Send(device, 4, 31, 256, data);
if (sendResult.Bytes.Count != 256)
{
Error = "Не удалось распознать дескриптор";
return false;
}
for (int i = 0; i < 256 / 4; i++)
{
var descriptorAddress = BytesHelper.SubstructInt(sendResult.Bytes, i * 4);
if (descriptorAddress == -1)
{
return true;
}
descriptorAddresses.Add(descriptorAddress);
}
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:27,代码来源:KauDescriptorsReader.cs
示例11: RemoveDevice
public static void RemoveDevice(XDevice device)
{
var parentDevice = device.Parent;
foreach (var zone in device.Zones)
{
zone.Devices.Remove(device);
zone.OnChanged();
}
foreach (var direction in device.Directions)
{
direction.InputDevices.Remove(device);
direction.OutputDevices.Remove(device);
var directionDevice = direction.DirectionDevices.FirstOrDefault(x => x.Device == device);
if (directionDevice != null)
{
direction.DirectionDevices.Remove(directionDevice);
direction.InputDevices.Remove(device);
}
direction.OnChanged();
}
parentDevice.Children.Remove(device);
Devices.Remove(device);
if (parentDevice.DriverType == XDriverType.RSR2_KAU_Shleif)
RebuildRSR2Addresses(parentDevice.Parent);
device.OnChanged();
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:28,代码来源:XManager.Actions.cs
示例12: DeviceDescriptor
public DeviceDescriptor(XDevice device, DatabaseType databaseType)
{
DatabaseType = databaseType;
DescriptorType = DescriptorType.Device;
Device = device;
Build();
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:DeviceDescriptor.cs
示例13: GetTankColor
public static Color GetTankColor(XDevice xdevice)
{
Color color = Colors.Black;
if (xdevice != null)
color = Colors.LightCyan;
return color;
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:Helper.cs
示例14: UpdatedDeviceViewModel
public UpdatedDeviceViewModel(XDevice device)
{
Device = device;
Name = device.ShortName;
Address = device.DottedPresentationAddress;
ImageSource = device.Driver.ImageSource;
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:7,代码来源:UpdatedDeviceViewModel.cs
示例15: PropertiesViewModel
public PropertiesViewModel(XDevice xDevice)
{
XDevice = xDevice;
StringProperties = new List<StringPropertyViewModel>();
ShortProperties = new List<ShortPropertyViewModel>();
BoolProperties = new List<BoolPropertyViewModel>();
EnumProperties = new List<EnumPropertyViewModel>();
if (xDevice != null)
foreach (var driverProperty in xDevice.Driver.Properties)
{
switch (driverProperty.DriverPropertyType)
{
case XDriverPropertyTypeEnum.EnumType:
EnumProperties.Add(new EnumPropertyViewModel(driverProperty, xDevice));
break;
case XDriverPropertyTypeEnum.StringType:
StringProperties.Add(new StringPropertyViewModel(driverProperty, xDevice));
break;
case XDriverPropertyTypeEnum.IntType:
ShortProperties.Add(new ShortPropertyViewModel(driverProperty, xDevice));
break;
case XDriverPropertyTypeEnum.BoolType:
BoolProperties.Add(new BoolPropertyViewModel(driverProperty, xDevice));
break;
}
}
}
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:31,代码来源:PropertiesViewModel.cs
示例16: ObjectsListViewModel
public ObjectsListViewModel (XDevice device, XDeviceConfiguration deviceConfiguration)
{
deviceConfiguration.Update();
Objects = new List<ObjectViewModel>();
foreach (var childDevice in deviceConfiguration.Devices)
{
var objectViewModel = new ObjectViewModel(childDevice);
var parent = childDevice.AllParents.FirstOrDefault(x => x.ShortName == device.ShortName && x.Address == device.Address);
if (parent != null && childDevice.IsRealDevice)
Objects.Add(objectViewModel);
}
if (deviceConfiguration.Zones != null)
foreach (var zone in deviceConfiguration.Zones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
{
var objectViewModel = new ObjectViewModel(zone);
Objects.Add(objectViewModel);
}
if (deviceConfiguration.Directions != null)
foreach (var direction in deviceConfiguration.Directions.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
{
var objectViewModel = new ObjectViewModel(direction) { ObjectType = ObjectType.Direction };
Objects.Add(objectViewModel);
}
if (deviceConfiguration.PumpStations != null)
foreach (var pumpStation in deviceConfiguration.PumpStations.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
{
var objectViewModel = new ObjectViewModel(pumpStation) { ObjectType = ObjectType.PumpStation };
Objects.Add(objectViewModel);
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:31,代码来源:ObjectsListViewModel.cs
示例17: GetDescriptorInfo
bool GetDescriptorInfo(XDevice kauDevice, int descriptorAdderss)
{
var descriptorAdderssesBytes = new List<byte>(BitConverter.GetBytes(descriptorAdderss));
var data = new List<byte>(descriptorAdderssesBytes);
var sendResult = SendManager.Send(kauDevice, 4, 31, 256, data);
var bytes = sendResult.Bytes;
if (bytes.Count != 256)
{
Error = "Длина дескриптора не соответствует нужному значению";
return false;
}
var deviceType = BytesHelper.SubstructShort(bytes, 0);
var address = BytesHelper.SubstructShort(bytes, 2);
int shleifNo = (byte)(address / 256 + 1);
var device = new XDevice();
device.Driver = XManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == deviceType);
if ((1 <= shleifNo && shleifNo <= 8) && (address != 0))
{
device.DriverUID = device.Driver.UID;
var shleif = KauDevice.Children.FirstOrDefault(x => (x.DriverType == XDriverType.KAU_Shleif || x.DriverType == XDriverType.RSR2_KAU_Shleif) && x.IntAddress == shleifNo);
shleif.Children.Add(device);
device.IntAddress = (byte)(address % 256);
return true;
}
device.Driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.KAUIndicator);
device.DriverUID = device.Driver.UID;
device.IntAddress = 1;
KauDevice.Children.Add(device);
return true;
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:30,代码来源:KauDescriptorsReader.cs
示例18: 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);
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:29,代码来源:FiresecToGKConverter.cs
示例19: WriteFileToGK
public void WriteFileToGK(XDevice gkDevice)
{
var bytesList = new List<byte>();
var gkFileInfo = new GKFileInfo();
gkFileInfo.Initialize(XManager.DeviceConfiguration, gkDevice);
bytesList.AddRange(gkFileInfo.InfoBlock);
var sendResult = SendManager.Send(gkDevice, 0, 21, 0);
if (sendResult.HasError)
{ Error = "Невозможно начать процедуру записи "; return; }
bytesList.AddRange(gkFileInfo.FileBytes);
var progressCallback = GKProcessorManager.StartProgress("Запись файла в " + gkDevice.PresentationName, null, bytesList.Count / 256, true, GKProgressClientType.Administrator);
for (var i = 0; i < bytesList.Count; i += 256)
{
if (progressCallback.IsCanceled)
{ Error = "Операция отменена"; return; }
GKProcessorManager.DoProgress("Запись блока данных " + i + 1, progressCallback);
var bytesBlock = BitConverter.GetBytes((uint)(i / 256 + 1)).ToList();
bytesBlock.AddRange(bytesList.GetRange(i, Math.Min(256, bytesList.Count - i)));
sendResult = SendManager.Send(gkDevice, (ushort)bytesBlock.Count(), 22, 0, bytesBlock);
if (sendResult.HasError)
{
Error = "Невозможно записать блок данных " + i;
break;
}
}
var endBlock = BitConverter.GetBytes((uint) (bytesList.Count()/256 + 1)).ToList();
sendResult = SendManager.Send(gkDevice, 0, 22, 0, endBlock);
if (sendResult.HasError)
{ Error = "Невозможно завершить запись файла "; }
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:30,代码来源:GKFileReaderWriter.cs
示例20: GetDeviceInfo
public static string GetDeviceInfo(XDevice device)
{
try
{
var stringBuilder = new StringBuilder();
var result1 = SendManager.Send(device, 0, 1, 1);
if (!result1.HasError)
{
byte softvareVersion = result1.Bytes[0];
if (softvareVersion > 127)
stringBuilder.AppendLine("Режим: Технологический");
else
stringBuilder.AppendLine("Режим: Рабочий");
softvareVersion = (byte)(softvareVersion << 1);
softvareVersion = (byte)(softvareVersion >> 1);
stringBuilder.AppendLine("Версия ПО: " + softvareVersion.ToString());
}
var result2 = SendManager.Send(device, 0, 2, 8);
if (!result2.HasError)
{
var serialNo = (ushort)BytesHelper.SubstructInt(result2.Bytes, 0);
stringBuilder.AppendLine("Серийный номер: " + serialNo.ToString());
var hardvareVervion = (ushort)BytesHelper.SubstructInt(result2.Bytes, 4);
stringBuilder.AppendLine("Аппаратный номер: " + hardvareVervion.ToString());
}
return stringBuilder.ToString();
}
catch (Exception e)
{
Logger.Error(e, "DeviceBytesHelper.ShowInfoCommand");
}
return null;
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:34,代码来源:DeviceBytesHelper.cs
注:本文中的XFiresecAPI.XDevice类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论