ISwitchV2GetSwitch Method

Return the state of switch device id as a boolean

Definition

Namespace: ASCOM.Common.DeviceInterfaces
Assembly: ASCOM.Common (in ASCOM.Common.dll) Version: 2.2.1+77356f79b05b579f6d860a4edd5934fda9fe29e4
C#
bool GetSwitch(
	short id
)

Parameters

id  Int16
The device number (0 to MaxSwitch - 1)

Return Value

Boolean
True or false

Remarks

Must be implemented, must not throw a NotImplementedException.

All devices must implement this. A multi-state device will return true if the device is at the maximum value, false if the value is at the minimum and either true or false as specified by the driver developer for intermediate values.

Some devices do not support reading their state although they do allow state to be set. In these cases, on start-up, the driver can not know the hardware state and it is recommended that the driver either:

  • Sets the device to a known state on connection
  • Throws an InvalidOperationException until the client software has set the device state for the first time

In both cases the driver should save a local copy of the state which it last set and return this through GetSwitch(Int16) and GetSwitchValue(Int16)

Devices are numbered from 0 to MaxSwitch - 1

Exceptions

InvalidOperationExceptionIf there is a temporary condition that prevents the device value being returned.
InvalidValueExceptionIf id is outside the range 0 to MaxSwitch - 1
NotConnectedExceptionWhen Connected is False.
DriverExceptionAn error occurred that is not described by one of the more specific ASCOM exceptions. Include sufficient detail in the message text to enable the issue to be accurately diagnosed by someone other than yourself.

Version Information

.NET Standard

Supported in: 2.0

See Also