Simply3DScan
ArduinoConnection.ArduinoConnection Class Reference

Class for detecting an arduino and sending commands to it More...

Public Member Functions

 ArduinoConnection (string portString="")
 Initializes a new instance of the ArduinoConnection class. More...
 
string FindComPort ()
 Finds the COM port used by arduino More...
 
void ActivateLaser (bool on=true)
 Activates the laser. More...
 
void ActivateLight (bool on, int hue)
 Activates the light. More...
 
void RotateTurnTableCw (int steps)
 Rotates the turn table clockwise. More...
 
void RotateTurnTableCcw (int steps)
 Rotates the turn table counter clockwise. More...
 
void RotateLaserCw (int steps)
 Rotates the laser clockwise. More...
 
void RotateLaserCcw (int steps)
 Rotates the laser counter clockwise. More...
 
void EnableMicroStepping ()
 Enables the micro stepping. More...
 
void DisableMicroStepping ()
 Disables the micro stepping. More...
 

Properties

bool PortFound [get]
 Gets a value indicating whether [port found]. More...
 
string PortString [get]
 Gets the port string. More...
 

Detailed Description

Class for detecting an arduino and sending commands to it

Definition at line 12 of file ArduinoConnection.cs.

Constructor & Destructor Documentation

ArduinoConnection.ArduinoConnection.ArduinoConnection ( string  portString = "")

Initializes a new instance of the ArduinoConnection class.

Parameters
portStringThe port string.

Definition at line 34 of file ArduinoConnection.cs.

35  {
36  if (String.IsNullOrEmpty(portString))
37  FindComPort();
38  else
39  {
40  PortString = portString;
41  currentPort = new SerialPort(PortString, Configuration.Configuration.Information.Arduino.BaudRate) { ReadTimeout = 1000 };
42  }
43  }
string PortString
Gets the port string.
Class holding the configuration information
Definition: Information.cs:8
string FindComPort()
Finds the COM port used by arduino
int BaudRate
Gets or sets the baud rate.
Definition: Arduino.cs:23
Arduino Arduino
Gets or sets the arduino.
Definition: Information.cs:45

Member Function Documentation

void ArduinoConnection.ArduinoConnection.ActivateLaser ( bool  on = true)

Activates the laser.

Parameters
onif set to true [on].

Definition at line 78 of file ArduinoConnection.cs.

79  {
80  SendCommand(@on ? ArduinoConfiguration.EnableLaserCommand : ArduinoConfiguration.DisableLaserCommand);
81  }
void ArduinoConnection.ArduinoConnection.ActivateLight ( bool  on,
int  hue 
)

Activates the light.

Parameters
onif set to true [on].
hueThe hue.

Definition at line 87 of file ArduinoConnection.cs.

88  {
89  if(on)
90  SendCommand(ArduinoConfiguration.EnableLightCommand, hue);
91  else
92  SendCommand(ArduinoConfiguration.DisableLightCommand);
93  }
void ArduinoConnection.ArduinoConnection.DisableMicroStepping ( )

Disables the micro stepping.

Definition at line 142 of file ArduinoConnection.cs.

143  {
144  SendCommand(ArduinoConfiguration.DisableMicroSteppingCommand);
145  }
void ArduinoConnection.ArduinoConnection.EnableMicroStepping ( )

Enables the micro stepping.

Definition at line 134 of file ArduinoConnection.cs.

135  {
136  SendCommand(ArduinoConfiguration.EnableMicroSteppingCommand);
137  }
string ArduinoConnection.ArduinoConnection.FindComPort ( )

Finds the COM port used by arduino

  • prerequisit: sketch must run on arduino and arduino must be powered
Returns

Definition at line 50 of file ArduinoConnection.cs.

51  {
52  try
53  {
54  string[] ports = SerialPort.GetPortNames();
55  foreach (string port in ports)
56  {
57  currentPort = new SerialPort(port, Configuration.Configuration.Information.Arduino.BaudRate);
58  if (DetectArduino())
59  {
60 
61  PortFound = true;
62  return PortString = port;
63  }
64  PortFound = false;
65  }
66  }
67  catch (Exception ex)
68  {
69  Singleton<Logger>.Instance.LogException(ex);
70  }
71  return string.Empty;
72  }
string PortString
Gets the port string.
Class holding the configuration information
Definition: Information.cs:8
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
bool PortFound
Gets a value indicating whether [port found].
static T Instance
Gets the instance.
Definition: Singleton.cs:27
int BaudRate
Gets or sets the baud rate.
Definition: Arduino.cs:23
Arduino Arduino
Gets or sets the arduino.
Definition: Information.cs:45
void ArduinoConnection.ArduinoConnection.RotateLaserCcw ( int  steps)

Rotates the laser counter clockwise.

Parameters
stepsThe steps.

Definition at line 126 of file ArduinoConnection.cs.

127  {
128  SendCommand(ArduinoConfiguration.RotateLaserCcwCommand, steps);
129  }
void ArduinoConnection.ArduinoConnection.RotateLaserCw ( int  steps)

Rotates the laser clockwise.

Parameters
stepsThe steps.

Definition at line 117 of file ArduinoConnection.cs.

118  {
119  SendCommand(ArduinoConfiguration.RotateLaserCwCommand, steps);
120  }
void ArduinoConnection.ArduinoConnection.RotateTurnTableCcw ( int  steps)

Rotates the turn table counter clockwise.

Parameters
stepsThe steps.

Definition at line 108 of file ArduinoConnection.cs.

109  {
110  SendCommand(ArduinoConfiguration.RotateTurnTableCcwCommand, steps);
111  }
void ArduinoConnection.ArduinoConnection.RotateTurnTableCw ( int  steps)

Rotates the turn table clockwise.

Parameters
stepsThe steps.

Definition at line 99 of file ArduinoConnection.cs.

100  {
101  SendCommand(ArduinoConfiguration.RotateTurnTableCwCommand, steps);
102  }

Property Documentation

bool ArduinoConnection.ArduinoConnection.PortFound
get

Gets a value indicating whether [port found].

true if [port found]; otherwise, false.

Definition at line 21 of file ArduinoConnection.cs.

string ArduinoConnection.ArduinoConnection.PortString
get

Gets the port string.

The port string.

Definition at line 28 of file ArduinoConnection.cs.


The documentation for this class was generated from the following file: