Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalDatasetDistributor"/> class.
        /// </summary>
        /// <param name="localDistributor">The object that handles distribution proposals for the local machine.</param>
        /// <param name="loader">The object that handles the actual starting of the dataset application.</param>
        /// <param name="commandHub">The object that sends commands to remote endpoints.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks on.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localDistributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="loader"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public LocalDatasetDistributor(
            ICalculateDistributionParameters localDistributor,
            IDatasetActivator loader,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func <DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Enforce.Argument(() => localDistributor);
                Enforce.Argument(() => loader);
                Enforce.Argument(() => commandHub);
                Enforce.Argument(() => notificationHub);
                Enforce.Argument(() => datasetInformationBuilder);
                Enforce.Argument(() => communicationLayer);
                Enforce.Argument(() => systemDiagnostics);
            }

            m_LocalDistributor          = localDistributor;
            m_Loader                    = loader;
            m_CommandHub                = commandHub;
            m_NotificationHub           = notificationHub;
            m_Uploads                   = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer        = communicationLayer;
            m_Diagnostics               = systemDiagnostics;
            m_Scheduler                 = scheduler ?? TaskScheduler.Default;
        }
 ///// <summary>
 ///// MBUS protocol initialization
 ///// </summary>
 ///// <param name="cCommLayer">Interface responsible for providing the communication</param>
 ///// <param name="cProtParameters">Protocol parameters</param>
 ///// <param name="cStatistic">Statistical information about the communication performance</param>
 ///// <param name="cPool">Empty data messages pool to be used by the protocol.</param>
 //internal MODBProtocol
 //  ( ICommunicationLayer cCommLayer, ProtocolParameters cProtParameters,
 //  BaseStation.Management.IProtocolParent cStatistic, SesDBufferPool<MBUS_message> cPool
 //  )
 //  : base( cCommLayer, cProtParameters, cStatistic )
 //{
 //  this.m_Pool = cPool;
 //}
 /// <summary>
 /// SBUS protocol initialization
 /// </summary>
 /// <param name="pCommLayer">Interface responsible for providing the communication</param>
 /// <param name="pProtParameters">Protocol parameters</param>
 /// <param name="pStatistic">Statistical information about the communication performance</param>
 /// <param name="pPool">Empty data messages pool to be used by the protocol.</param>
 internal MBUSProtocol
     (ICommunicationLayer pCommLayer, ProtocolParameters pProtParameters,
     CAS.Lib.RTLib.Management.IProtocolParent pStatistic, SesDBufferPool <MBUS_message> pPool)
     : base(pCommLayer, pProtParameters, pStatistic)
 {
     this.m_Pool = pPool;
 }
 /// <summary>
 /// contructor
 /// </summary>
 /// <param name="pStatistic">out statistic class</param>
 /// <param name="pComm"></param>
 /// <param name="pErrorFrequency"></param>
 internal NULL_ApplicationLayerMaster
     (IProtocolParent pStatistic, ICommunicationLayer pComm, int pErrorFrequency)
     : base(pComm)
 {
     this.myStatistic = pStatistic;
     //m_errorfrequency = pErrorFrequency;
 }
        }//ReadData

        #endregion
        #region INIT
        internal NULL_ApplicationLayerSniffer
            (CAS.Lib.RTLib.Management.IProtocolParent pStatistic, ICommunicationLayer pComm)
            : base(pComm)
        {
            this.myStatistic = pStatistic;
            init();
        }
        /// <summary>
        /// Creates the application layer master.
        /// </summary>
        /// <param name="pProtParameters">The protocol parameters.</param>
        /// <param name="pStatistic">The statistic.</param>
        /// <param name="pCommLayer">The communication layer.</param>
        /// <returns></returns>
        public IApplicationLayerMaster CreateApplicationLayerMaster
            (IProtocolParent pStatistic, ICommunicationLayer pCommLayer, ProtocolParameters pProtParameters)
        {
            Protocol mp = new Protocol(pCommLayer, pProtParameters, pStatistic, m_Pool);

            return(new Master(m_Pool, mp));
        }
 /// <summary>
 /// ApplicationLayerCommon creator
 /// </summary>
 /// <param name="commChannel">
 /// Communication layer to be used to transfer data to/from data provider
 /// </param>
 /// <exception cref="ApplicationException">If commChannel is null.</exception>
 public ApplicationLayerCommon(ICommunicationLayer commChannel)
 {
     if (commChannel == null)
     {
         throw new ArgumentNullException("Communication layer cannot be null");
     }
     m_CommLayer = commChannel;
 }
