Exemplo n.º 1
0
        private void btnLoad_Click(object sender, System.EventArgs e)
        {
            if (lstCustomUsers.ContainsItemByTag(mySelectedActionContext) ||
                lstPresetUsers.ContainsItemByTag(mySelectedActionContext))
            {
                myCurrentActionContext = mySelectedActionContext;

                Enabled = false;

                // Reload protocols in a thread
                myReloadProtocolsThread = new Thread(new ThreadStart(this.ReloadProtocolsThread));
                myReloadProtocolsThread.IsBackground = true;
                myReloadProtocolsThread.Start();


                myRoboSepWaitForm.ShowDialog();
                //System.Threading.Thread.Sleep(2000);
                SeparatorGateway.GetInstance().Connect(false);
                //System.Threading.Thread.Sleep(2000);



                Enabled = true;
            }
            else
            {
                MessageBox.Show(this, "Please select a Custom User or a Preset User first.");
            }
        }
        private void AttemptSeparatorConnection()
        {
            try
            {
                // Initialise the Separator connection
                mySeparatorGateway.InitialiseConnection(myCultureInfo);

                mySeparator = SeparatorGateway.GetInstance().ControlApi;
                myEventSink = SeparatorGateway.GetInstance().EventsApi;

                if (myEventSink != null)
                {
                    myEventSink.ReportInstrumentInformation += new Tesla.Separator.ReportInstrumentInfoDelegate(AtReportInstrumentInformation);
                }

                // Actually connect the UI to the Separator server
                mySeparatorGateway.Connect(true);
            }


            catch (ApplicationException /*aex*/)
            {
                // Allow application exceptions to propagate upwards.  That is, if the
                // InitialiseConnection times out, we use the generated ApplicationException
                // to trigger application shutdown.
            }
            catch (Exception ex)
            {
                LogFile.LogException(System.Diagnostics.TraceLevel.Error, ex);
            }
        }
Exemplo n.º 3
0
 private void ReloadProtocolsThread()
 {
     SaveUserConfig();
     System.Threading.Thread.Sleep(1000);
     SeparatorGateway.GetInstance().ReloadProtocols();
     //SeparatorGateway.GetInstance().Disconnect(false);
     //System.Threading.Thread.Sleep(3000);
     //SeparatorGateway.GetInstance().Connect(false);
     //SeparatorGateway.GetInstance().Connect(true);
     //System.Threading.Thread.Sleep(1000);
 }
        public void StartLoadingProtocolsToServer(string ActiveUser, List <RoboSep_Protocol> tempList)
        {
            if (tempList == null)
            {
                return;
            }

            // LOG
            string logMSG = "Start thread for loading profile";

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            try
            {
                RoboSep_UserConsole.strCurrentUser = ActiveUser;// textBox_UserName.Text;
                UserNameHeader.Text = ActiveUser;

                string[] sProtocols = new string[tempList.Count];
                for (int i = 0; i < tempList.Count; i++)
                {
                    sProtocols[i] = tempList[i].Protocol_FileName;
                }

                // save over user1.udb
                RoboSep_UserDB.getInstance().XML_SaveUserProfile(ActiveUser, sProtocols);
                protocolsToLoad = sProtocols.Length;

                // Reload protocols with SeparatorGateway using a thread
                myReloadProtocolsThread = new Thread(new ThreadStart(this.ReloadProtocolsThread));
                myReloadProtocolsThread.IsBackground = true;
                myReloadProtocolsThread.Start();

                // set sep-gateway to updating Separator Protocols
                // so that we can watch for when it is updated
                // (in timer_tick)
                SeparatorGateway.GetInstance().separatorUpdating = true;

                string sMSG   = LanguageINI.GetString("msgLoadingProtocols");
                string sTitle = LanguageINI.GetString("headerLoadingUserProtocols");
                loading = new RoboMessagePanel5(RoboSep_UserConsole.getInstance(), sTitle, sMSG, GUI_Controls.GifAnimationMode.eUploadingMultipleFiles);
                RoboSep_UserConsole.showOverlay();
                loading.Show();
                //Thread.Sleep(SERVER_WAIT_TIME);
                // add loop to that polls loading status
                LoadUserTimer.Start();
            }
            catch (Exception ex)
            {
                // LOG
                logMSG = "Failed to save user to server";

                LogFile.AddMessage(System.Diagnostics.TraceLevel.Error, logMSG);
            }
        }
        public FrmCWJMain()
        {
//            CheckForIllegalCrossThreadCalls = false;

            mySeparatorGateway = SeparatorGateway.GetInstance();
            myCultureInfo      = new CultureInfo("en-US", true);

            InitializeComponent();

            Thread.CurrentThread.CurrentCulture   = myCultureInfo;      // Set culture for formatting
            Thread.CurrentThread.CurrentUICulture = myCultureInfo;      // Set culture for UI resources

            m_Timer.Interval = 500;
            m_Timer.Enabled  = false;
        }
