private void CommandPaste_Executed(object sender, ExecutedRoutedEventArgs e) { IntbusDevice intbusDevice = TreeView_IntbusDevices.SelectedItem as IntbusDevice; IntbusDevice copiedIntbusDevice = IntbusDeviceCloneBuffer; intbusDevice.AddIntbusDevice(copiedIntbusDevice); }
public IntbusConfigurator() { InitializeComponent(); this.DataContext = this; IntbusDevices = new ObservableCollection <IntbusDevice>(); IntbusDevice = IntbusDevices.FirstOrDefault(); IntbusInterfaces = new ObservableCollection <IntbusInterface> { new UART0(), new FM(), new I2C(), new OWI(), new SPI() }; IntbusInterface = IntbusInterfaces.First(); IntbusDevice A = new IntbusDevice(new OWI(), 1) { Name = "Датчик давления" }; IntbusDevice B = new IntbusDevice(new SPI(), 26) { Name = "БП" }; B.AddIntbusDevice(A); IntbusDevice C = new IntbusDevice(new FM(), 1) { Name = "О-модем" }; IntbusDevice D = new IntbusDevice(new UART0(), 1) { Name = "Клапан" }; C.AddIntbusDevice(B); C.AddIntbusDevice(A); C.AddIntbusDevice(D); IntbusDevices = new ObservableCollection <IntbusDevice> { C }; C.SlaveIntbusDevices.First(x => x.Name == "Датчик давления").ModbusDeviceAddress = 2; C.SlaveIntbusDevices.First(x => x.Name == "Клапан").ModbusDeviceAddress = 1; C.ModbusDeviceAddress = 3; }
public object Clone() { IntbusDevice intbusDevice = new IntbusDevice(this.IntbusInterface, this.address) { Name = this.name, MasterIntbusDevice = this.MasterIntbusDevice, }; foreach (var slaveDevice in this.SlaveIntbusDevices) { intbusDevice.AddIntbusDevice(slaveDevice.Clone() as IntbusDevice); } return(intbusDevice); }
private void CommandNew_Executed(object sender, ExecutedRoutedEventArgs e) { if (TreeView_IntbusDevices.SelectedItem == null) { IntbusDevices.Add(new IntbusDevice(IntbusInterface, IntbusAddress) { Name = IntbusName }); } else { IntbusDevice intbusDevice = TreeView_IntbusDevices.SelectedItem as IntbusDevice; intbusDevice.AddIntbusDevice( new IntbusDevice( IntbusInterface.Clone() as IntbusInterface, IntbusAddress) { Name = IntbusName } ); } }