/// <summary> /// Initializes a new instance of the <see cref="OPCClientGroup"/> class. /// </summary> /// <param name="group">The group description from XML configuration file<see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param> /// <param name="items">The table of items <see cref="OPCCliConfiguration.ItemsRow"/>.</param> /// <param name="server">Server that this group should belong to</param> /// <param name="parent">The parent.</param> /// <param name="volumeConstrain">The volume constrain.</param> private void OPCClientGroup ( OPCCliConfiguration.SubscriptionsRow group, OPCCliConfiguration.ItemsRow[] items, OPC_Interface server, ref uint?volumeConstrain ) { if (volumeConstrain.HasValue) { if (volumeConstrain.Value < items.Length) { throw new LicenseException(typeof(DataBindingsManager), this, CAS.Lib.CodeProtect.Properties.Resources.Tx_LicVolumeConstrainErr); } else { volumeConstrain = volumeConstrain.Value - Convert.ToUInt32(items.Length); } } SubscriptionState state = group.CreateSubscriptionState; OPC_Interface.OPCGroup m_OPCGroup; m_OPCGroup = server.CreateOPCGroup((uint)group.ID, (uint)group.ID_server, group.Asynchronous, state); m_OPCGroup.Tags = Tags(items, server, m_OPCGroup); }
public SubscriptionTreeNodes(OPCCliConfiguration.SubscriptionsRow subscription) : base(new SubscriptionWrapperForPropertyGrid(subscription), subscription.Name) { foreach (OPCCliConfiguration.ItemsRow item in subscription.GetItemsRows()) { this.Nodes.Add(new ItemTreeNode(item)); } }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionTreeNode"/> class. /// </summary> /// <param name="subscription">The subscription <see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param> /// <param name="parent">The parent tree node <see cref="OPCSessionServer"/>.</param> internal SubscriptionTreeNodeSession(OPCCliConfiguration.SubscriptionsRow subscription, OPCSessionServer parent) : base("", null, parent) { Text = subscription.Name; m_Menu = new ContextMenuSubscription(this); Enabled = subscription.Enabled; State = subscription.CreateSubscriptionState; foreach (var item in subscription.GetItemsRows()) { new TagTreeNode(item, this); } AssignImageIndex(); }
/// <summary> /// Initializes a new instance of the <see cref="OPCClientGroup"/> class. /// </summary> /// <param name="group">The group description from XML configuration file<see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param> /// <param name="items">The table of items <see cref="OPCCliConfiguration.ItemsRow"/>.</param> /// <param name="server">Server that this group should belong to</param> /// <param name="parent">The parent.</param> /// <param name="volumeConstrain">The volume constrain.</param> internal OPCClientGroup ( OPCCliConfiguration.SubscriptionsRow group, OPCCliConfiguration.ItemsRow[] items, OPC_Interface server, OPCDataQueue parent, ref uint? volumeConstrain ) { if ( volumeConstrain.HasValue ) if ( volumeConstrain.Value < items.Length ) throw new LicenseException( typeof( Main ), Main.MainComponent, CAS.Lib.CodeProtect.Properties.Resources.Tx_LicVolumeConstrainErr ); else volumeConstrain = volumeConstrain.Value - Convert.ToUInt32( items.Length ); OpcDa.SubscriptionState state = group.CreateSubscriptionState; m_OPCGroup = server.CreateOPCGroup( (uint)group.ID, (uint)group.ID_server, group.Asynchronous, state ); m_OPCGroup.Tags = Tags( items, server, m_OPCGroup ); m_AllGroups.Add( this ); }
internal OPCItemIdentifier GetItemIdentifier(string description, out ConfigurationManagement.AdditionalResultInfo resultInfo) { if ((!Opened) && !Open(m_DefaultFileName, out resultInfo)) { return(null); } foreach (OPCCliConfiguration.ItemsRow item in m_ConfigurationManagement.Configuartion.Items) { if (item.Name.Contains(description)) { OPCCliConfiguration.SubscriptionsRow subscription = item.SUBSCRIPTIONRow; OPCCliConfiguration.ServersRow server = subscription.SERVERSRow; resultInfo = ConfigurationManagement.AdditionalResultInfo.OK; return(new OPCItemIdentifier() { ItemName = item.Name, SubscriptionName = subscription.Name, ServerName = server.Name }); } } resultInfo = ConfigurationManagement.AdditionalResultInfo.Exception; return(null); }
protected override void DoTheImport() { int changes_number = 0; #region IMPORT //robimy jakies importowanie: long group_add = 0; long server_add = 0; if (this.m_ImportTagsInfo.AddNew && this.m_ImportTagsInfo.CreateGroup && m_ImportTagsInfo.ServerID.HasValue) { OPCCliConfiguration.SubscriptionsRow newgroup = this.m_database.Subscriptions.NewSubscriptionsRow(); newgroup.UpdateRate = m_ImportTagsInfo.SamplingRate; newgroup.Name = "NewGroup"; newgroup.ID_server = (long)m_ImportTagsInfo.ServerID; this.m_database.Subscriptions.AddSubscriptionsRow(newgroup); this.m_ImportTagsInfo.GroupID = newgroup.ID; } if (this.m_ImportTagsInfo.AddNew && this.m_ImportTagsInfo.GroupID.HasValue) { group_add = (long)this.m_ImportTagsInfo.GroupID; //szukamy serwera foreach (OPCCliConfiguration.SubscriptionsRow srow in this.m_database.Subscriptions) { if (srow.ID == group_add) { server_add = srow.ID_server; break; } } } CSVManagement file = CSVManagement.ReadFile(m_ImportTagsInfo.Filename); while (file.ToString().Length > 0) { string read; string name = file.GetAndMove2NextElement(); int type; read = file.GetAndMove2NextElement(); if (read.Length > 0) { type = System.Convert.ToByte(read); } else { type = -1; } string conversion = file.GetAndMove2NextElement(); bool async; read = file.GetAndMove2NextElement(); if (read.Length > 0) { async = System.Convert.ToBoolean(System.Convert.ToInt16(read)); } else { async = false; } int maxage = -1; read = file.GetAndMove2NextElement(); if (read.Length > 0) { maxage = System.Convert.ToInt32(read); } System.Console.WriteLine("tag do zminay: " + name); if (this.m_ImportTagsInfo.AddNew && this.m_ImportTagsInfo.GroupID.HasValue) { throw new Exception("Importing tools are not support new schema yet"); //OPCCliConfiguration.ItemsRow itrow = m_database.Items.NewItemsRow(); //itrow.Name = name; //itrow.ID = getMaxItemID(); //itrow.ID_Subscription = group_add; ////if ( type >= 0 ) //// itrow.RequestedType = (byte)type; //if ( maxage >= 0 ) // itrow.MaxAge = maxage; //else // itrow.SetMaxAgeNull();//=new DBNull(); ////TODO:fix import tool ////itrow.Async = async; ////if ( conversion != "" ) //// itrow.Conversion = conversion; //m_database.Items.AddItemsRow( itrow ); //changes_number++; } else { //szukamy teraz odpowiedniego taga w liscie foreach (OPCCliConfiguration.ItemsRow itrow in m_database.Items) { if (itrow.Name.Equals(name)) { throw new Exception("Importing tools are not support new schema yet"); ////if ( type >= 0 ) //// itrow.RequestedType = (byte)type; //if ( maxage >= 0 ) // itrow.MaxAge = maxage; //else // itrow.SetMaxAgeNull();//=new DBNull(); ////TODO:fix import tool ////itrow.Async = async; ////if ( conversion != "" ) //// itrow.Conversion = conversion; //itrow.AcceptChanges(); ////System.Console.WriteLine("zmieniono: "+itrow.Name.ToString()+" numer" +zmieniono.ToString()); //changes_number++; } } } //czytamy jeszce slowo endline: file.GetAndMove2NextElement(); } AppendToLog("changed: " + changes_number.ToString() + "of: " + m_database.Items.Count.ToString()); #endregion IMPORT }
protected override void DoTheImport() { int changes_number = 0; #region IMPORT //robimy jakies importowanie: //dodajemy grupe: OPCCliConfiguration.SubscriptionsRow grow = null; try { if (m_ImportTagsInfo.GroupID != null) { foreach (OPCCliConfiguration.SubscriptionsRow tempgr in m_database.Subscriptions) { if (m_ImportTagsInfo.GroupID == tempgr.ID) { grow = tempgr; break; } } } if (grow == null) { grow = m_database.Subscriptions.NewSubscriptionsRow(); grow.ID_server = m_ImportTagsInfo.ServerID; grow.UpdateRate = m_ImportTagsInfo.SamplingRate; grow.Name = "ImportedGroup" + m_ImportTagsInfo.ServerID.ToString(); m_database.Subscriptions.AddSubscriptionsRow(grow); } if (m_ImportTagsInfo.ClearGroup) { foreach (OPCCliConfiguration.ItemsRow itrow in grow.GetItemsRows()) { m_database.Items.RemoveItemsRow(itrow); } } } catch { AppendToLog("Problem with adding for server: " + m_ImportTagsInfo.ServerID.ToString()); return; } //teraz otworzymy plik i dodamy wszystkie tagi: System.IO.StreamReader plik = new System.IO.StreamReader(m_ImportTagsInfo.Filename, System.Text.Encoding.Default); string plikzawartosc = plik.ReadToEnd(); plik.Close(); string Tagname = "-- unknowname --"; while (plikzawartosc.Length > 0) { try { int pos = plikzawartosc.IndexOf("\r\n"); if (pos >= 0) { Tagname = plikzawartosc.Substring(0, pos); plikzawartosc = plikzawartosc.Remove(0, pos + 2); } else { if (plikzawartosc.Length > 0) { Tagname = plikzawartosc; plikzawartosc = ""; } } Tagname = Tagname.Trim(); if (Tagname.Length > 0) //only if the line is not empty { //dodajemy taga: OPCCliConfiguration.ItemsRow itemrow = m_database.Items.NewItemsRow(); itemrow.Name = Tagname; itemrow.ID_Subscription = grow.ID; itemrow.MaxAge = m_ImportTagsInfo.MaxAge; m_database.Items.AddItemsRow(itemrow); changes_number++; } } catch ( Exception #if DEBUG ex #endif ) { AppendToLog("problem with tag:" + Tagname + " :" #if DEBUG + ex.Message.ToString() #endif ); } } #endregion IMPORT AppendToLog("Number of changed tags: " + changes_number.ToString()); }