private bool actuatorCommander(int actuator, int index1, int index2, ActuatorCommand cmd) { try { switch (cmd) { case ActuatorCommand.OPEN: actuatorCommand[index1] = 1; actuatorCommand[index2] = 0; break; case ActuatorCommand.CLOSE: actuatorCommand[index1] = 0; actuatorCommand[index2] = 1; break; case ActuatorCommand.STOP: actuatorCommand[index1] = 0; actuatorCommand[index2] = 0; break; } stream.Write(actuatorCommand); return(true); } catch (Exception ex) { switch (cmd) { case ActuatorCommand.OPEN: Console.WriteLine("Error when opening ACTUATOR #" + actuator.ToString() + ": " + ex.Message); break; case ActuatorCommand.CLOSE: Console.WriteLine("Error when closing ACTUATOR #" + actuator.ToString() + ": " + ex.Message); break; case ActuatorCommand.STOP: Console.WriteLine("Error when stopping ACTUATOR #" + actuator.ToString() + ": " + ex.Message); break; } return(false); } }
public void SendActuatorCommand(ActuatorCommand command) { string commandTxt = string.Format("ACTUATOR_COMMAND {0}", Convert.ToInt32(command)); CommunicationNetwork.Instance.Send(commandTxt); }