示例#1
0
        public Palletiser(ClusterConfig config)
            : base(config)
        {
            _palletiserRobot = config.Robots[typeof(PalletiserRobot)] as PalletiserRobot;

            if (_palletiserRobot == null)
            {
                throw new ArgumentException("Could not retrieve a PalletiserRobot from ClusterConfig");
            }
        }
示例#2
0
 public TrayVerifier(ClusterConfig config)
     : base(config)
 {
     ICamera c;
     if (config.Cameras.TryGetValue(CameraName, out c))
     {
         _trayDetector = new TrayDetectorVision(c as Camera);
     }
     else
     {
         throw new ArgumentException("Unable to get " + CameraName + "from ClusterConfig");
     }
 }
示例#3
0
        public ConveyorController(ClusterConfig config)
            : base(config)
        {
            _serialConveyor = config.Conveyors[typeof(SerialConveyor)] as SerialConveyor;
            _bluetoothConveyor = config.Conveyors[typeof(BluetoothConveyor)] as BluetoothConveyor;

            _conveyorTypeMap = new Dictionary<ConveyorType, IConveyor>()
            {
                {ConveyorType.Sorting, _bluetoothConveyor},
                {ConveyorType.Assembly, _serialConveyor}
            };

            _actionMap = new Dictionary<ConveyorAction, Action<IConveyor>>()
            {
                {ConveyorAction.MoveForward, x => x.MoveForward() },
                {ConveyorAction.MoveBackward, x => x.MoveBackward() }
            };
        }
示例#4
0
        public Assembler(ClusterConfig config)
            : base(config)
        {
            _assemblerRobot = config.Robots[typeof(AssemblerRobot)] as AssemblerRobot;
            this._cancelTokenSource = new CancellationTokenSource();
            this.LastOrderTray = null;

            if (_assemblerRobot == null)
            {
                throw new ArgumentException("Could not retrieve a AssemblerRobot from ClusterConfig");
            }

            _actionMap = new Dictionary<AssemblerAction, Action<AssemblerParams>>()
            {
                { AssemblerAction.Assemble, (x) => AssembleAsync(x.Magazine, x.OrderConfiguration) },
                { AssemblerAction.GetTabletMagazine, (x) => GetTabletMagazineAsync() },
                { AssemblerAction.ReturnTabletMagazine, (x) => ReturnTabletMagazineAsync() }
            };
        }
示例#5
0
        public HardwareMonitor(ClusterConfig config)
        {
            _hardware = config.GetAllHardware();
            int updateTime = 1000;

            PreviousHardwareStatuses = new Dictionary<string, HardwareStatus>();

            if (!Int32.TryParse(ConfigurationManager.AppSettings["HardwareMonitorUpdateRateMsec"], out updateTime))
            {
                Logger.Instance.Write(new LogEntry("HardwareMonitorUpdateRateMsec is invalid, defaulting to 1000 msec",
                    LogType.Warning));
            }
            this._updateTimer = new Timer(updateTime);
            this._updateTimer.Elapsed += new ElapsedEventHandler((s, e) => this.Update());

            foreach (var hw in _hardware)
            {
                PreviousHardwareStatuses.Add(hw.Name, HardwareStatus.Offline);
            }
        }
示例#6
0
文件: Loader.cs 项目: jack06215/tmc
        public Loader(ClusterConfig config)
            : base(config)
        {
            _actionMap = new Dictionary<LoaderAction, Action>
            {
                { LoaderAction.LoadToConveyor, () => LoadToConveyorAsync() },
                { LoaderAction.LoadToPalletiser, () => LoadToPalletiserAsync() }
            };

            _loaderRobot = config.Robots[typeof(LoaderRobot)] as LoaderRobot;
            _traySensor = config.Plcs["MainPlc"] as IPlc;
            _traySwitchMap = CreateTraySwitchMap();

            if (_loaderRobot == null)
            {
                throw new ArgumentException("Could not retrieve a LoaderRobot from ClusterConfig");
            }
            if (_traySensor == null)
            {
                throw new ArgumentException("Could not retrieve a Plc from ClusterConfig");
            }
        }
示例#7
0
文件: Sorter.cs 项目: jack06215/tmc
        public Sorter(ClusterConfig config)
            : base(config)
        {
            this.MaxShakeRetryAttempts = 1;
            this._vision = new SorterVision(config.Cameras["SorterCamera"] as Camera);
            this._robot = config.Robots[typeof(SorterRobot)] as SorterRobot;
            this._cancelTokenSource = new CancellationTokenSource();

            if (_vision == null)
            {
                throw new ArgumentException("Could not create SorterVision");
            }
            if (_robot == null)
            {
                throw new ArgumentException("Could not retrieve a SorterRobot from ClusterConfig");
            }

            _actionMap = new Dictionary<SorterAction, Action<SorterParams>>()
            {
                { SorterAction.LoadToBuffer, (x) => LoadToBufferAsync() },
                { SorterAction.LoadToConveyor, (x) => LoadToConveyorAsync() },
                { SorterAction.Sort, (x) => SortAsync(x.Magazine) }
            };
        }
示例#8
0
        private Dictionary<Type, IController> CreateControllers(ClusterConfig config)
        {
            var controllers = new Dictionary<Type, IController>();

            controllers.Add(typeof(Assembler), new Assembler(config));
            controllers.Add(typeof(ConveyorController), new ConveyorController(config));
            controllers.Add(typeof(Loader), new Loader(config));
            controllers.Add(typeof(Sorter), new Sorter(config));
            controllers.Add(typeof(TrayVerifier), new TrayVerifier(config));

            return controllers;
        }
示例#9
0
        private ClusterConfig CreateClusterConfig(ClusterTemplate template)
        {
            ClusterConfig config = new ClusterConfig();

            foreach (var hwTemplate in template.Hardware)
            {
                var hw = CreateHardware(hwTemplate.Type);

                try
                {
                    hw.SetParameters(hwTemplate.Parameters);
                    Logger.Instance.Write(String.Format("[ClusterFactory] Initializing {0}", hw.Name), LogType.Message);
                    hw.Initialise();
                }
                catch(Exception ex)
                {
                    var outer = new InvalidOperationException(
                        String.Format("Failed to initialise hardware item Type: {0}, Name: {1}",
                        hw.GetType().ToString(), hw.Name), ex);

                    Logger.Instance.Write(new LogEntry(outer));
                    throw outer;
                }

                if (hw is IRobot)
                {
                    config.Robots.Add(hw.GetType(), hw as IRobot);
                }
                else if (hw is IConveyor)
                {
                    config.Conveyors.Add(hw.GetType(), hw as IConveyor);
                }
                else if (hw is ISensor)
                {
                    config.Sensors.Add(hw.Name, hw as ISensor);
                }
                else if (hw is ICamera)
                {
                    config.Cameras.Add(hw.Name, hw as ICamera);
                }
                else if (hw is IPlc)
                {
                    config.Plcs.Add(hw.Name, hw as IPlc);
                }

                Logger.Instance.Write(String.Format("[ClusterFactory] {0} initialization completed", hw.Name), LogType.Message);
            }

            config.Controllers = CreateControllers(config);

            return config;
        }
示例#10
0
 public ControllerBase(ClusterConfig _config)
 {
     this._config = _config;
     this.IsRunning = false;
 }