protected void InitializeOperation(IDataProviderID dataProviderID, CommonBusControl commonBusControl, IProtocolParent protocolParent, bool readOperation)
 {
     m_ResourceSelected     = ResourceSelected;
     m_StationAddress       = StationAddress;
     m_RegisterAddress      = RegisterStartAddress;
     m_DataTypeOfConversion = DataTypeOfConversion;
     m_Length = Length;
     if (m_DataTypeOfConversion == typeof(string))
     {
         m_RegistersCount = 1;
     }
     else
     {
         m_RegistersCount = Length;
     }
     m_CommLayerAddress     = Commlayeraddress;
     ApplicationLayerMaster = dataProviderID.GetApplicationLayerMaster(protocolParent, commonBusControl);
     if (readOperation)
     {
         m_DoOperation = ReadOperation;
     }
     else
     {
         m_ValueToBeWritten = ValueToBeWritten(m_DataTypeOfConversion);
         m_DoOperation      = WriteOperation;
     }
 }
Ejemplo n.º 2
0
 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);
 }
 /// <summary>
 /// Creats new <see cref="ProtocolAndSerialRowWrapper"/> based on specified Protocol nad Serial rows
 /// </summary>
 /// <param name="protocol">Protocol row</param>
 public ProtocolAndSerialRowWrapper(ComunicationNet.ProtocolRow protocol)
     : base(protocol)
 {
     if (!protocol.IsDPIdentifierNull())
     {
         CAS.Lib.CommonBus.Management.PluginCollection cPC = new CAS.Lib.CommonBus.Management.PluginCollection(m_CommonBusControl);
         try
         {
             m_DataProvider = cPC[protocol.DPIdentifier];
             m_DataProvider.SetSettings(protocol.DPConfig);
         }
         catch (Exception)
         {
             MessageBox.Show("One of the Data Provider cannot be loaded: \n\r " + protocol.DPConfig);
         }
     }
 }
Ejemplo n.º 4
0
 private void c_TreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag is ICommunicationLayerId)
     {
         c_PropertyGrid.SelectedObject = ((ICommunicationLayerId)e.Node.Tag).GetCommunicationLayerDescription;
         GetSelectedDPID = (IDataProviderID)e.Node.Parent.Tag;
         GetSelectedDPID.SelectedCommunicationLayer = (ICommunicationLayerId)e.Node.Tag;
         m_OKCnacelForm.CanBeAccepted(true);
     }
     else
     {
         if (e.Node.Tag is IDataProviderID)
         {
             c_PropertyGrid.SelectedObject = ((IDataProviderID)e.Node.Tag).GetDataProviderDescription;
         }
         GetSelectedDPID = null;
         m_OKCnacelForm.CanBeAccepted(false);
     }
 }
 /// <summary>
 /// sets the source object for the property window
 /// </summary>
 /// <param name="pDPID"></param>
 public void SetObjects(IDataProviderID pDPID)
 {
     cn_PropertyGridApp.SelectedObject  = pDPID;
     cn_PropertyGridComm.SelectedObject = pDPID.SelectedCommunicationLayer;
 }
Ejemplo n.º 6
0
 internal LocalOperation(Program parent, IDataProviderID dataProviderID, CommonBusControl commonBusControl, IProtocolParent protocolParent, bool readOperation)
 {
     Parent = parent;
     Delay  = System.Convert.ToInt32(parent.@_Delay.Text);
     InitializeOperation(dataProviderID, commonBusControl, protocolParent, readOperation);
 }