public override plcdb_lib.Models.Model.TagsDataTable BrowseTags() { try { Model.TagsDataTable Table = new Model.TagsDataTable(); if (Server == null) { return(Table); } ServerAddressSpaceBrowser Browser = Server.GetAddressSpaceBrowser(); foreach (String ItemId in Browser.GetItemIds(BrowseType.Flat, string.Empty, VarEnum.VT_EMPTY, 0)) { Model.TagsRow Row = Table.NewTagsRow(); Row.Address = ItemId; Row.Controller = ControllerInfo.PK; Table.AddTagsRow(Row); } Table.AcceptChanges(); return(Table); } catch (Exception ex) { throw new Exception("Error browsing tags from OPC server: " + ControllerInfo.Address + "\\" + ControllerInfo.opc_server, ex); } }
private void OnRefreshTags() { Model.TagsDataTable AllTags = CurrentController.Controller.BrowseTags(); //add new tags foreach (Model.TagsRow row in AllTags) { if (ActiveModel.Tags.Where(p => p.Controller == CurrentController.PK && p.Address == row.Address).Count() == 0) { Model.TagsRow NewRow = ActiveModel.Tags.NewTagsRow(); NewRow.Controller = CurrentController.PK; foreach (DataColumn col in ActiveModel.Tags.Columns) { if (col.ColumnName != "PK") { NewRow[col.ColumnName] = row[col.ColumnName]; } } ActiveModel.Tags.AddTagsRow(NewRow); } } //delete old tags foreach (Model.TagsRow row in ActiveModel.Tags.Where(p => p.Controller == CurrentController.PK)) { if (AllTags.Where(p => p.Address == row.Address).Count() == 0) { row.Delete(); } } ActiveModel.Tags.AcceptChanges(); SetAvailableTags(); }
private void SetAvailableTags() { Model.TagsDataTable tbl = new Model.TagsDataTable(); foreach (Model.TagsRow row in CurrentController.GetTagsRows()) { tbl.ImportRow(row); } AvailableTags = tbl.AsEnumerable(); }
public override Model.TagsDataTable BrowseTags() { if (Tags == null) { Tags = new Model.TagsDataTable(); Model.TagsRow Sine = Tags.NewTagsRow(); Sine.Address = "Doubles\\Sine"; Sine.Name = Sine.Address; Sine.DataType = typeof(Double); Sine.Controller = ControllerInfo.PK; Model.TagsRow Rand = Tags.NewTagsRow(); Rand.Address = "Doubles\\Rand"; Rand.Name = Rand.Address; Rand.DataType = typeof(Double); Rand.Controller = ControllerInfo.PK; Model.TagsRow AlwaysOn = Tags.NewTagsRow(); AlwaysOn.Address = "Bools\\AlwaysOn"; AlwaysOn.Name = AlwaysOn.Address; AlwaysOn.DataType = typeof(Boolean); AlwaysOn.Controller = ControllerInfo.PK; Model.TagsRow AlwaysOff = Tags.NewTagsRow(); AlwaysOff.Address = "Bools\\AlwaysOff"; AlwaysOff.Name = AlwaysOff.Address; AlwaysOff.DataType = typeof(Boolean); AlwaysOff.Controller = ControllerInfo.PK; Model.TagsRow RandBool = Tags.NewTagsRow(); RandBool.Address = "Bools\\RandBool"; RandBool.Name = RandBool.Address; RandBool.DataType = typeof(Boolean); RandBool.Controller = ControllerInfo.PK; Model.TagsRow Now = Tags.NewTagsRow(); Now.Address = "DateTimes\\Now"; Now.Name = Now.Address; Now.DataType = typeof(DateTime); Now.Controller = ControllerInfo.PK; Tags.AddTagsRow(Sine); Tags.AddTagsRow(Rand); Tags.AddTagsRow(AlwaysOn); Tags.AddTagsRow(AlwaysOff); Tags.AddTagsRow(RandBool); Tags.AddTagsRow(Now); } return(Tags); }