Beispiel #1
0
        public void loadSettings(string filename)
        {
            ProjectConfigFile defFile = new ProjectConfigFile(filename);

            DefinitionFile = filename;
            SplashScreen.SetStatus("Loading project file " + DefinitionFile);
            defFile.LoadObject(this);

            // If any of the GlobalValues within the Project are Retentive, then load the retentive file
            // TODO: need to check if any TestSequence values are retentive???  investigate...
            foreach (GlobalValue globalValue in mGlobalValues)
            {
                if (globalValue.IsRetentive)
                {
                    mDataValueRetentionFile.LoadDataFromFile();
                    break; // only load it once
                }
            }


            foreach (TestSequence seq in mTestSequences)
            {
                seq.SetFullyInitialized();
            }
            SetFullyInitialized();

            mWindow.logMessage("Settings loaded successfully");
        }
Beispiel #2
0
        public bool ConnectToRuntime(string machineName, bool queryOnErrors)
        {         // TODO: what if multiple threads try to connect at once???
            //throw new ArgumentException("Attempt to use old T&D Link.  Please use new link instead."); //OLDTND
            // if we failed to connect before (reconnect timer running), then only try every second or so...
            if (mReconnectTimer.Enabled)
            {
                return(false);
            }

            bool         success = true;
            DialogResult dialogResult;

            TNDType = Type.GetTypeFromProgID("tndrt");
            TND     = Activator.CreateInstance(TNDType);

            object[] param       = new object[0];
            String   projectName = "";

            try
            {
                projectName = (String)TNDType.InvokeMember("GetProjectName", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, TND, param);
            }
            catch (COMException e)
            {
                success = false;
                string logMessage = "";
                switch (e.ErrorCode)
                {
                case 429:
                    logMessage = "This PC does not appear to have a Think & Do Runtime to link to.";
                    FireTNDLinkDisabled();
                    break;

                case 462:
                    logMessage = "Unable to connect to the remote T&D machine from here.";
                    break;

                case 463:
                    logMessage = "This PC does not appear to be properly configured for Think & Do communication.";
                    break;

                default:
                    logMessage = "UNUSUAL T&D LINK FAILURE DURING CONNECT (runtime error=" + e.ErrorCode + " '" + e.Message + "')";
                    break;
                }
                if (e.ErrorCode != mLastCOMErrorDuringConnect)
                {
                    myForm.logMessage(logMessage);
                    mLastCOMErrorDuringConnect = e.ErrorCode;
                }
            }
            catch (Exception e)
            {
                mLastCOMErrorDuringConnect = 0;
                success = false;
                myForm.logMessage("UNUSUAL FAILURE CONNECTING TO T&D (runtime error='" + e.Message + "')");
            }
            finally
            {
            }

            if (!success || projectName.Length == 0)
            {
                if (queryOnErrors)
                {
                    dialogResult = MessageBox.Show("The Think & Do Runtime isn't running a project." + Environment.NewLine + Environment.NewLine + "Would you like to connect when it starts up?", "Think & Do Runtime not active", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        FireTNDLinkLost();
                    }
                    else
                    {
                        FireTNDLinkDisabled();
                    }
                }
                success = false;
            }
            else
            {
                FireTNDLinkEstablished();
                success = true;
                mLastCOMErrorDuringConnect = 0;
            }

            if (!success)
            {
                mReconnectTimer.Enabled = true;
                FireTNDLinkLost();
            }
            mConnected = success;
            return(success);
        }