/// <summary> /// Initialize for a specific module /// </summary> internal void Initialize(AsyncLocoBuffer lb, LocoNetAddress address) { this.lb = lb; this.programmer = new Programmer(address); configurationControl.Initialize(lb, programmer); Text += string.Format(" [{0}]", address); }
/// <summary> /// Start reading loco IO's /// </summary> protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (Visible && !started && (appState != null)) { started = true; var list = appState.LocoNet.NewLocoIOs.ToList(); progressBar1.Maximum = list.Count + 1; progressBar1.Minimum = 0; foreach (var io in list) { var index = list.IndexOf(io); var programmer = new Programmer(io.Address); var config = new LocoIOConfig(); appState.LocoBuffer.BeginRequest( x => programmer.Read(x, config), x => { if (!x.HasError) { appState.Configuration.LocoIOs[config.Address] = config; } progressBar1.Value = index + 1; if (index == list.Count-1) { Close(); } }); } } }
/// <summary> /// Initialize for a specific module /// </summary> internal void Initialize(AsyncLocoBuffer lb, LocoNetAddress currentAddress) { this.lb = lb; programmer = new Programmer(new LocoNetAddress(0, 0)); Text = string.Format("Change address of {0}/{1}", currentAddress.Address, currentAddress.SubAddress); upAddress.Value = currentAddress.Address; upSubAddress.Value = currentAddress.SubAddress; }
/// <summary> /// Initialize for a specific module /// </summary> internal void Initialize(AsyncLocoBuffer lb, Programmer programmer) { this.lb = lb; this.programmer = programmer; }
/// <summary> /// Read Single SV /// </summary> private void CmdReadClick(object sender, EventArgs e) { var programmer = new Programmer(new LocoNetAddress((byte)tbDstL.Value, (byte)tbDstH.Value)); var configs = new[] { new SVConfig((int)tbSvAddress.Value) }; lb.BeginRequest(x => programmer.Read(x, configs), x => { if (configs[0].Valid) { MessageBox.Show("Value = " + configs[0].Value); } else { MessageBox.Show("Cannot read SV"); } }); }