private void CheckTables() { Select S; int nn; S = new Select(string.Format( "select count(*) as nn from INFORMATION_SCHEMA.TABLES where table_type='BASE TABLE' and TABLE_SCHEMA='{0}' and table_name='BoardSQL'" , schema)); if (!S.Read()) { FN.fatal("BoardSQL.CheckTables: " + S.SQL + " - не нашли записей"); } nn = Convert.ToInt32(S["nn"]); S.Dispose(); if (nn != 1) { new ExecSQL(string.Format( "CREATE TABLE {0}.BoardSQL(" + " DevNum int," + " Input varchar(32) NULL,"+ " Output varchar(32) NULL"+ ") ON [PRIMARY]" , schema)); } S = new Select(string.Format("select count(*) as nn from {0}.BoardSQL where DevNum={1}", schema, Devnum)); S.Read(); nn = Convert.ToInt32(S["nn"]); S.Dispose(); if (nn < 1) { new ExecSQL(string.Format("insert into {0}.BoardSQL values({1},replicate('.',32),replicate('.',32))", schema, Devnum.ToString())); } }
void CheckTables() { Select S; int nn; S = new Select(string.Format( "select count(*) as nn from INFORMATION_SCHEMA.TABLES where table_type='BASE TABLE' and TABLE_SCHEMA='{0}' and table_name='Board1784'" , schema)); if (!S.Read()) { FN.fatal("BoardSQL.CheckTables: " + S.SQL + " - не нашли записей"); } nn = (int)S[0]; S.Dispose(); if (nn != 1) { new ExecSQL(string.Format("CREATE TABLE {0}.Board1784(DevNum int NOT NULL,Lir0 int NOT NULL,Lir1 int NOT NULL,Command varchar(50) NULL)", schema)); } S = new Select(string.Format("select count(*) as nn from {0}.Board1784 where DevNum={1}", schema, DevNum)); S.Read(); nn = (int)S[0]; S.Dispose(); if (nn < 1) { new ExecSQL(string.Format("insert into {0}.Board1784 (DevNum,Lir0,Lir1) values({1},0,0)", schema, DevNum.ToString())); } }
public override void Dispose() { disposed = true; int err = DASP52032Connector.DASP52032_Release((byte)devnum); if (err != 0) { FN.fatal("DASP52032_real.Dispose: Ошибка: " + DASP52032Connector.GetError(err)); } }
public DASP52032_real(BoardPars _pars, DOnPr _OnPr = null) : base(_pars, _OnPr) { int err; int DllVersion = 0; err = DASP52032Connector.DASP52032_GetDllVersion(ref DllVersion); pr("DASP52032_real.DASP52032_real: DllVersion=" + DllVersion.ToString()); err = DASP52032Connector.DASP52032_QuickInstalled((byte)devnum, 0); if (err != 0) { FN.fatal("DASP52032_real.DASP52032_real: Ошибка: " + DASP52032Connector.GetError(err)); } }
public override void Write(byte[] _values_out) { if (disposed) { return; } Int16 data = 0; data |= (Int16)(_values_out[0]); data |= (Int16)(_values_out[1] << 8); int err = DASP52032Connector.DASP52032_WriteGpio((byte)devnum, data); if (err != 0) { FN.fatal("DASP52032_real.Write: Ошибка: " + DASP52032Connector.GetError(err)); } }
public override byte[] ReadOut() { if (disposed) { return(null); } Int16 data = 0; int err = DASP52032Connector.DASP52032_ReadBackGpio((byte)devnum, ref data); if (err != 0) { FN.fatal("DASP52032_real.ReadOut: Ошибка: " + DASP52032Connector.GetError(err)); } values_out[0] = (byte)(data & 0xFF); values_out[1] = (byte)((data >> 8) & 0xFF); return(values_out); }
public override int ReadOut() { Select S = new Select(string.Format("select {0} from {1}.BoardSQL where DevNum={2}", OutputSide, schema, Devnum.ToString())); if (!S.Read()) { FN.fatal("BoardSQL.ReadOut: " + S.SQL + " - не нашли записей"); } string sval = S[0] as string; values_out = 0; int i = 0; foreach (char c in sval) { SetBit(ref values_out, i++, c == '1'); } S.Dispose(); return(values_out); }