public void Start(Properties props)
 {
     myInterval = props.Interval;
       myMagicNumber = props.MagicNumber;
       InitSerialPort(props.ComPort);
       StartTimer();
 }
 private static void TestSend(Properties props)
 {
     foreach (var row in File.ReadAllLines("sample.txt"))
       {
     var bytes = Convert(row, props);
     mySerialPortConnectionService.PutData(bytes, bytes.Length);
       }
 }
 internal NetworkService(IDataConsumer dataConsumer, Properties props)
 {
     myServerPort = props.NetworkPort;
       myDataConsumer = dataConsumer;
       myServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
       myServerSocket.Bind(new IPEndPoint(IPAddress.Any, myServerPort));
       myServerSocket.Listen(1024);
 }
 private static byte[] Convert(string msg, Properties props)
 {
     if (msg.Length == 0) return new[] {props.MagicNumber};
       var strings = msg.Split(' ');
       var bytes = new byte[strings.Length + 1];
       for (var i = 0; i < strings.Length; i++)
       {
     bytes[i] = byte.Parse(strings[i]);
       }
       bytes[strings.Length] = props.MagicNumber;
       return bytes;
 }
        public static void Start()
        {
            var properties = new Properties();
              properties.Load();
              mySerialPortConnectionService = new SerialPortConnectionService();
              mySerialPortConnectionService.Start(properties);
              if (!properties.PlaySample)
              {
            var networkService = new NetworkService(mySerialPortConnectionService, properties);
            networkService.Start();
              }

              TestSend(properties);
              while (Console.ReadLine().Length == 0)
              {
            TestSend(properties);
              }
        }