}//Scanner #endregion private #region creator private Channel(ComunicationNet.ChannelsRow myCDsc, CommServerComponent parent, bool demoVersion, ISettingsBase settings) : base(false, "ChannelSegTOL_" + myCDsc.Name) { CommServerComponent.Tracer.TraceVerbose(150, m_src, "Creating channel: " + myCDsc.Name); Multichannel.NextChannnel(); myStatistics = new Statistics.ChannelStatistics(myCDsc); PluginCollection m_Plugins = new PluginCollection(parent.m_CommonBusControl); foreach (ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows()) { IApplicationLayerMaster chnProtocol = CreateApplicationProtocol(proto, parent, m_Plugins, settings); if (chnProtocol != null) { foreach (ComunicationNet.SegmentsRow currDSC in proto.GetSegmentsRows()) { SegmentParameters parameters = new SegmentParameters(currDSC); Diagnostic.Segment segmentStatistic = new Diagnostic.Segment(currDSC, myStatistics); Segment segment = new Segment (currDSC, (byte)proto.MaxNumberOfRetries, chnProtocol, parameters, demoVersion, segmentStatistic, this) { Cycle = parameters.TimeReconnect }; segment.ResetCounter(); } } else { string name = proto != null ? proto.Name : "---not set---"; CommServerComponent.Tracer.TraceWarning(199, m_src, "Cannot find component implementing the required protocol: " + name); } } //foreach (NetworkConfig.ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows) CommServerComponent.Tracer.TraceVerbose(203, m_src, "Channel: " + myCDsc.Name + " has been created."); } //Channel
/// <summary> /// Initializes the cache when the first server is created. /// </summary> public void Initialize() { lock (this) { if (m_disposed) { throw new ObjectDisposedException("Opc.Da.Cache"); } // create the resource manager. m_resourceManager = new ResourceManager("OpcDa.Resources.Strings", Assembly.GetExecutingAssembly()); // initialize status. m_status = new ServerStatus(); m_status.VendorInfo = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute))).Description; m_status.ProductVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); m_status.ServerState = serverState.running; m_status.StatusInfo = serverState.running.ToString(); m_status.StartTime = DateTimeProvider.GetCurrentTime(); m_status.LastUpdateTime = DateTime.MinValue; m_status.CurrentTime = DateTimeProvider.GetCurrentTime(); CommServerComponent _protocolHub = new CommServerComponent(); m_ServerShutdown += c => ToBeDisposedAfterShutdown.GetServerShutdownEventHandler(_protocolHub); _protocolHub.Initialize(CAS.Lib.RTLib.Management.AppConfigManagement.filename); Device _Device = new Device(); m_ServerShutdown += c => ToBeDisposedAfterShutdown.GetServerShutdownEventHandler(_Device); BuildAddressSpace(_Device, ((IDeviceIndexed)_Device).GetIndexedAddressSpace); } }
public static void InstallLicense(TestContext testContext) { try { LibInstaller.InstallLicense(false); CommServerComponent = new CommServerComponent(); SettingsBaseFixture _settings = new SettingsBaseFixture(); CommServerComponent.Initialize("DefaultConfig.xml", _settings); } catch (System.Exception _ex) { m_InstallLicenseError = _ex.ToString(); Debug.WriteLine(m_InstallLicenseError); throw; } }
/// <summary> /// Initialize the communication server /// </summary> /// <param name="parent">Parent control hosting some common resources</param> /// <param name="demoVer">true if there is no valid license, false otherwise</param> /// <param name="valueConstrain">Number of item I can instantiate according of the license. �1 if unlimited. Valid if cDemoVer is false.</param> /// <param name="configurationFileName">Name of the configuration file.</param> internal static void InitializeServer(CommServerComponent parent, bool demoVer, ref int valueConstrain, string configurationFileName, ISettingsBase settings) { ProtocolHubConfiguration xml = new ProtocolHubConfiguration(configurationFileName, true); try { InitializeItemDescriber(); } catch (Exception ex) { CommServerComponent.Tracer.TraceWarning(98, typeof(Initialization).FullName + ".Initialization", ex.Message); } //CAS.OpcSvr.Da.NETServer.Initialization.InitComponent(); Station.InitStations(xml.configuration.Station, ref valueConstrain); Channel.InitializeChannels(xml.configuration.Channels, parent, demoVer, settings); Station.SwitchOnDataScanning(); }
private IApplicationLayerMaster CreateApplicationProtocol(ComunicationNet.ProtocolRow protocol, CommServerComponent parent, PluginCollection plugins, ISettingsBase settings) { CommServerComponent.Tracer.TraceVerbose(60, m_src, "Creating protocol: " + protocol.Name); if (protocol.IsDPIdentifierNull()) { //the protocol is not set so it cannot be created CommServerComponent.Tracer.TraceWarning(65, m_src, "The protocol is not set so it cannot be created, channel = " + this.myStatistics.myName); return(null); } CommServerComponent.Tracer.TraceVerbose(69, m_src, string.Format("Trying to find data provider: {0}", protocol.DPIdentifier.ToString())); try { IDataProviderID _DataProviderID = plugins[protocol.DPIdentifier]; if (_DataProviderID != null) { string _format = "OK I have got DataProvider. Name = {0} [{1}]"; CommServerComponent.Tracer.TraceVerbose(77, m_src, string.Format(_format, _DataProviderID.Title, _DataProviderID.GetDataProviderDescription.FullName)); try { _DataProviderID.SetSettings(protocol.DPConfig); } catch (XmlException xe) { _format = "Problem with: {0} because of Xml content: {1}."; CommServerComponent.Tracer.TraceWarning(85, m_src, string.Format(_format, protocol.DPConfig, xe.ToString())); } catch (Exception e) { _format = "Problem with: {0} because of general failure: {1}."; CommServerComponent.Tracer.TraceWarning(90, m_src, string.Format(_format, protocol.DPConfig, e.ToString())); } IProtocolParent cStatistic = Diagnostic.CommServerProtocol.CreateNewProtocol(protocol.DPConfig, protocol.Name, protocol.ProtocolID, _DataProviderID.GetSettingsHumanReadableFormat(), myStatistics, settings); IApplicationLayerMaster chnProtocol = _DataProviderID.GetApplicationLayerMaster(cStatistic, parent.m_CommonBusControl); CommServerComponent.Tracer.TraceVerbose(95, m_src, "I have created the DataProvider helper object."); return(chnProtocol); } else { string _message = "The data provider you are looking for is not available – check your configuration and execution path of the product."; CommServerComponent.Tracer.TraceInformation(102, m_src, _message); } }//try catch (System.ComponentModel.LicenseException ex) { string _format = "The component cannot be granted a license: {0}."; CommServerComponent.Tracer.TraceWarning(108, m_src, string.Format(_format, ex.LicensedType.ToString())); } catch (Exception _ex) { CommServerComponent.Tracer.TraceWarning(112, m_src, string.Format("Some problem encountered while trying to get a DataProvider. Exception {0}.", _ex.Message)); } return(null); }
} //Channel #endregion creator #endregion #region API internal static void InitializeChannels(ComunicationNet.ChannelsDataTable channelsConfigTable, CommServerComponent parent, bool demoVersion, ISettingsBase settings) { Segment.DemoMode = demoVersion; foreach (ComunicationNet.ChannelsRow currRow in channelsConfigTable) { try { myChannels.Add(new Channel(currRow, parent, demoVersion, settings)); } catch (LicenseException ex) { string msg = "Cannot create channel {0} because of {1}"; CommServerComponent.Tracer.TraceVerbose(220, m_src, string.Format(msg, currRow.Name, ex.Message)); } } }
public void CommServerComponentConstructorExistTest() { CommServerComponent target = new CommServerComponent(); }