public void TurnRfidOff() { this.rfidOn = false; TcpPacket tcp = new TcpPacket(IP, 0x03, 0x0A, 0, null, 100); connection.Send(tcp.getBuffer()); }
public void setDeviceLight(int color) { MemoryStream light_stream = new MemoryStream(); light_stream.Write(BitConverter.GetBytes(color), 0, 1); TcpPacket tcp = new TcpPacket(IP, 0x02, 0x0F, light_stream.ToArray().Length, light_stream.ToArray(), readDelay); connection.Send(tcp.getBuffer()); }
public void TurnRfidOn() { if (primeOn == false) { this.rfidOn = true; TcpPacket tcp = new TcpPacket(IP, 0x03, 0x09, 0, null, 100); connection.Send(tcp.getBuffer()); } else { Debug.WriteLine("Info", "RFID Scanning Not Available During Prime"); } }
public void setDateTime() { MemoryStream time_stream = new MemoryStream(); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Hour), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Minute), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Second), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Day), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Month), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Year % 100), 0, 1); TcpPacket tcp = new TcpPacket(IP, 0x02, 0x08, time_stream.ToArray().Length, time_stream.ToArray(), 100); connection.Send(tcp.getBuffer()); }
public void Prime() { if (rfidOn == true) { Debug.WriteLine("Prime Not Available During RFID Scanning"); } else { primeOn = !primeOn; if (primeOn) { setDeviceLight(LED_PURPLE_BLINK); } else { setDeviceLight(LED_PURPLE_STOP); } TcpPacket tcp = new TcpPacket(IP, 0x04, 0x0E, 0, null, 100); connection.Send(tcp.getBuffer()); } }
private void SetupDevice() { Debug.WriteLine("Local(" + IP + "): " + Convert.ToString(state)); switch (state) { case DevStates.STATE_SET_ID: { try { MemoryStream id_stream = new MemoryStream(); id_stream.Write(BitConverter.GetBytes(ID), 0, 1); TcpPacket tcp = new TcpPacket(IP, 0x02, 0x0B, id_stream.ToArray().Length, id_stream.ToArray(), readDelay); connection.Send(tcp.getBuffer()); } catch (Exception e) { Debug.WriteLine("ID conf failed" + e.GetBaseException()); state = DevStates.STATE_DONE; } } break; case DevStates.STATE_SET_TIME: { try { MemoryStream time_stream = new MemoryStream(); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Hour), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Minute), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Second), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Day), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Month), 0, 1); time_stream.Write(BitConverter.GetBytes(DateTime.Now.Year % 100), 0, 1); TcpPacket tcp = new TcpPacket(IP, 0x02, 0x08, time_stream.ToArray().Length, time_stream.ToArray(), readDelay); connection.Send(tcp.getBuffer()); } catch (Exception e) { Debug.WriteLine("Time conf failed: " + e.GetBaseException()); } } break; case DevStates.STATE_GET_SYS_INFO: { try { int majorVersion = 1; int minorVersion = 16; MemoryStream version_stream = new MemoryStream(); version_stream.Write(BitConverter.GetBytes(majorVersion), 0, 1); version_stream.Write(BitConverter.GetBytes(minorVersion), 0, 1); TcpPacket tcp = new TcpPacket(IP, 0x02, 0x09, version_stream.ToArray().Length, version_stream.ToArray(), readDelay); connection.Send(tcp.getBuffer()); byte[] request = new byte[255]; connection.Receive(request); Debug.WriteLine("--------New Msg-------------"); Debug.WriteLine(BitConverter.ToString(request)); processPacket(request, request.Length); } catch (Exception e) { Debug.WriteLine("Sys conf failed: " + e.GetBaseException()); } } break; case DevStates.STATE_GET_MEM_INFO: { try { TcpPacket tcp = new TcpPacket(IP, 0x02, 0x0A, 0, null, readDelay); connection.Send(tcp.getBuffer()); byte[] request = new byte[255]; connection.Receive(request); Debug.WriteLine("--------New Msg-------------"); Debug.WriteLine(BitConverter.ToString(request)); processPacket(request, request.Length); } catch (Exception e) { Debug.WriteLine("Sys conf failed: " + e.GetBaseException()); } } break; case DevStates.STATE_GET_ADAP_SETT: { try { TcpPacket tcp = new TcpPacket(IP, 0x04, 0x0D, 0, null, readDelay); connection.Send(tcp.getBuffer()); byte[] request = new byte[255]; connection.Receive(request); Debug.WriteLine("--------New Msg-------------"); Debug.WriteLine(BitConverter.ToString(request)); processPacket(request, request.Length); } catch (Exception e) { Debug.WriteLine("Adap get failed: " + e.GetBaseException()); } } break; case DevStates.STATE_SET_FARM_INFO: break; case DevStates.STATE_DONE: { Debug.WriteLine("Setup Device Finished"); readMsg(); } break; } if (state < DevStates.STATE_DONE) { Task.Delay(500).Wait(); state++; SetupDevice(); } else { state = DevStates.STATE_SET_ID; } }