//定时器 public void CommTimerCall(object source, System.Timers.ElapsedEventArgs e) { int iSec = DateTime.Now.Second; DateTime DTNow = DateTime.Now; if (iOldSec != iSec) { iOldSec = iSec; foreach (CStation nSta in ListStation) { foreach (CVar nVar in nSta.LstExtendVar) { if (nVar.ExpressR != null) { nVar.SetExtendVarValue(); } } foreach (CVar nVar in nSta.StaDevice.ListDevVar) { if (nVar.SaveToDB > 0) { SVarValue newValue = new SVarValue(nVar.VarNewValue.Value_d); newValue.Date_Time = DTNow; nVar.ListValue.Add(newValue); while (nVar.ListValue.Count > CCONST.VarNumMax) { nVar.ListValue.RemoveAt(0); } } } } nDatabase.CommTimerCall(); } }
public virtual void SetValue(Int64 value) { //ValueInt64 = value; SVarValue newValue = new SVarValue(); newValue.Date_Time = DateTime.Now; if (StrTag[2] == "Int16") { value = (short)value; } if (StrTag[2] == "float754") { byte[] bytes = BitConverter.GetBytes((int)value); Single sinV = BitConverter.ToSingle(bytes, 0); newValue.Value_d = (double)(sinV * RatioValue + BaseValue); } else { newValue.Value_d = (double)(value * RatioValue + BaseValue); } VarOldValue = VarNewValue; VarNewValue = newValue; if (nVarAlarm != null)//配置了报警,且品质是好的情况下,产生报警 { CheckAlarm(); } }
public virtual void SetExtendVarValue() { //ValueInt64 = value; SVarValue newValue = new SVarValue(); newValue.Date_Time = DateTime.Now; newValue.Value_d = (double)(Convert.ToDouble(ExpressR.GetValue()) * RatioValue + BaseValue); VarOldValue = VarNewValue; VarNewValue = newValue; if (nVarAlarm != null)//配置了报警,且品质是好的情况下,产生报警 { CheckAlarm(); } }
public virtual void SetValue(Single value) { //ValueInt64 = value; SVarValue newValue = new SVarValue(); newValue.Date_Time = DateTime.Now; newValue.Value_d = (double)(value * RatioValue + BaseValue); VarOldValue = VarNewValue; VarNewValue = newValue; if (nVarAlarm != null)//配置了报警,且品质是好的情况下,产生报警 { CheckAlarm(); } }
public virtual String GetStrDataValue() { try { // if (DAType == EDAType.DA_YS && ExpressR != null) // return ExpressR.GetValue(); SVarValue newValue; if (ListValue.Count > 0) { newValue = ListValue[ListValue.Count - 1]; } else { newValue = new SVarValue(); } switch (VarType) { case EVarTYPE.Var_INT: case EVarTYPE.Var_UINT: case EVarTYPE.Var_LINT: case EVarTYPE.Var_ULINT: return((Convert.ToInt64(newValue.Value_d)).ToString()); case EVarTYPE.Var_FLOAT: case EVarTYPE.Var_DOUBLE: return(newValue.Value_d.ToString()); case EVarTYPE.Var_CHAR: //"字符型"; case EVarTYPE.Var_UCHAR: //"无符号字符型"; return(Convert.ToChar(newValue.Value_d).ToString()); case EVarTYPE.Var_BOOL: // "布尔型"; return(Convert.ToBoolean(newValue.Value_d).ToString()); case EVarTYPE.Var_STRING: //"字符串型"; return(""); case EVarTYPE.Var_BLOB: //"二进制型"; return(""); default: return(""); } } catch (Exception ex) { return(""); } }
public virtual Double GetDoubleDataValue() { try { SVarValue newValue; if (ListValue.Count > 0) { newValue = ListValue[ListValue.Count - 1]; } else { newValue = new SVarValue(); } switch (VarType) { case EVarTYPE.Var_INT: case EVarTYPE.Var_UINT: case EVarTYPE.Var_LINT: case EVarTYPE.Var_ULINT: case EVarTYPE.Var_BOOL: // "布尔型"; case EVarTYPE.Var_FLOAT: case EVarTYPE.Var_DOUBLE: case EVarTYPE.Var_CHAR: //"字符型"; case EVarTYPE.Var_UCHAR: //"无符号字符型"; return((Double)newValue.Value_d); case EVarTYPE.Var_STRING: //"字符串型"; return(0); case EVarTYPE.Var_BLOB: //"二进制型"; return(0); default: return(0); } } catch (Exception ex) { return(0); } }