Exemplo n.º 6
0
        public UserProfileSubPage()
            : base(RoboSepSubPage.MdiChild.UserProfile)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            // Initialise fixed text
            this.Text = "Profile";

            btnUpdate.Text   = "Modify/Update";
            btnUpdate.Role   = RoboSepButton.ButtonRole.OK;
            btnLoad.Text     = "Load";
            btnLoad.Role     = RoboSepButton.ButtonRole.OK;
            btnProtocol.Text = "Protocol List";
            btnProtocol.Role = RoboSepButton.ButtonRole.Warning;
            btnEditor.Text   = "Protocol Editor";
            btnEditor.Role   = RoboSepButton.ButtonRole.Warning;

            pnlCustomUsers.Text = "Custom Users";
            pnlPresetUsers.Text = "Preset Protocol Databases";

            // Initialise colour scheme
            Color activeSubPageBackground = ColourScheme.GetColour(ColourSchemeItem.ActiveSubPageBackground);

            pnlCustomUsers.BackColor = activeSubPageBackground;
            pnlPresetUsers.BackColor = activeSubPageBackground;

            pnlCustomUsers.FillColor = ColourScheme.GetColour(ColourSchemeItem.NamedAreaStandardBackground);
            lstCustomUsers.BackColor = pnlCustomUsers.FillColor;
            pnlPresetUsers.FillColor = pnlCustomUsers.FillColor;
            lstPresetUsers.BackColor = pnlCustomUsers.FillColor;

            LoadCustomUsers();
            LoadPresetUsers();

            LoadCurrentUser();

            SeparatorGateway.GetInstance().UpdateChosenProtocolTable += new SampleTableDelegate(AtUpdateChosenProtocolTableUpdate);
            //SeparatorGateway.GetInstance()
            //myCurrentActionContext = listPresetUsersItems[0].Tag;

            myRoboSepWaitForm = new RoboSepWaitForm();
        }
        private void SelectUser(string UserLogin)
        {
            if (string.IsNullOrEmpty(UserLogin))
            {
                return;
            }

            string usrName = UserLogin;

            RoboSep_UserConsole.strCurrentUser = usrName;

#if false
            // load user preferences
            RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);

            // load user protocols
            List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(usrName);

            // it could be new user with no protocols
            if (tempList != null && tempList.Count > 0)
            {
                // load user protocols
                RoboSep_Protocols.getInstance().LoadUserToServer(usrName);
                RoboSep_Protocols.getInstance().setProtocolLoading(true);
                SeparatorGateway.GetInstance().separatorUpdating = true;

                if (evhHandleUserProtocolsReloaded == null)
                {
                    evhHandleUserProtocolsReloaded = new EventHandler(HandleUserProtocolsReloadedBeforeExiting);
                }

                RoboSep_UserConsole.getInstance().NotifyUserSeparationProtocolsUpdated += evhHandleUserProtocolsReloaded;
                return;
            }
