Exemple #1
0
        /// <summary>
        /// InitializeSystem - this method gets called after the constructor
        /// has finished.
        ///
        /// Use InitializeSystem to:
        /// * Start threads
        /// * Configure ports, such as serial and verisports
        /// * Start and initialize socket connections
        /// Send initial device configurations
        ///
        /// Please be aware that InitializeSystem needs to exit quickly also;
        /// if it doesn't exit in time, the SIMPL#Pro program will exit.
        /// </summary>
        public override void InitializeSystem()
        {
            try
            {
                if (PinAuthenticationProvider.Initialize() == PinAuthenticationProvider.InitializationSuccessFailureReason.ConfigFileNotFound)
                {
                    PinAuthenticationProvider.CreateNewConfig();
                }
                pinAuthProvider = PinAuthenticationProvider.GetInstance();

                SmartObjectDynamicButtonIconListHelper smartObjectDynamicButtonIconListHelper = new SmartObjectDynamicButtonIconListHelper(xPanel.SmartObjects[smartObjectDynamicListHelperParameters.Id], smartObjectDynamicListHelperParameters);
                smartObjectDynamicButtonIconListHelper.NumberOfItems = (ushort)ActionsManager.GetActions().Length;
                uint actionId = 0;
                foreach (string actionName in ActionsManager.GetActions())
                {
                    actionId++;
                    string actionNameFix = actionName;
                    smartObjectDynamicButtonIconListHelper.Items[actionId].Enable        = true;
                    smartObjectDynamicButtonIconListHelper.Items[actionId].Visible       = true;
                    smartObjectDynamicButtonIconListHelper.Items[actionId].Text          = actionNameFix;
                    smartObjectDynamicButtonIconListHelper.Items[actionId].PressedAction = new Action <bool>(x => { if (!x)
                                                                                                                    {
                                                                                                                        ActionsManager.InvokeAction(actionNameFix);
                                                                                                                    }
                                                                                                             });
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }