Exemple #1
0
        /// <summary>
        /// Adds a new adapter to the access.
        /// </summary>
        /// <param name="adapter"></param>
        public void AddAdapter(MAdapterDescription description, MMIAdapter.Iface adapter)
        {
            IAdapter newAdapter = new LocalAdapterAccess(description, adapter, this);

            //Check if the adapter is already available as a remote one
            if (this.Adapters.Exists(s => s.Description.Name == description.Name && description.Addresses[0] == description.Addresses[0] && s.Description.Addresses[0].Port == description.Addresses[0].Port))
            {
                //Find the old adapter
                IAdapter oldAdapter = this.Adapters.Find(s => s.Description.Name == description.Name && description.Addresses[0] == description.Addresses[0] && s.Description.Addresses[0].Port == description.Addresses[0].Port);

                //Find MMUs which utilize the old adapter
                List <Abstraction.MotionModelUnitAccess> mmusWithOldAdapter = this.MotionModelUnits.Where(s => ((Abstraction.MotionModelUnitAccess)s).Adapter == oldAdapter).Select(s => ((Abstraction.MotionModelUnitAccess)s)).ToList();

                //Change the adapter to the new one
                foreach (Abstraction.MotionModelUnitAccess mmu in mmusWithOldAdapter)
                {
                    mmu.ChangeAdapter(newAdapter);
                }

                //Disposes the adapter
                oldAdapter.Dispose();

                //Remove the old adapter
                this.Adapters.Remove(oldAdapter);
            }

            //Add the new adapter
            this.Adapters.Add(newAdapter);
        }
        /// <summary>
        /// Basic constructor
        /// </summary>
        /// <param name="description">The adapter description. The first address in  the Addressed field is used for hosting the server.</param>
        /// <param name="mmiRegisterAddress">The address of the register (where all services, adapters and mmus are registered)</param>
        /// <param name="mmuPath">The path where the MMUs are located</param>
        /// <param name="mmuProvider">A class which provides information regarding the available MMUs</param>
        /// <param name="mmuInstantiatior">A class which can instantiate MMUs based on the file and description</param>
        /// <param name="customAdapterImplementation">An optionally specified customAdapterImplementation which is utilized instead of the default one</param>
        public AdapterController(SessionData sessionData, MAdapterDescription description, MIPAddress mmiRegisterAddress, IMMUProvider mmuProvider, IMMUInstantiation mmuInstantiatior, MMIAdapter.Iface customAdapterImplementation = null)
        {
            //Assign the session data
            this.SessionData = sessionData;

            //Is the default implementation if not explicitly set
            if (customAdapterImplementation == null)
            {
                this.adapterImplementation = new ThriftAdapterImplementation(sessionData, mmuInstantiatior);
            }
            else
            {
                this.adapterImplementation = customAdapterImplementation;
            }

            //Assign the adapter implementation instance
            SessionData.AdapterInstance = this.adapterImplementation;

            //Assign the mmu instantiator
            this.mmuInstantiator = mmuInstantiatior;
            this.mmuProvider     = mmuProvider;

            //Assign the adapter description
            this.adapterDescription        = description;
            SessionData.AdapterDescription = description;

            //Assign the addresses
            this.address            = description.Addresses[0];
            this.mmiRegisterAddress = mmiRegisterAddress;

            //Assign the MMI register address
            SessionData.MMIRegisterAddress = mmiRegisterAddress;

            //Register on changed event
            this.mmuProvider.MMUsChanged += MmuProvider_MMUsChanged;
        }
Exemple #3
0
 /// <summary>
 /// Constructor to create a new server
 /// </summary>
 /// <param name="address"></param>
 /// <param name="port"></param>
 /// <param name="implementation"></param>
 public AdapterServer(string address, int port, MMIAdapter.Iface implementation)
 {
     this.address        = address;
     this.port           = port;
     this.implementation = implementation;
 }
Exemple #4
0
 /// <summary>
 /// Basic constructor
 /// </summary>
 /// <param name="address"></param>
 /// <param name="port"></param>
 public RemoteAdapterClient(string address, int port)
 {
     this.thriftClient = new AdapterClient(address, port);
     this.Access       = thriftClient.Access;
 }
Exemple #5
0
 /// <summary>
 /// Basic constructor
 /// </summary>
 /// <param name="description"></param>
 /// <param name="instance"></param>
 public LocalAdapterAccess(MAdapterDescription description, MMIAdapter.Iface instance, MMUAccess mmuAccess)
 {
     this.Description = description;
     this.instance    = instance;
     this.mmuAccess   = mmuAccess;
 }
Exemple #6
0
 public LocalAdapterClient(MMIAdapter.Iface instance)
 {
     this.Access = instance;
 }