#else
            // load user protocols
            List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(usrName);

            // it could be new user with no protocols
            if (tempList != null && tempList.Count > 0)
            {
                // load user protocols
                RoboSep_Protocols.getInstance().LoadUserToServer(usrName);
                RoboSep_Protocols.getInstance().setProtocolLoading(true);
                SeparatorGateway.GetInstance().separatorUpdating = true;

                // load user preferences
                RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);

                if (evhHandleUserProtocolsReloaded == null)
                {
                    evhHandleUserProtocolsReloaded = new EventHandler(HandleUserProtocolsReloadedBeforeExiting);
                }

                RoboSep_UserConsole.getInstance().NotifyUserSeparationProtocolsUpdated += evhHandleUserProtocolsReloaded;
                return;
            }
            else
            {
                // load user preferences
                RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);
            }
#endif
            // open run samples window
            RoboSep_UserConsole myUC = RoboSep_UserConsole.getInstance();
            RoboSep_UserConsole.ctrlCurrentUserControl = RoboSep_RunSamples.getInstance();
            RoboSep_RunSamples.getInstance().UserName = usrName;
            RoboSep_RunSamples.getInstance().Enabled  = false;
            myUC.SuspendLayout();
            myUC.Controls.Remove(this);
            myUC.Controls.Add(RoboSep_RunSamples.getInstance());
            myUC.ResumeLayout();
            if (RoboSep_RunSamples.getInstance().IsInitialized)
            {
                RoboSep_RunSamples.getInstance().ReInitialize();
            }
            RoboSep_RunSamples.getInstance().Enabled = true;
        }
 // function run to refresh server's active user protocol list
 private void ReloadProtocolsThread()
 {
     // save list as old robosep would
     SeparatorGateway.GetInstance().ReloadProtocols();
     SeparatorGateway.GetInstance().Connect(false);
 }
        private void LoadUserTimer_Tick(object sender, EventArgs e)
        {
            if (loadState == 0 && RoboSep_UserConsole.getInstance().bLoadingProtocols)
            {
                loadState++;
            }
            else if (loadState == 1 && RoboSep_UserConsole.getInstance().bLoadingProtocols)
            {
                int Loaded = RoboSep_UserConsole.getInstance().ProtocolsLoaded;

                // calculate percent
                double completion = (double)Loaded * 100.00 / (double)protocolsToLoad;
                loading.setProgress((int)completion);
            }
            else //if (loadState == 1 && !RoboSep_UserConsole.getInstance().bLoadingProtocols)
            {
                // check if server list is updated
                // server delegate function will update
                // protocolUpdated value when completed
                if (!SeparatorGateway.GetInstance().protocolUpdated)
                {
                    Thread.Sleep(100);
                }
                // peform completion test
                // check if given list matches
                // list returned from server
                else
                {
                    if (isProtocolLoading)
                    {
                        return;
                    }

                    SeparatorGateway.GetInstance().protocolUpdated = false;
                    bool ServerUpdated = true;

                    LoadUserTimer.Stop();

                    if (ServerUpdated || reloadProtocolCount > 2)
                    {
                        loading.setProgress(90);
                        reloadProtocolCount = 0;
                        //RoboSep_UserConsole.getInstance().XML_getUserProtocols();
                        loadState = 0;

                        // close dialog window
                        loading.Close();
                        RoboSep_UserConsole.hideOverlay();

                        if (RoboSep_UserConsole.ctrlCurrentUserControl == this)
                        {
                            // run base home button click
                            // base.btn_home_Click(sender, e);
                            return;
                        }
                        else
                        {
                            // loading user from protocol selection window
                            // check if current user control in UserConsole form
                            // is protocol select control.. if so re-load page
                            if (RoboSep_UserConsole.ctrlCurrentUserControl.GetType() == typeof(RoboSep_ProtocolSelect))
                            {
                                RoboSep_UserConsole UC = RoboSep_UserConsole.getInstance();
                                UC.Controls.Remove(RoboSep_UserConsole.ctrlCurrentUserControl);
                                RoboSep_ProtocolSelect PS = new RoboSep_ProtocolSelect(0, 4, null);
                                UC.Controls.Add(PS);
                                RoboSep_UserConsole.ctrlCurrentUserControl = PS;
                            }
                            return;
                        }
                    }
                    else
                    {
                        reloadProtocolCount++;
                        LoadUserToServer(textBox_UserName.Text);
                    }
                }
            }
        }