コード例 #1
0
ファイル: frmMain.cs プロジェクト: FabioGP/OPCServerWatcher
        /// <summary>
        /// Configuration wizard to support the user on scheduler configuration
        /// </summary>
        private void ConfigurationWizardScheduler()
        {
            ///Variable that store the user input
            string userInput = "";

            string defaultEnable = "";

            if (theSchedulerIsEnabled)
            {
                defaultEnable = "Yes";
            }
            else
            {
                defaultEnable = "No";
            }
            ///Request if the scheduler will be enabled
            userInput = UserDecision.ShowInputComboBox(defaultEnable, "Enable scheduler?", new string[] { "Yes", "No" });
            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            switch (userInput)
            {
            case "Yes":
                theSchedulerIsEnabled = true;
                break;

            case "No":
                theSchedulerIsEnabled = false;
                break;

            default:
                theSchedulerIsEnabled = false;
                MessageBox.Show("Invalid value!");
                return;
            }
            userInput = "";

            ///Request the OPC topic (address)
            DateTime newUserDate;

            newUserDate      = UserDecision.ShowTimePicker(DateTime.Now.ToString(), "Input the time:");
            theSchedulerTime = newUserDate;
            userInput        = "";

            //Save the new configurtaion and restart the application.
            GenerateConfigurationFile();
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: FabioGP/OPCServerWatcher
        /// <summary>
        /// Configuration wizard to support the user on OPC setup
        /// </summary>
        private void ConfigurationWizardKeepAliveMonitor()
        {
            ///Variable that store the user input
            string userInput = "";

            string defaultEnable = "";

            if (theKeepAliveMonitorIsEnabled)
            {
                defaultEnable = "Yes";
            }
            else
            {
                defaultEnable = "No";
            }
            ///Request if the keep alive monitor will be enabled
            userInput = UserDecision.ShowInputComboBox(defaultEnable, "Enable auto-restart by server state?", new string[] { "Yes", "No" });
            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            switch (userInput)
            {
            case "Yes":
                theKeepAliveMonitorIsEnabled = true;
                break;

            case "No":
                theKeepAliveMonitorIsEnabled = false;
                break;

            default:
                theKeepAliveMonitorIsEnabled = false;
                MessageBox.Show("Invalid value!");
                return;
            }
            userInput = "";

            ///Request the OPC Type
            userInput = UserDecision.ShowInputComboBox(theOPCServerType.ToString(), "Input the OPC server type", new string[] { eOPCServerType.DataFEED.ToString(), eOPCServerType.INAT.ToString(), eOPCServerType.KEPWare.ToString(), eOPCServerType.RsLinx.ToString(), eOPCServerType.SoftingS7.ToString() });
            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            theOPCServerType = (eOPCServerType)Enum.Parse(typeof(eOPCServerType), userInput);
            userInput        = "";

            ///Request the OPC topic (address)
            string defaultTopicConfig;

            switch (theOPCServerType)
            {
            case eOPCServerType.DataFEED:
                defaultTopicConfig = "Softing.OPC.DF.S7.DA.1";
                break;

            case eOPCServerType.INAT:
                defaultTopicConfig = "INAT TcpIpH1 OPC Server";
                break;

            case eOPCServerType.KEPWare:
                defaultTopicConfig = "";
                break;

            case eOPCServerType.RsLinx:
                defaultTopicConfig = "RsLinx OPC Server";
                break;

            case eOPCServerType.SoftingS7:
                defaultTopicConfig = "Softing.OPC.S7.DA.1";
                break;

            default:
                defaultTopicConfig = "";
                break;
            }
            userInput = UserDecision.ShowInputString(defaultTopicConfig, "Input the OPC topic (address)");
            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            theOPCServerTopic = userInput;
            userInput         = "";

            ///Request the process name
            string defaultProcessName;

            switch (theOPCServerType)
            {
            case eOPCServerType.DataFEED:
                defaultProcessName = "OSF_Service";
                break;

            case eOPCServerType.INAT:
                defaultProcessName = "TCPIPH1";
                break;

            case eOPCServerType.KEPWare:
                defaultProcessName = "";
                break;

            case eOPCServerType.RsLinx:
                defaultProcessName = "RSLINX";
                break;

            case eOPCServerType.SoftingS7:
                defaultProcessName = "S7OPCsvc";
                break;

            default:
                defaultProcessName = "";
                break;
            }
            userInput = UserDecision.ShowInputString(defaultProcessName, "Input the name of OPC process (Windows)");
            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            theOPCServerProcessName = userInput;
            userInput = "";

            ///Request the cycle timer
            userInput = UserDecision.ShowInputString(theCycleTime.ToString(), "Input the cycle timer in [ms]");
            int newCycleTimer;

            if (userInput == "")
            {
                MessageBox.Show("This value cannot be empty..."); return;
            }
            ;
            if (int.TryParse(userInput, out newCycleTimer) == false)
            {
                MessageBox.Show("Input value was not valid. Please use just numbers..."); return;
            }
            ;
            theCycleTime = newCycleTimer;
            userInput    = "";

            //Save the new configurtaion and restart the application.
            GenerateConfigurationFile();
        }