Exemple #7
0
        public LedMatrixServer(int width, int height, ICommunicationLayer communicationLayer)
        {
            Width  = width;
            Height = height;

            CommunicationLayer = communicationLayer;

            lastDraw.Start();
        }
Exemple #8
0
 /// <summary>
 /// contructor
 /// </summary>
 /// <param name="pStatistic">out statistic class</param>
 /// <param name="pComm"></param>
 /// <param name="pErrorFrequency"></param>
 internal NULL_ApplicationLayerMaster
     (IProtocolParent pStatistic, ICommunicationLayer pComm, int pErrorFrequency)
     : base(pComm)
 {
     this.myStatistic = pStatistic;
     m_errorfrequency = pErrorFrequency;
     ComPortCli       = pComm;
     CommunicationThroughCommunicationLayer = true;
     if (pComm.GetType().Name.Contains("NULL"))
     {
         CommunicationThroughCommunicationLayer = false;
     }
 }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteDatasetDistributor"/> class.
        /// </summary>
        /// <param name="configuration">The application specific configuration.</param>
        /// <param name="commandHub">The object that manages the remote command proxies.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RemoteDatasetDistributor(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func <DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Lokad.Enforce.Argument(() => commandHub);
                Lokad.Enforce.Argument(() => notificationHub);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => datasetInformationBuilder);
                Lokad.Enforce.Argument(() => communicationLayer);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Configuration             = configuration;
            m_Uploads                   = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer        = communicationLayer;
            m_Diagnostics               = systemDiagnostics;
            m_Scheduler                 = scheduler ?? TaskScheduler.Default;
            m_CommandHub                = commandHub;
            {
                // Set up the events so that we can see the loaders come online.
                //
                // Note that the events may come in on a different thread than the one
                // we're normally accessed on. This is because adding an enpoint is usually
                // a result of a WCF message being received, on the WCF message thread.
                m_CommandHub.OnEndpointSignedIn  += (s, e) => AddNewEndpoint(e.Endpoint, e.Commands);
                m_CommandHub.OnEndpointSignedOff += (s, e) => RemoveEndpoint(e.Endpoint);

                var knownCommands = m_CommandHub.AvailableCommands();
                foreach (var command in knownCommands)
                {
                    AddNewEndpoint(command.Endpoint, command.RegisteredCommands);
                }
            }

            m_NotificationHub = notificationHub;
        }
Exemple #10
0
        private TFrameEndSignalRes TransmitFrame(out byte[] buff, ICommunicationLayer ComPortCli)
        {
            buff = get_buffor();
            NULL_message message = pool.GetEmptyISesDBuffer();

            message.userDataLength = (ushort)buff.Length;
            for (int i = 0; i < buff.Length; i++)
            {
                message.WriteByte(buff[i]);
            }
            // czas na wyslanie ramki:
            ComPortCli.Flush();
            string msg = "sending frame: " + buff.Length.ToString() + " size";

            m_TraceSource.TraceVerbose(382, "TransmitFrame", msg);
            TFrameEndSignalRes lastRes = ComPortCli.FrameEndSignal(message);

            m_TraceSource.TraceVerbose(382, "TransmitFrame", "Frame has been sent");
            message.ReturnEmptyEnvelope();
            return(lastRes);
        }
Exemple #11
0
 /// <summary>
 /// Creator of ALProtocol
 /// </summary>
 /// <param name="pCommLayer">Interface responsible for providing the communication</param>
 /// <param name="pProtParameters">Protocol parameters</param>
 /// <param name="pStatistic">Statistical information about the communication performance</param>
 protected ALProtocol(ICommunicationLayer pCommLayer, ProtocolParameters pProtParameters, IProtocolParent pStatistic)
 {
     InitObject(pCommLayer, pProtParameters, pStatistic);
 }
Exemple #12
0
 protected override ModBusProtocol CreateModBusProtocol(ICommunicationLayer communicationLayer, ModBus_ProtocolParameters parameters, IProtocolParent protocolParent, SesDBufferPool <ModBusMessage> pool)
 {
     return(new ModBusProtocol(communicationLayer, parameters, protocolParent, pool));
 }
 /// <summary>
 /// MODBUS protocol initialization
 /// </summary>
 /// <param name="communicationLayer">Interface responsible for providing the communication</param>
 /// <param name="protocolParameters">Protocol parameters</param>
 /// <param name="protocolParent">Statistical information about the communication performance</param>
 /// <param name="pool">Empty data messages pool to be used by the protocol.</param>
 public ModbusProtocol(ICommunicationLayer communicationLayer, ProtocolParameters protocolParameters, IProtocolParent protocolParent, SesDBufferPool <ModBusMessage> pool)
     : base(communicationLayer, protocolParameters, protocolParent)
 {
     this.m_Pool = pool;
 }
Exemple #14
0
 internal ApplicationLayerSlave
     (IProtocolParent pStatistic, ICommunicationLayer pComm)
     : base(pComm)
 {
     this.myStatistic = pStatistic;
 }
 ///// <summary>
 ///// SBUS protocol initialization
 ///// </summary>
 ///// <param name="cCommLayer">Interface responsible for providing the communication</param>
 ///// <param name="cProtParameters">Protocol parameters</param>
 ///// <param name="cStatistic">Statistical information about the communication performance</param>
 ///// <param name="cPool">Empty data messages pool to be used by the protocol.</param>
 //internal SBUSProtocol
 //  ( ICommunicationLayer cCommLayer, ProtocolParameters cProtParameters,
 //  BaseStation.Management.IProtocolParent cStatistic, SesDBufferPool<SBUSbase_message> cPool
 //  )
 //  : base( cCommLayer, cProtParameters, cStatistic )
 //{
 //  this.m_Pool = cPool;
 //}
 /// <summary>
 /// SBUS protocol initialization
 /// </summary>
 /// <param name="pStatistic">Statistical information about the communication performance</param>
 /// <param name="pCommLayer">Interface responsible for providing the communication</param>
 /// <param name="pProtParameters">Protocol parameters</param>
 /// <param name="cPool">Empty data messages pool to be used by the protocol.</param>
 internal SBUSProtocol(IProtocolParent pStatistic, ICommunicationLayer pCommLayer,
                       ProtocolParameters pProtParameters, SesDBufferPool <FrameStateMachine> cPool)
     : base(pCommLayer, pProtParameters, pStatistic)
 {
     this.m_Pool = cPool;
 }
 internal SBUS_ApplicationLayerSniffer(ICommunicationLayer commChannel, SBUSProtocol pProtocol)
     : base(commChannel)
 {
     m_ALProtocol = pProtocol;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestStepExecutionCommands"/> class.
        /// </summary>
        /// <param name="fileSystem">The object that provides access to the file system.</param>
        /// <param name="layer">The object that provides methods for sending and receiving data from remote endpoints.</param>
        /// <param name="remoteCommands">The object that sends commands to remote endpoints.</param>
        /// <param name="remoteNotifications">The object that provides notifications from remote endpoints.</param>
        /// <param name="dataDownload">The function that is used to download data streams from remote endpoints.</param>
        /// <param name="executionEvents">The object that handles sending test execution events to the Sherlock master.</param>
        /// <param name="sectionBuilders">The function that returns a new test section builder.</param>
        /// <param name="configuration">The configuration object.</param>
        /// <param name="testInformation">The object that stores information about the currently active test.</param>
        /// <param name="hostInformation">The object that stores information about the host.</param>
        /// <param name="storageDirectory">The directory in which all the report files are stored.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="fileSystem"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="layer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="remoteCommands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="remoteNotifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="dataDownload"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="executionEvents"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="sectionBuilders"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testInformation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="hostInformation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="storageDirectory"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public TestStepExecutionCommands(
            IFileSystem fileSystem,
            ICommunicationLayer layer,
            ISendCommandsToRemoteEndpoints remoteCommands,
            INotifyOfRemoteEndpointEvents remoteNotifications,
            DownloadDataFromRemoteEndpoints dataDownload,
            ITestExecutionNotificationsInvoker executionEvents,
            Func<string, ITestSectionBuilder> sectionBuilders,
            IConfiguration configuration,
            ActiveTestInformation testInformation,
            HostInformationStorage hostInformation,
            string storageDirectory,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => fileSystem);
                Lokad.Enforce.Argument(() => layer);
                Lokad.Enforce.Argument(() => remoteCommands);
                Lokad.Enforce.Argument(() => remoteNotifications);
                Lokad.Enforce.Argument(() => dataDownload);
                Lokad.Enforce.Argument(() => executionEvents);
                Lokad.Enforce.Argument(() => sectionBuilders);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => testInformation);
                Lokad.Enforce.Argument(() => hostInformation);
                Lokad.Enforce.Argument(() => storageDirectory);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_FileSystem = fileSystem;
            m_Layer = layer;
            m_RemoteCommands = remoteCommands;
            m_RemoteNotifications = remoteNotifications;
            m_DataDownload = dataDownload;
            m_TestExecutionEvents = executionEvents;
            m_SectionBuilders = sectionBuilders;
            m_Configuration = configuration;
            m_TestInformation = testInformation;
            m_HostInformation = hostInformation;
            m_StorageDirectory = storageDirectory;
            m_Diagnostics = diagnostics;
        }
