コード例 #1
0
 internal bool RegisterNamedComponent(Component _component)
 {
     try
     {
         lock (Components)
         {
             if (!Components.ContainsKey(_component))
             {
                 Components.Add(_component, new InternalEvents());
                 this.SendDebug(string.Format("Adding named component {0}", _component.Name));
                 if (isInitialized && IsConnected)
                 {
                     AddComponentToChangeGroup addComponent;
                     addComponent                           = new AddComponentToChangeGroup();
                     addComponent.method                    = "ChangeGroup.AddComponentControl";
                     addComponent.ComponentParams           = new AddComponentToChangeGroupParams();
                     addComponent.ComponentParams.Component = _component;
                     this.SendDebug(string.Format("Adding named component: {0} to core change group", _component.Name));
                     this.commandQueue.Enqueue(JsonConvert.SerializeObject(addComponent));
                 }
                 return(true);
             }
             else
             {
                 this.SendDebug(string.Format("Failed to add named component as it alreadt exists: {0}", _component.Name));
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         ErrorLog.Error("Error registering Named Component to the Qsys Core {0} : {1}", this.coreID, e.Message);
         return(false);
     }
 }
コード例 #2
0
        private void CoreModuleInit()
        {
            //Send login if needed
            if (this.loginUser.Length > 0 && this.loginPass.Length > 0)
            {
                this.SendLogin();
            }

            this.heartbeatTimer = new CTimer(SendHeartbeat, null, 0, 15000);

            this.SendDebug("Initialized");
            this.isInitialized = true;

            foreach (var item in this.SimplClients)
            {
                item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRegistered, (SimplSharpString)"true", 1));
                item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, (SimplSharpString)"true", 1));
            }

            this.SendDebug("Requesting all named components and controls");
            this.commandQueue.Enqueue(JsonConvert.SerializeObject(new GetComponents()));

            if (Controls.Count() > 0)
            {
                AddControlToChangeGroup addControls;
                addControls                        = new AddControlToChangeGroup();
                addControls.method                 = "ChangeGroup.AddControl";
                addControls.ControlParams          = new AddControlToChangeGroupParams();
                addControls.ControlParams.Controls = new List <string>();
                foreach (var item in Controls)
                {
                    addControls.ControlParams.Controls.Add(item.Key);
                    this.SendDebug(string.Format("Adding named control: {0} to change group", item.Key));
                }
                this.commandQueue.Enqueue(JsonConvert.SerializeObject(addControls));
            }

            if (Components.Count() > 0)
            {
                AddComponentToChangeGroup addComponents;
                foreach (var item in Components)
                {
                    addComponents                           = new AddComponentToChangeGroup();
                    addComponents.method                    = "ChangeGroup.AddComponentControl";
                    addComponents.ComponentParams           = new AddComponentToChangeGroupParams();
                    addComponents.ComponentParams.Component = item.Key;
                    this.SendDebug(string.Format("Adding named component: {0} to change group", item.Key));
                    commandQueue.Enqueue(JsonConvert.SerializeObject(addComponents));
                }
            }
        }