2 using System.Collections.Generic;
23 public string ComPort {
get; set; }
25 private SerialPort Port = null;
26 private object PortLocker =
new object();
34 if (ComPort.IsNullOrWhiteSpace())
36 Log.
Warning(
"ComPort is not set for {0} {1}.".Build(this.GetType().Name, Name));
40 if (!SerialPort.GetPortNames().Any(x => x.Equals(ComPort, StringComparison.InvariantCultureIgnoreCase)))
42 Log.
Warning(
"ComPort {2} is defined for {0} {1}, but does not exist.".Build(this.GetType().Name, Name, ComPort));
49 byte[] OldValues = null;
58 for (
int i = 0; i < 7; i++)
60 if (OldValues == null || OldValues[i] != OutputValues[i])
62 Port.Write(
"{0},{1}{2}#".Build(i + 1, (OutputValues[i] == 0 ? 2 : 1), (OutputValues[i] != 0 && i == 0 ?
",0,0," + OutputValues[i].ToString() :
"")));
67 bool ColorChanged =
false;
69 for (
int i = 8; i < 10; i++)
71 if (OldValues == null || OldValues[i] != OutputValues[i])
75 if (OutputValues[i] != 0) IsBlack =
false;
86 Port.Write(
"9,1,{0},{1},{2}#".Build(OutputValues[7], OutputValues[8], OutputValues[9]));
90 OldValues = (byte[])OutputValues.Clone();
94 throw new Exception(
"COM port {2} is not initialized for {0} {1}.".Build(this.GetType().Name, Name, ComPort));
107 DisconnectFromController();
112 Port =
new SerialPort(ComPort, 115200, Parity.None, 8, StopBits.One);
118 string Msg =
"A exception occured while opening comport {2} for {0} {1}.".Build(this.GetType().Name, Name, ComPort);
120 throw new Exception(Msg, E);
static void Warning(string Message)
Writes a warning message to the log.
override bool VerifySettings()
Verifies the settings of the output controller.
A simple logger used to record important events and exceptions.
PinControl is a Arduniobased output controller by http://www.vpforums.org/index.php?showuser=79113 Is has 4 pwm output, 6 digital outputs. DOF supports any number of these controllers. Outputs 1,8,9,10 are pwm outputs. Outputs 2,3,4,5,6,7 are digital outputs.
override void ConnectToController()
This method is called when DOF wants to connect to the controller. Implement your own logic to connec...
This abstract class implement the full base logic for a output controller with a separate thread for ...
override void UpdateOutputs(byte[] OutputValues)
This method is called whenever new data has to be sent to the output controller. Implement the commun...
override void DisconnectFromController()
This method is called when DOF wants to disconnect from the controller. Implement your own logic to d...
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
override int GetNumberOfConfiguredOutputs()
This method must return the number of configured outputs. The method is used internaly to determine t...