1
0
mirror of https://bitbucket.org/cjdskunkworks/lynxastrodewcontroller.git synced 2026-05-03 17:28:52 +00:00

Version 1 of the LynxAstro.DewController.Switch driver

This commit is contained in:
2021-02-17 19:48:23 +00:00
parent 7be023be2c
commit 7fe6d52363
65 changed files with 6381 additions and 0 deletions
@@ -0,0 +1,78 @@
// This implements a console application that can be used to test an ASCOM driver
//
// This is used to define code in the template that is specific to one class implementation
// unused code can be deleted and this definition removed.
#define Switch
// remove this to bypass the code that uses the chooser to select the driver
//#define UseChooser
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ASCOM
{
class Program
{
static void Main(string[] args)
{
// Uncomment the code that's required
#if UseChooser
// choose the device
string id = ASCOM.DriverAccess.Switch.Choose("");
if (string.IsNullOrEmpty(id))
return;
// create this device
ASCOM.DriverAccess.Switch device = new ASCOM.DriverAccess.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.LynxAstro.DewController.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);
// TODO add more code to test the driver.
device.Connected = true;
Console.WriteLine("Number of switches: " + device.MaxSwitch);
for (short i = 0; i < device.MaxSwitch; i++)
{
var min = device.MinSwitchValue(i);
var max = device.MaxSwitchValue(i);
var step = device.SwitchStep(i);
var value = device.GetSwitchValue(i);
Console.WriteLine($"switch {i}: {min} - {max} stepsize {step}: {value}");
}
for (short i = 0; i < device.MaxSwitch; i++)
{
device.SetSwitchValue(i, 500);
}
for (short i = 0; i < device.MaxSwitch; i++)
{
var min = device.MinSwitchValue(i);
var max = device.MaxSwitchValue(i);
var step = device.SwitchStep(i);
var value = device.GetSwitchValue(i);
Console.WriteLine($"switch {i}: {min} - {max} stepsize {step}: {value}");
}
device.Connected = false;
Console.WriteLine("Press Enter to finish");
Console.ReadLine();
}
}
}