/// <summary> /// Cause all devices to identify themselves. /// </summary> private void CmdDiscoverClick(object sender, EventArgs e) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Discover }; Execute(cmd); }
/// <summary> /// Search for all LocoIO devices. /// </summary> public void QueryLocoIOs() { var msg = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Read, DestinationLow = 0, // DestinationHigh = 0, SvAddress = 0 }; msg.Execute(lb); }
/// <summary> /// Write a single SV variable at the given index with the given value. /// </summary> internal bool WriteSV(LocoBuffer lb, int index, byte value) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = index, DestinationLow = address.Address, SubAddress = address.SubAddress, Data1 = value, }; var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>( lb, x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); return((result != null) && (result.Data1 == value)); }
/// <summary> /// Write a single SV variable at the given index with the given value. /// </summary> internal bool ChangeAddress(LocoBuffer lb, int address, int subAddress) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = 1, DestinationLow = this.address.Address, SubAddress = this.address.SubAddress, Data1 = (byte)address, }; var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>( lb, x => ((x.SvAddress == 1) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); if (result == null) { throw new TimeoutException("Program index 1 failed"); } cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = 2, DestinationLow = this.address.Address, SubAddress = this.address.SubAddress, Data1 = (byte)subAddress, }; result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>( lb, x => ((x.SvAddress == 2) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); if (result == null) { throw new TimeoutException("Program index 2 failed"); } return(true); }
/// <summary> /// Read a single SV variable at the given index. /// </summary> internal bool TryReadSV(LocoBuffer lb, int index, out byte value) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Read, SvAddress = index, DestinationLow = address.Address, SubAddress = address.SubAddress, }; var result = cmd.ExecuteAndWaitForResponse <PeerXferResponse>( lb, x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Read)), timeout); if (result != null) { value = result.Data1; return(true); } value = 0; return(false); }
/// <summary> /// Write a single SV variable at the given index with the given value. /// </summary> internal bool ChangeAddress(LocoBuffer lb, int address, int subAddress) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = 1, DestinationLow =this.address.Address, SubAddress = this.address.SubAddress, Data1 = (byte)address, }; var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>( lb, x => ((x.SvAddress == 1) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); if (result == null) throw new TimeoutException("Program index 1 failed"); cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = 2, DestinationLow = this.address.Address, SubAddress = this.address.SubAddress, Data1 = (byte)subAddress, }; result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>( lb, x => ((x.SvAddress == 2) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); if (result == null) throw new TimeoutException("Program index 2 failed"); return true; }
public virtual TReturn Visit(PeerXferRequest1 msg, TData data) { return(Visit((PeerXferRequest)msg, data)); }
/// <summary> /// Write a single SV variable at the given index with the given value. /// </summary> internal bool WriteSV(LocoBuffer lb, int index, byte value) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Write, SvAddress = index, DestinationLow = address.Address, SubAddress = address.SubAddress, Data1 = value, }; var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>( lb, x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Write)), timeout); return (result != null) && (result.Data1 == value); }
/// <summary> /// Read a single SV variable at the given index. /// </summary> internal bool TryReadSV(LocoBuffer lb, int index, out byte value) { var cmd = new PeerXferRequest1 { Command = PeerXferRequest.Commands.Read, SvAddress = index, DestinationLow = address.Address, SubAddress = address.SubAddress, }; var result = cmd.ExecuteAndWaitForResponse<PeerXferResponse>( lb, x => (address.Equals(x.Source) && (x.SvAddress == index) && (x.OriginalCommand == PeerXferRequest.Commands.Read)), timeout); if (result != null) { value = result.Data1; return true; } value = 0; return false; }