| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using GSG.NET.Logging;
- using GSG.NET.TCP;
- using GSG.NET.Utils;
- namespace OHVLoggerTest
- {
- public class KV8000
- {
- static Logger logger = Logger.GetLogger();
- TcpConnector h = new TcpConnector();
- const byte CR = 0x0d;
- public bool Connecte()
- {
- h.Connect( new TcpComm
- {
- Active = true,
- Ip = "192.168.0.20",
- PortNo = 8501,
- } ) ;
- return h.Connected;
- }
- /// <summary>
- /// 주행 시작 시 진단 PLC Bit On
- /// </summary>
- /// <returns></returns>
- public bool SetPLCStartDrive()
- {
- try
- {
- if ( !h.Connected )
- {
- h.Connect( new TcpComm
- {
- Active = true,
- Ip = "192.168.0.20",
- PortNo = 8501,
- } );
- }
- if ( !h.Connected )
- return false;
- var mb = new MemoryBuffer();
- mb.AppendAscii( "WR MR100 1" );
- mb.Append( CR );
- this.h.WriteFlush( mb.ToBytes );
- }
- catch ( Exception e )
- {
- h.CloseSocket();
- logger.E( $"[PLC] - Set Value Connection Error {e}" );
- return false;
- }
- return true;
- }
- /// <summary>
- /// 주행 정지 시 진단 PLC Bit Off
- /// </summary>
- /// <returns></returns>
- public bool ResetPLCStartDrive()
- {
- try
- {
- if ( !h.Connected )
- {
- h.Connect( new TcpComm
- {
- Active = true,
- Ip = "192.168.0.20",
- PortNo = 8501,
- } );
- }
- if ( !h.Connected )
- return false;
- var mb = new MemoryBuffer();
- mb.AppendAscii( "WR MR100 0" );
- mb.Append( CR );
- this.h.WriteFlush( mb.ToBytes );
- }
- catch ( Exception e )
- {
- h.CloseSocket();
- logger.E( $"[PLC] - Reset Value Connection Error {e}" );
- return false;
- }
- return true;
- }
- }
- }
|