コード例 #1
0
        internal CMProxy(RegistrationRequest request)
        {
            var appconfig = AppDomain.CurrentDomain.UnityContainer().Resolve <AbstractAppConfig>();

            Info = new CMProxyInfo(request, this);

            var config = appconfig.PanelConfigs(COFFE_MACHINE);

            config.Title = request.un;
            Dashboard.Sgt.CreateDynamicPanel(request.un, config);
            Dashboard.Sgt.AddFixedLinesToDynamicPanel(request.un, appconfig.PanelFixedLines(COFFE_MACHINE));
            ChangeEvent += Dashboard.Sgt.UpdateEventHandlerOfPanel(request.un);

            DisabledState   = new CMProxyStateDisabled(this);
            EnabledState    = new CMProxyStateEnabled(this);
            ProcessingState = new CMProxyStateProcessing(this);
            CurrentState    = EnabledState;
            _disableFlag    = false;

            Info.Enabled      = true;
            Info.MakingCoffee = false;

            Cookbook = new ProxyCookBook(this);
            Cookbook.GetRecipesFromMainCookbook();
            Waitress = new Waitress(this);

            Subscribe(Waitress);
            Subscribe(CMProxyHub.Sgt);
        }
コード例 #2
0
 internal void Unregister(string mac)
 {
     lock (_proxies)
     {
         if (!_proxies.ContainsKey(mac))
         {
             return;
         }
         else
         {
             var proxy      = GetProxy(mac);
             var uniqueName = proxy.Info.UniqueName;
             Waitress.DeleteWaitress(mac);
             _proxies.Remove(mac);
             _selectedCMIndex = 0;
             Dashboard.Sgt.DeleteDynamicPanel(uniqueName);
             Dashboard.Sgt.LogAsync($"Coffee machine {uniqueName} has been unregistered.");
         }
     }
 }