static void Main(string[] args) { // Uncomment the code that's required #if UseChooser // choose the device string id = Switch.Choose(""); if (string.IsNullOrEmpty(id)) { return; } // create this device Switch device = new Switch(id); #else // this can be replaced by this code, it avoids the chooser and creates the driver class directly. ASCOM.DriverAccess.Switch device = new ASCOM.DriverAccess.Switch("ASCOM.Simulator.Switch"); #endif // now run some tests, adding code to your driver so that the tests will pass. // these first tests are common to all drivers. Console.WriteLine("name " + device.Name); Console.WriteLine("description " + device.Description); Console.WriteLine("DriverInfo " + device.DriverInfo); Console.WriteLine("driverVersion " + device.DriverVersion); device.SetupDialog(); // TODO add more code to test the driver. device.Connected = true; Console.WriteLine("Number " + device.MaxSwitch); for (short i = 0; i < device.MaxSwitch; i++) { Console.Write("Id {0}, Name {1}, Min {2}, max {3}, step {4}", i, device.GetSwitchName(i), device.MinSwitchValue(i), device.MaxSwitchValue(i), device.SwitchStep(i)); try { if (isBoolean(device, i)) { Console.Write(", Value {0}", device.GetSwitch(i)); } else { Console.Write(", Value {0}", device.GetSwitchValue(i)); } } catch (ASCOM.MethodNotImplementedException) { Console.Write(", Value unknown"); } Console.WriteLine(", CanWrite {0}", device.CanWrite(i)); } device.Connected = false; Console.WriteLine("Press Enter to finish"); Console.ReadLine(); }
private void buttonSetup_Click(object sender, EventArgs e) { try { if (_switcheReady) { _switch.SetupDialog(); } else { _switch = new Switch("ASCOM.StroblCap.Switch"); _switch.SetupDialog(); _switcheReady = true; } } catch (Exception ex) { } }
private void buttonConnect_Click(object sender, EventArgs e) { if (_switcheReady) { if (_switch.Connected) { _switch.Connected = false; _switch.Dispose(); _switcheReady = false; this.buttonConnect.Image = global::EnvironmentPlot.Properties.Resources.Off; } else { _switch.Connected = true; if (_switch.Connected) { this.buttonConnect.Image = global::EnvironmentPlot.Properties.Resources.On; } else { this.buttonConnect.Image = global::EnvironmentPlot.Properties.Resources.Off; } } } else { _switch = new Switch("ASCOM.StroblCap.Switch"); _switcheReady = true; _switch.Connected = true; if (_switch.Connected) { this.buttonConnect.Image = global::EnvironmentPlot.Properties.Resources.On; } else { this.buttonConnect.Image = global::EnvironmentPlot.Properties.Resources.Off; } } ReadSwitched(); }
private void button12_Click(object sender, EventArgs e) { if (SwitchIsConnected) { FlatFlap.Connected = false; Log(devId4 + " disconnected"); button12.BackColor = System.Drawing.Color.WhiteSmoke; return; } ASCOM.Utilities.Chooser chooser = new ASCOM.Utilities.Chooser(); chooser.DeviceType = "Switch"; devId4 = chooser.Choose(); if (!string.IsNullOrEmpty(devId4)) { FlatFlap = new ASCOM.DriverAccess.Switch(devId4); FlatFlap.Connected = true; Thread.Sleep(200); FlatFlap.SetSwitch(0, false); } else { return; } if (SwitchIsConnected) button12.BackColor = System.Drawing.Color.Lime; Log("connected to " + devId4); FileLog2("connected to " + devId4); }