public void RefreshFromEvents(OPCController opcgroup) { for (int opcIndex = 1; opcIndex < opcgroup.TotalItemNumber + 1; opcIndex++) { string tag = opcgroup.GetTagName(opcIndex); int index = SearchTag(tag); if (index > -1) { InternalTag dt = Values[index]; if (Convert.ToInt32(dt.LastValue) != Convert.ToInt32(dt.Value)) { dt.LastValue = dt.Value; dt.Activated = Convert.ToInt32(dt.Value) > 0; dt.Deactivated = !dt.Activated; } else { if (dt.Activated) { dt.LastValue = 0; dt.Value = 0; dt.Activated = false; dt.Deactivated = true; } else { dt.Deactivated = false; } } Values[index] = dt; } } }
public void Init() { Values = new List <InternalTag>(); Logging log = new Logging("select Tag, OPCName, Type from PLC2DB_Tags order by tag"); try { using (var connection = new SqlConnection(IntData.CfgConn)) { connection.Open(); SqlCommand cmd = new SqlCommand(log.Command, connection); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { InternalTag dt = new InternalTag { Tag = sdr[0].ToString().Trim(), IsIntTag = sdr[1].ToString().Trim() == "-" && sdr[2].ToString().Trim() == "VAR", Activated = false, Deactivated = false, LastValue = 0, Value = 0 }; Values.Add(dt); } } log.Success(); } catch (Exception ex) { log.Fatal(ex); } }
public bool UpdateTagsValue(string tag, object newValue) { for (int i = 0; i < Values.Count; i++) { InternalTag dt = Values[i]; if (dt.Tag.Trim() == tag.Trim()) { dt.Value = newValue; Values[i] = dt; return(true); } } return(false); }
public void RefreshFromGroup(OPCController opcgroup) { for (int index = 1; index < opcgroup.TotalItemNumber + 1; index++) { for (int i = 0; i < Values.Count; i++) { InternalTag dt = Values[i]; if (dt.Tag == opcgroup.GetTagName(index)) { dt.Value = opcgroup.GetTagValue(dt.Tag); dt.Activated = opcgroup.Activated(dt.Tag); dt.Deactivated = opcgroup.Deactivated(dt.Tag); } Values[i] = dt; } } }