Exemple #18
0
 private void InitObject(ICommunicationLayer cCommLayer, ProtocolParameters cProtParameters, IProtocolParent cStatistic)
 {
     myCommLayer      = cCommLayer;
     myProtParameters = cProtParameters;
     myStatistic      = cStatistic;
 }
Exemple #19
0
 //private IProtocolParent myStatistic = null;
 //    private class MODBUS_buf_pool: CAPI.Session.SesDBufferPool
 //    {
 //      protected override CAPI.Session.ISesDBuffer CreateISesDBuffer()
 //      {
 //        MBUS_message newMess = new MBUS_message(this);
 //        return newMess;
 //      }
 //    }//MODBUS_buf_pool
 //    private MODBUS_buf_pool pool;
 //    //private RS_to_Serial r_t_s = new RS_to_Serial.RS_to_Serial();
 //
 //    private bool TX_TELEGRAM(MBUS_message Txmsg, object PcdPort)
 //    {
 //      bool res;
 //      if(r_t_s.FrameEndSignal(PcdPort,Txmsg)==BaseStation.TResult.Success) res = true;
 //      else res = false;
 //      return res;
 //    }
 //    private RX_Res_T RX_TELEGRAM(object PcdPort, out MBUS_message Rxmsg, bool GetResponse)
 //    {
 //      BaseStation.TResult getcharres = 0, getcharres2 = 0;
 //      BaseStation.RX_Res_T res;
 //      byte lastChar;
 //      Rxmsg = (MBUS_message)pool.GetEmptyISesDBuffer();
 //      getcharres = r_t_s.GetChar(out lastChar,PcdPort,GetResponse);
 //      if(getcharres == BaseStation.TResult.Success)
 //      {
 //        while(getcharres2!=BaseStation.TResult.Timeout35)
 //        {
 //          Rxmsg.WriteByte(lastChar);
 //          getcharres2 = r_t_s.GetChar(out lastChar,PcdPort);
 //          if(getcharres2 == BaseStation.TResult.Timeout15)
 //          {
 //            Rxmsg = null;
 //            return BaseStation.RX_Res_T.RX_INVALID;
 //          }
 //        }//end while
 //        if(Rxmsg.CheckRequestFrame()== Modbus_Exceptions.OK) res = BaseStation.RX_Res_T.RX_OK;
 //        else res = BaseStation.RX_Res_T.RX_INVALID;
 //      }//end if
 //      res = BaseStation.RX_Res_T.RX_INVALID;
 //      return res;
 //
 //    }//RX_TELEGRAM
 //
 internal ModBus_ApplicationLayerSlave(ICommunicationLayer cCommChannel)
     : base(cCommChannel)
 {
     //      pool = new MODBUS_buf_pool();
 }
