Ejemplo n.º 1
0
        private async Task <string> Depart(IVessel vessel, string vesselName, DateTime ts)
        {
            var wait = await vessel.GetTicksToWait();

            if (wait == 0)
            {
                var r          = new Random();
                int routeIndex = r.Next(0, routes.Count - 1);
                await vessel.SetRoute(routes[routeIndex]);

                AssignAllocationAsync(vessel, ts);
                var obj = new IntakeEventModel();
                obj.VesselCode    = vesselName;
                obj.DepartureDate = ts;
                obj.Intake        = await vessel.GetCapacity();

                await new KafkaProducer().SendToKafka(JsonConvert.SerializeObject(obj), "intake");
                await vessel.Depart(ts);

                await vessel.ResetDistanceOnRoute();

                return(vesselName);
            }
            else
            {
                //_logger.LogInformation(vesselName+" Waiting");
                var i = wait - 1;
                await vessel.SetTicksToWait(i);
            }

            return("");
        }
Ejemplo n.º 2
0
 public MainControl()
 {
     this.InitializeComponent();
     this.DataContextChanged += MainControl_DataContextChanged;
     _vessel              = ((App)App.Current).Vessel;
     _vessel.VesselEvent += _vessel_VesselEvent;
     _blinker             = new Blinker();
 }
Ejemplo n.º 3
0
        public const double InitialTemperature  = 273; //В Кельвинах

        public DiffEq(ParamFi paramFi, DichotomyDensity dichotomyDensity,
                      PneumaticParams pneumaticParams, IVessel vesselOne, IVessel vesselTwo)
        {
            _paramFi          = paramFi;
            _dichotomyDensity = dichotomyDensity;
            _pneumaticParams  = pneumaticParams;
            _vesselOne        = vesselOne;
            _vesselTwo        = vesselTwo;
        }
Ejemplo n.º 4
0
 public MainController()
 {
     _emergencyButton             = new EmergencyButtonDummy();// EmergencyButton();
     _vessel                      = ((App)App.Current).Vessel;
     _vessel.VesselEvent         += _vessel_VesselEvent;
     _stepController              = new StepController(_vessel, _emergencyButton);
     _stepController.StepEvent   += _stepController_StepEvent;
     _stepController.StepReached += _stepController_StepReached;
     _logUpdateTimer.Elapsed     += _logUpdateTimer_Elapsed;
     //_brewingViewModel = brewingViewModel;
 }
Ejemplo n.º 5
0
        public StepController(IVessel vessel, IEmergencyButton emergencyButton)
        {
            _vessel = vessel;
            //_vessel.VesselEvent += _vessel_VesselEvent;
            _vessel.TargetTemperaturReached += _vessel_TargetTemperaturReached;
            _emergencyButton = emergencyButton;

            if (_vessel is IEmergency)
            {
                _emergencyButton.ButtonPressed  += (_vessel as IEmergency).SetEmergencyStop;
                _emergencyButton.ButtonReleased += (_vessel as IEmergency).ResetEmergencyStop;
            }
            _updateTimer.Elapsed  += _updateTimer_Elapsed;
            _updateTimer.AutoReset = true;
            _stepTimer.Elapsed    += Timer_Elapsed;
            _stepTimer.AutoReset   = false;
        }
Ejemplo n.º 6
0
        public async Task AssignAllocationAsync(IVessel v, DateTime ts)
        {
            int capacity = await v.GetCapacity();

            var r                    = new Random();
            var range                = r.Next(80, 120);
            var percentage           = range / 100f;
            var percentagePerCompany = percentage / 3f;

            var companies = Configuration.Constants.Companies.OrderBy(x => r.Next()).Take(3);

            foreach (var c in companies)
            {
                var a = (int)Math.Round(capacity * percentagePerCompany);
                await v.AddAllocationToVessel(a, c, ts);
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            //注册通道
            TcpClientChannel channel = new TcpClientChannel();

            ChannelServices.RegisterChannel(channel, true);

            talkerClient = (ITalker)Activator.GetObject(
                typeof(ITalker), "tcp://localhost:8090/Talker");
            Console.WriteLine("talker 远程对象激活成功。!");

            vessel = (IVessel)Activator.GetObject(
                typeof(IVessel), "tcp://localhost:8091/H3BPMSERVER");
            Console.WriteLine("vessel 远程对象激活成功。!");

            while (true)
            {
                Console.WriteLine("1,直接执行简单Remoting调用。");
                Console.WriteLine("2,执行复杂Remoting调用。");

                string keyboard = Console.ReadLine();

                switch (keyboard)
                {
                case "1":
                    InvokeRemoting();
                    break;

                case "2":
                    InvokeH3Remoting();
                    break;

                default:
                    break;
                }
            }
        }
 public void Add(IVessel vessel)
 {
     m_Vessel.Add(vessel);
 }
Ejemplo n.º 9
0
 public void AddVessel(IVessel vessel)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 构造器初始化Vessel对象
 /// </summary>
 /// <param name="vessel"></param>
 public AppManagerClient(IVessel vessel)
 {
     this.vessel = vessel;
 }
Ejemplo n.º 11
0
 public void Add(IVessel vessel)
 {
     m_Vessel.Add(vessel);
 }
Ejemplo n.º 12
0
 public Placement(IVessel vessel, Coordinate coord, Orientation orientation)
     : this(vessel, coord.X, coord.Y, orientation)
 {
 }
Ejemplo n.º 13
0
 public Placement(IVessel vessel, int x, int y, Orientation orientation)
     : base(x, y)
 {
     _vessel = vessel;
     _orientation = orientation;
 }