private static void Log1Bin(TComVar cv, byte b) { if (((cv.FilePause & /*ttftypes.OpLog*/ 1) != 0) || cv.ProtoFlag) { return; } if (cv.BinSkip > 0) { cv.BinSkip--; return; } cv.BinBuf[cv.BinPtr] = b; cv.BinPtr++; if (cv.BinPtr >= tttypes.InBuffSize) { cv.BinPtr = cv.BinPtr - tttypes.InBuffSize; } if (cv.BCount >= tttypes.InBuffSize) { cv.BCount = tttypes.InBuffSize; cv.BStart = cv.BinPtr; } else { cv.BCount++; } }
private static int CommRawOut(TComVar cv, char[] B, int C) { int a; if (!cv.Ready) { return(C); } if (C > tttypes.OutBuffSize - cv.OutBuffCount) { a = tttypes.OutBuffSize - cv.OutBuffCount; } else { a = C; } if (cv.OutPtr > 0) { System.Buffer.BlockCopy(cv.OutBuff, cv.OutPtr, cv.OutBuff, 0, cv.OutBuffCount); cv.OutPtr = 0; } System.Buffer.BlockCopy(B, 0, cv.OutBuff, cv.OutBuffCount, a); cv.OutBuffCount = cv.OutBuffCount + a; return(a); }
public static int CommBinaryOut(TComVar cv, string B, int C) { int a, i, Len; char[] d = new char[3]; if (!cv.Ready) { return(C); } i = 0; a = 1; while ((a > 0) && (i < C)) { Len = 0; d[Len] = B[i]; Len++; if (cv.TelFlag && (B[i] == '\x0d') && !cv.TelBinSend) { d[Len++] = '\x00'; } else if (cv.TelFlag && (B[i] == '\xff')) { d[Len++] = '\xff'; } if (tttypes.OutBuffSize - cv.OutBuffCount - Len >= 0) { CommRawOut(cv, d, Len); a = 1; } else { a = 0; } i += a; } return(i); }
public static void CommInsert1Byte(TComVar cv, byte b) { if (!cv.Ready) { return; } if (cv.InPtr == 0) { System.Buffer.BlockCopy(cv.InBuff, 0, cv.InBuff, 1, cv.InBuffCount); } else { cv.InPtr--; } cv.InBuff[cv.InPtr] = b; cv.InBuffCount++; if (cv.HBinBuf != IntPtr.Zero) { cv.BinSkip++; } }
internal static void CommInit(TComVar cv) { cv.Open = false; cv.Ready = false; // log-buffer variables cv.HLogBuf = IntPtr.Zero; cv.HBinBuf = IntPtr.Zero; cv.LogBuf = null; cv.BinBuf = null; cv.LogPtr = 0; cv.LStart = 0; cv.LCount = 0; cv.BinPtr = 0; cv.BStart = 0; cv.BCount = 0; cv.DStart = 0; cv.DCount = 0; cv.BinSkip = 0; cv.FilePause = 0; cv.ProtoFlag = false; /* message flag */ cv.NoMsg = 0; }
private static int CommReadRawByte(TComVar cv, ref byte b) { if (!cv.Ready) { return(0); } if (cv.InBuffCount > 0) { b = cv.InBuff[cv.InPtr]; cv.InPtr++; cv.InBuffCount--; if (cv.InBuffCount == 0) { cv.InPtr = 0; } return(1); } else { cv.InPtr = 0; return(0); } }
public static void NotifyInfoMessage(TComVar cv, string message, string title) { NotifyMessage(cv, message, title, 1); }
public static void NotifyMessage(TComVar cv, string message, string title, int flag) { throw new NotImplementedException(); }
internal static void CommTextEcho(TComVar tComVar, byte[] Code, int CodeLength) { byte[] data = new byte[CodeLength]; System.Buffer.BlockCopy(Code, 0, data, 0, data.Length); DoDataReceive(data); }
public static int CommRead1Byte(TComVar cv, out byte b) { int c; b = 0; if (!cv.Ready) { return(0); } if ((cv.HLogBuf != IntPtr.Zero) && ((cv.LCount >= tttypes.InBuffSize - 10) || (cv.DCount >= tttypes.InBuffSize - 10))) { // 自分のバッファに余裕がない場合は、CPUスケジューリングを他に回し、 // CPUがストールするの防ぐ。 // (2006.10.13 yutaka) Thread.Sleep(1); return(0); } if ((cv.HBinBuf != IntPtr.Zero) && (cv.BCount >= tttypes.InBuffSize - 10)) { return(0); } if (cv.TelMode) { c = 0; } else { c = CommReadRawByte(cv, ref b); } if ((c == 1) && cv.TelCRFlag) { cv.TelCRFlag = false; if (b == 0) { c = 0; } } if (c == 1) { if (cv.IACFlag) { cv.IACFlag = false; if (b != 0xFF) { cv.TelMode = true; CommInsert1Byte(cv, b); if (cv.HBinBuf != IntPtr.Zero) { cv.BinSkip--; } c = 0; } } else if ((cv.PortType == PortTypeId.IdTCPIP) && (b == 0xFF)) { if (!cv.TelFlag && cv.TelAutoDetect) /* TTPLUG */ { cv.TelFlag = true; } if (cv.TelFlag) { cv.IACFlag = true; c = 0; } } else if (cv.TelFlag && !cv.TelBinRecv && (b == 0x0D)) { cv.TelCRFlag = true; } } if ((c == 1) && (cv.HBinBuf != IntPtr.Zero)) { Log1Bin(cv, b); } return(c); }
internal void Init(ProgramDatas datas) { ttwinman = datas.ttwinman; ts = datas.TTTSet; cv = datas.TComVar; }
internal static void CommClose(TComVar cv) { //throw new NotImplementedException(); }
internal static bool CommCanClose(TComVar cv) { throw new NotImplementedException(); }
internal static void CommResetSerial(ref TTTSet ts, ref TComVar cv, bool p) { throw new NotImplementedException(); }
public static void NotifyWarnMessage(TComVar cv, string message, string title) { NotifyMessage(cv, message, title, 2); }
public static void NotifyErrorMessage(TComVar cv, string message, string title) { NotifyMessage(cv, message, title, 3); }
internal static void TTXInit(TTTSet ts, TComVar cv) { }