C# Class CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice

A device abstraction for an RC (remote control) switched power outlets.
Inheritance: DeviceBase, IRCSwitch
Exibir arquivo Open project: cyrusbuilt/MonoPi

Public Methods

Method Description
Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Call Dispose when you are finished using the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice. The Dispose method leaves the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice was occupying.

GetSwitchGroupAddress ( String address ) : BitSet

Convenience method for converting a string like "11011" to a CyrusBuilt.MonoPi.BitSet.

RCSwitchDevice ( IRaspiGpio transmitPin ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice class with the pin to use to transmit codes with.

Send ( char codeWord ) : void

Transmits the specified code word to the device.

Send ( long code, Int32 length ) : void

Transmits the specified code word to the device.

SendTriState ( char codeWord ) : void

Sends a code word.

SwitchOff ( AddressCode address, ChannelCode channel ) : void

Switch a remote switch off (Type B with two rotary/sliding switches).

SwitchOff ( BitSet switchGroupAddress, RCSwitchDevNum device ) : void

Switch a remote switch off (Type A with 10 pole DIP switches).

SwitchOn ( AddressCode address, ChannelCode channel ) : void

Switch a remote switch on (Type B with two rotary/sliding switches).

SwitchOn ( BitSet switchGroupAddress, RCSwitchDevNum device ) : void

Switch a remote switch on (Type A with 10 pole DIP switches).

Private Methods

Method Description
Dec2BinWzeroFill ( long dec, Int32 bitLength ) : char[]

Converts a decimal value into its binary representation.

GetCodeWordA ( BitSet groupAddress, ChannelCode chan, System.Boolean status ) : String

Returns a 13 character array, representing the code word to be sent. A code word consists of 9 address bits, 3 data bits, and on sync bit but in our case, only the first 8 address bits and the last 2 data bits are used. A code bit can have 4 different states: "F" (floating), "1" (high), "0" (low), and "S" (synchronous bit).

+-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+ | 4 bits address (switch group) | 4 bits address (switch number) | 1 bit address (not used, so never mind) | 1 bit address (not used, so never mind) | 2 data bits (on|off) | 1 sync bit | | 1=0FFF 2=F0FF 3=FF0F 4=FFF0 | 1=0FFF 2=F0FF 3=FF0F 4=FFF0 | F | F | on=FF off=F0 | S | +-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+

GetCodeWordB ( AddressCode address, ChannelCode chan, System.Boolean status ) : String

Returns a 13 character array, representing the code word to be sent. A code word consists of 9 address bits, 3 data bits, and on sync bit but in our case, only the first 8 address bits and the last 2 data bits are used. A code bit can have 4 different states: "F" (floating), "1" (high), "0" (low), and "S" (synchronous bit).

+-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+ | 4 bits address (switch group) | 4 bits address (switch number) | 1 bit address (not used, so never mind) | 1 bit address (not used, so never mind) | 2 data bits (on|off) | 1 sync bit | | 1=0FFF 2=F0FF 3=FF0F 4=FFF0 | 1=0FFF 2=F0FF 3=FF0F 4=FFF0 | F | F | on=FF off=F0 | S | +-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+

Send0 ( ) : void

Sends a "0" bit.

_
Waveform Protocol 1: | |___

_
Waveform Protocol 2: | |__

Send1 ( ) : void

Sends a "1" bit.

___
Waveform Protocol 1: | |_

__
Waveform Protocol 2: | |_

SendSync ( ) : void

Sends a "Sync" bit.

_
Waveform Protocol 1: | |_______________________________
_
Waveform Protocol 2: | |__________

SendT0 ( ) : void

Sends a tri-state "0" bit.

_ _
Waveform: | |___| |___

SendT1 ( ) : void

Sends a tri-state "1" bit.

___ ___
Waveform: | |_| |_

SendTF ( ) : void

Sends a tri-state "F" bit.

_ ___
Waveform: | |___| |_

Transmit ( Int32 highPulses, Int32 lowPulses ) : void

Trasmits the specified number of high and low pulses

Method Details

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Call Dispose when you are finished using the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice. The Dispose method leaves the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice was occupying.
public Dispose ( ) : void
return void

GetSwitchGroupAddress() public static method

Convenience method for converting a string like "11011" to a CyrusBuilt.MonoPi.BitSet.
/// cannot be a null or empty string. /// /// must contain exactly 5 bits. ///
public static GetSwitchGroupAddress ( String address ) : BitSet
address String /// The a string containing the address bits in sequence. ///
return BitSet

RCSwitchDevice() public method

Initializes a new instance of the CyrusBuilt.MonoPi.Devices.RCSwitch.RCSwitchDevice class with the pin to use to transmit codes with.
/// cannot be null. /// /// is not an output pin. ///
public RCSwitchDevice ( IRaspiGpio transmitPin ) : System
transmitPin IRaspiGpio /// The native pin to use to transmit codes. ///
return System

Send() public method

Transmits the specified code word to the device.
public Send ( char codeWord ) : void
codeWord char /// The code word to transmit. ///
return void

Send() public method

Transmits the specified code word to the device.
public Send ( long code, Int32 length ) : void
code long /// A long represents the bits of the address. ///
length System.Int32 /// The length of bits (count) to send. ///
return void

SendTriState() public method

Sends a code word.
public SendTriState ( char codeWord ) : void
codeWord char /// The code word to send. ///
return void

SwitchOff() public method

Switch a remote switch off (Type B with two rotary/sliding switches).
public SwitchOff ( AddressCode address, ChannelCode channel ) : void
address AddressCode /// The address of the switch group. ///
channel ChannelCode /// The channel (switch) itself. ///
return void

SwitchOff() public method

Switch a remote switch off (Type A with 10 pole DIP switches).
/// cannot be null. /// /// cannot have more than 5 bits. ///
public SwitchOff ( BitSet switchGroupAddress, RCSwitchDevNum device ) : void
switchGroupAddress BitSet /// Code of the switch group (refers to DIP switches 1 - 5, where /// "1" = on and "0" = off, if all DIP switches are on it's "11111"). ///
device RCSwitchDevNum /// The switch device number. ///
return void

SwitchOn() public method

Switch a remote switch on (Type B with two rotary/sliding switches).
public SwitchOn ( AddressCode address, ChannelCode channel ) : void
address AddressCode /// The address of the switch group. ///
channel ChannelCode /// The channel (switch) itself. ///
return void

SwitchOn() public method

Switch a remote switch on (Type A with 10 pole DIP switches).
/// cannot be null. /// /// cannot have more than 5 bits. ///
public SwitchOn ( BitSet switchGroupAddress, RCSwitchDevNum device ) : void
switchGroupAddress BitSet /// Code of the switch group (refers to DIP switches 1 - 5, where /// "1" = on and "0" = off, if all DIP switches are on it's "11111"). ///
device RCSwitchDevNum /// The switch device number. ///
return void