Exemple #20
0
 /// <summary>
 /// Creates the application layer master.
 /// </summary>
 /// <param name="pStatistic">The statistic.</param>
 /// <param name="pCommLayer">The communication layer.</param>
 /// <param name="pErrorFrequency">The error frequency.</param>
 /// <returns>IApplicationLayerMaster</returns>
 public IApplicationLayerMaster CreateApplicationLayerMaster
     (CAS.Lib.RTLib.Management.IProtocolParent pStatistic, ICommunicationLayer pCommLayer, int pErrorFrequency)
 {
     return(new ApplicationLayerMaster(pStatistic, pCommLayer, pErrorFrequency));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalDatasetDistributor"/> class.
        /// </summary>
        /// <param name="localDistributor">The object that handles distribution proposals for the local machine.</param>
        /// <param name="loader">The object that handles the actual starting of the dataset application.</param>
        /// <param name="commandHub">The object that sends commands to remote endpoints.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks on.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localDistributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="loader"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public LocalDatasetDistributor(
            ICalculateDistributionParameters localDistributor,
            IDatasetActivator loader,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func<DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Enforce.Argument(() => localDistributor);
                Enforce.Argument(() => loader);
                Enforce.Argument(() => commandHub);
                Enforce.Argument(() => notificationHub);
                Enforce.Argument(() => datasetInformationBuilder);
                Enforce.Argument(() => communicationLayer);
                Enforce.Argument(() => systemDiagnostics);
            }

            m_LocalDistributor = localDistributor;
            m_Loader = loader;
            m_CommandHub = commandHub;
            m_NotificationHub = notificationHub;
            m_Uploads = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer = communicationLayer;
            m_Diagnostics = systemDiagnostics;
            m_Scheduler = scheduler ?? TaskScheduler.Default;
        }
 protected abstract TModbusProtocol CreateModBusProtocol(ICommunicationLayer communicationLayer, TProtocolParameters parameters, IProtocolParent protocolParent, SesDBufferPool <TModbusMessage> pool);
