public int Write <T>(PointGroup <T> pointGroup) { try { if (_isConnect) { ASCIIEncoding encoding = new ASCIIEncoding(); var sendBytes = creatWriteData(new List <PointGroup <T> > { pointGroup }); var receiveBuffer = new byte[12768]; _log.ByteSteamLog(ActionType.SEND, sendBytes); if (_socket.Send(sendBytes) != -1) { Thread.Sleep(10); int count = _socket.Receive(receiveBuffer); var receivedata = new byte[count]; Array.Copy(receiveBuffer, receivedata, count); _log.ByteSteamLog(ActionType.RECEIVE, receiveBuffer); var receiveStr = encoding.GetString(receivedata); receiveStr.Replace("<", ""); var strArrary = receiveStr.Split('>'); if (strArrary.Length > 2) { if (strArrary[1] == "12") { return(1); } else if (strArrary[1] == "22") { string errorInfo = ""; for (int i = 2; i < strArrary.Length - 1; i++) { errorInfo = string.Concat(errorInfo, "<", strArrary[i], ">"); } Log.ErrorLog(string.Format("Freedom Write {0} ", errorInfo)); return(-1); } else { Log.ErrorLog(string.Format("Freedom Write {0} ", "receive function code error!")); return(-1); } } else { Log.ErrorLog(string.Format("Freedom Write {0} ", "receive data length too less!")); return(-1); } } else { Log.ErrorLog(string.Format("Freedom Write {0} ", "send buffer fail!")); return(-1); } } else { Log.ErrorLog(string.Format("Freedom Write {0} ", "connect is not build!")); return(-1); } } catch (Exception e) { DisConnect(); Log.ErrorLog(string.Format("Freedom Write {0} ", e.Message)); return(-1); } }
public int ReadString(PointGroup <string> pointGroup) { return(read(new List <PointGroup <string> > { pointGroup }, stringDataProcess)); }
public int ReadData <T>(PointGroup <T> pointGroup) { throw new NotImplementedException(); }
public int Readfloat(PointGroup <float> pointGroup) { return(read(new List <PointGroup <float> > { pointGroup }, floatDataProcess)); }
public int ReadUInt(PointGroup <uint> pointGroup) { return(read(new List <PointGroup <uint> > { pointGroup }, uintDataProcess)); }
public int ReadUShort(PointGroup <ushort> pointGroup) { return(read(new List <PointGroup <ushort> > { pointGroup }, ushortDataProcess)); }
public int ReadByte(PointGroup <byte> pointGroup) { return(read(new List <PointGroup <byte> > { pointGroup }, byteDataProcess)); }
public int ReadBool(PointGroup <bool> pointGroup) { return(read(new List <PointGroup <bool> > { pointGroup }, boolDataProcess)); }