internal static string MichaelProtocolToString(IMichaelProtocol michaelProtocol) { var sb = new StringBuilder(); sb.Append("S;"); sb.Append(Convert.ToInt32(michaelProtocol.Up)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.Down)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.Left)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.Right)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.iOS)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.Triangle)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.A)); sb.Append(";"); sb.Append(Convert.ToInt32(michaelProtocol.X)); sb.Append(";"); foreach (float values in michaelProtocol.SensorValues) { sb.Append(string.Format("{0:0.00}", values)); sb.Append(";"); } sb.Append(Convert.ToInt32(michaelProtocol.Button1)); sb.Append(";CR"); return(sb.ToString()); }
private void SetSensor(ISensorDTO sensor, IMichaelProtocol protocol) { if (_sensorDTO != null) { protocol.SensorValues = _sensorDTO.SensorValues; } }
private void SetJoystick(IJoystickDTO joystick, IMichaelProtocol protocol) { if (_joystickDTO != null) { protocol.Up = _joystickDTO.Up; protocol.Down = _joystickDTO.Down; protocol.Left = _joystickDTO.Left; protocol.Right = _joystickDTO.Right; protocol.A = _joystickDTO.A; protocol.iOS = _joystickDTO.iOS; protocol.Triangle = _joystickDTO.Triangle; protocol.X = _joystickDTO.X; protocol.Button1 = _joystickDTO.Button1; } }
internal static void Send(IMichaelProtocol michaelProtocol, TcpServerNetwork tcpConnection) { string strSend = ConvertProtocol.MichaelProtocolToString(michaelProtocol); tcpConnection.SendMessage(strSend); }