Exemple #23
0
 //string IApplicationLayerPluginHelper.Name
 //{
 //  get
 //  {
 //    return "Symulator sieci cieplnej EC2- EC3";
 //  }
 //}
 //string IApplicationLayerPluginHelper.Author
 //{
 //  get
 //  {
 //    return "CAS Mariusz Postó³";
 //  }
 //}
 //string IApplicationLayerPluginHelper.Description
 //{
 //  get
 //  {
 //    return "NULLBUS protocol (master side) implementation for Commserver - virtual protocol for tests and simulations";
 //  }
 //}
 //Version IApplicationLayerPluginHelper.Version
 //{
 //  get
 //  {
 //    return new Version( 2, 0 );
 //  }
 //}
 //DateTime IApplicationLayerPluginHelper.Date
 //{
 //  get
 //  {
 //    return new DateTime( 2005, 01, 01 );//MZTD: Ew. sprawdzic i wstawic prawdziwa date
 //  }
 //}
 //int IApplicationLayerPluginHelper.Identifier
 //{
 //  get
 //  {
 //    return 4;
 //  }
 //}
 //IApplicationLayerMaster IApplicationLayerPluginHelperMaster.GetApplicationLayerMaster
 //  ( ICommunicationLayerFactory cCommFactory, ProtocolParameters myProtParameters, BaseStation.Management.IProtocolParent Statistic )
 //{
 //  return new NULL_ApplicationLayerMaster( cCommFactory, myProtParameters, Statistic );
 //}
 /// <summary>
 /// This fuction create simulator (application layer)
 /// </summary>
 /// <param name="pStatistic"></param>
 /// <param name="pComm"></param>
 /// <param name="pErrorFrequency"></param>
 /// <returns></returns>
 public IApplicationLayerMaster CreateApplicationLayerMaster
     (IProtocolParent pStatistic, ICommunicationLayer pComm, int pErrorFrequency)
 {
     return(new NULL_ApplicationLayerMaster(pStatistic, pComm, pErrorFrequency));
 }
 public ModBusProtocol(ICommunicationLayer pCommLayer, ProtocolParameters pProtParameters, RTLib.Management.IProtocolParent pStatistic, SesDBufferPool <ModBusMessage> pPool) :
     base(pCommLayer, pProtParameters, pStatistic, pPool)
 {
 }
        /// <summary>
        /// Creates the application layer master.
        /// </summary>
        /// <param name="statistic">The statistic.</param>
        /// <param name="pCommLayer">The communication layer.</param>
        /// <param name="protocolParameters">The protocol parameters.</param>
        /// <returns></returns>
        /// <exception cref="System.ComponentModel.LicenseException">The type is licensed, but a <see cref="License"/> cannot be granted.</exception>
        public IApplicationLayerMaster CreateApplicationLayerMaster(IProtocolParent statistic, ICommunicationLayer communicationLayer, TProtocolParameters protocolParameters)
        {
            m_Pool = new PrivateBufferPool(protocolParameters, CreateModBusMessage);
            TModbusProtocol mp = CreateModBusProtocol(communicationLayer, protocolParameters, statistic, m_Pool);

            return(CreateModBus_ApplicationLayerMaster(m_Pool, mp));
        }
Exemple #26
0
 /// <summary>
 /// Creates the application layer sniffer.
 /// </summary>
 /// <param name="pCommLayer">The communication layer.</param>
 /// <param name="pProtParameters">The protocol parameters.</param>
 /// <param name="pStatistic">The  statistic.</param>
 /// <returns>IApplicationLayerSlave</returns>
 public IApplicationLayerSniffer CreateApplicationLayerSniffer
     (ICommunicationLayer pCommLayer, ProtocolParameters pProtParameters, IProtocolParent pStatistic)
 {
     throw new ApplicationLayerInterfaceNotImplementedException();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteDatasetDistributor"/> class.
        /// </summary>
        /// <param name="configuration">The application specific configuration.</param>
        /// <param name="commandHub">The object that manages the remote command proxies.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RemoteDatasetDistributor(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func<DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Lokad.Enforce.Argument(() => commandHub);
                Lokad.Enforce.Argument(() => notificationHub);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => datasetInformationBuilder);
                Lokad.Enforce.Argument(() => communicationLayer);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Configuration = configuration;
            m_Uploads = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer = communicationLayer;
            m_Diagnostics = systemDiagnostics;
            m_Scheduler = scheduler ?? TaskScheduler.Default;
            m_CommandHub = commandHub;
            {
                // Set up the events so that we can see the loaders come online.
                //
                // Note that the events may come in on a different thread than the one
                // we're normally accessed on. This is because adding an enpoint is usually
                // a result of a WCF message being received, on the WCF message thread.
                m_CommandHub.OnEndpointSignedIn += (s, e) => AddNewEndpoint(e.Endpoint, e.Commands);
                m_CommandHub.OnEndpointSignedOff += (s, e) => RemoveEndpoint(e.Endpoint);

                var knownCommands = m_CommandHub.AvailableCommands();
                foreach (var command in knownCommands)
                {
                    AddNewEndpoint(command.Endpoint, command.RegisteredCommands);
                }
            }

            m_NotificationHub = notificationHub;
        }