Beispiel #1
0
        private void CloudBrokerSetting(string sBrowser, string sProjectName, string sWebAccessIP, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<CloudPC> Browser= Internet Explorer");
                api2 = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<CloudPC> Browser= Mozilla FireFox");
                api2 = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            api2.LinkWebUI(baseUrl2 + "/broadWeb/bwconfig.asp?username=admin");
            api2.ById("userField").Enter("").Submit().Exe();
            PrintStep(api2, "<CloudPC> Login WebAccess");
            EventLog.AddLog("<CloudPC> Set MQTT broker Account");
            EventLog.AddLog("<CloudPC> UserName=admin Password=12345");
            api2.ByXpath("//a[contains(@href, '/broadWeb/mqtt/mqttBroker.asp')]").Click();
            api2.ByName("Enable").Click();
            api2.ByName("UserName").Clear();
            api2.ByName("UserName").Enter("admin").Exe();
            api2.ByName("Password").Clear();
            api2.ByName("Password").Enter("12345").Submit().Exe();
            Thread.Sleep(500);
            PrintStep(api2, "<CloudPC> SetMQTTbrokerAccount");
            api2.Quit();
            PrintStep(api2, "<CloudPC> Quit browser");
        }
Beispiel #2
0
        private bool AnalogTagDataCheck(string sProjectName)
        {
            bool bCheckAnalogTag = true;

            string[] ToBeTestTag = { "Acc_0007", "AT_AI0007", "AT_AO0007", "Calc_OPCDA", "ConAna_0007", "OPCDA_0007", "OPCUA_0007", "SystemSec_0007" };

            for (int i = 0; i < ToBeTestTag.Length; i++)
            {
                EventLog.AddLog("Go to Analog Tag log setting page");
                api.ByXpath("//a[contains(@href, '/broadWeb/syslog/LogPg.asp') and contains(@href, 'pos=analog')]").Click();

                // select project name
                EventLog.AddLog("select project name");
                api.ByName("ProjNameSel").SelectTxt(sProjectName).Exe();
                Thread.Sleep(3000);

                // set today as start date
                //string sToday = string.Format("{0:dd}", DateTime.Now);
                //int iToday = Int32.Parse(sToday);   // 為了讓讀出來的日期去掉第一個零 ex: "06" -> "6"
                //string ssToday = string.Format("{0}", iToday);
                string sToday = DateTime.Now.ToString("%d");
                api.ByName("DateStart").Click();
                Thread.Sleep(1000);
                api.ByTxt(sToday).Click();
                Thread.Sleep(1000);
                EventLog.AddLog("select start date to today: " + sToday);

                // select one tag to get ODBC data
                EventLog.AddLog("select " + ToBeTestTag[i] + " to get ODBC data");
                api.ById("alltags").Click();
                api.ById("TagNameSel").SelectTxt(ToBeTestTag[i]).Exe();
                api.ById("addtag").Click();
                api.ById("TagNameSelResult").SelectTxt(ToBeTestTag[i]).Exe();

                Thread.Sleep(1000);
                api.ByName("PageSizeSel").Enter("").Submit().Exe();
                PrintStep("Set and get analog ODBC tag data");
                EventLog.AddLog("Get " + ToBeTestTag[i] + " ODBC data");

                Thread.Sleep(10000);                                             // wait to get ODBC data

                api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[2]/a").Click(); // click time to sort data
                Thread.Sleep(10000);
                //api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[3]/a").Click();    // click tagname to sort data
                //Thread.Sleep(5000);

                bool bRes = bCheckRecordTime(ToBeTestTag[i]);
                if (bRes == false)
                {
                    bCheckAnalogTag = false;
                }

                // print screen
                EventLog.PrintScreen(ToBeTestTag[i] + "_ODBCData");

                api.ByXpath("//*[@id=\"div1\"]/table/tbody/tr[1]/td[3]/a[5]/font").Click();     //return to homepage
            }

            return(bCheckAnalogTag);
        }
Beispiel #3
0
        private void CreateRealTimeTrend()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=RTrendList')]").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/rtrend/RTrendPg.asp') and contains(@href, 'action=add_rtrend')]").Click();

            string[] CalcTagName = { "System", "ConAna", "ConDis", "ModBusAI", "ModBusAO", "ModBusDI", "ModBusDO", "OPCDA", "OPCUA", "Acc" };

            for (int i = 0; i < CalcTagName.Length; i++)
            {
                try
                {
                    string tagName = "TagName" + (i + 1).ToString("000");
                    string dispH   = "DispH" + (i + 1).ToString("000");
                    string dispL   = "DispL" + (i + 1).ToString("000");

                    api.ByName(tagName).Enter("Calc_" + CalcTagName[i]).Exe();
                    api.ByName(dispH).Enter("100").Exe();
                    api.ByName(dispL).Enter("0").Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateRealTimeTrend error: " + ex.ToString());
                    i--;
                }
            }
            api.ByName("Description").Enter("").Submit().Exe();
        }
Beispiel #4
0
        private void CreateAlarmGroup()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=AlmGrpList')]").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/AlarmGrp/AlmGrpPg.asp') and contains(@href, 'action=add_almgr')]").Click();

            string[] AlarmTagName = { "AT_AI0001",   "AT_AO0001",   "AT_DI0001",   "AT_DO0001",   "ConDis_0001", "SystemSec_0001",
                                      "Calc_ConAna", "ConAna_0001", "ConAna_0002", "ConAna_0004", "ConAna_0008", "ConAna_0016",   "ConAna_0032","ConAna_0064", "ConAna_0128" };

            for (int i = 0; i < AlarmTagName.Length; i++)
            {
                try
                {
                    string tagName = "TagName" + (i + 1).ToString("000");
                    api.ByName(tagName).Enter(AlarmTagName[i]).Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateAlarmGroup" + ex.ToString());
                    i--;
                }
            }
            api.ByName("TagName").Enter("Alarm Group Set").Submit().Exe();
        }
Beispiel #5
0
 private void ExcuteExcelIn(string sSourceFile)
 {
     api.SwitchToCurWindow(0);
     api.SwitchToFrame("rightFrame", 0);
     api.ByXpath("//a[contains(@href, '/broadWeb/odbc/odbcPg1.asp?pos=import')]").Click();
     api.ByName("XlsName").Clear();
     api.ByName("XlsName").Enter(sSourceFile).Submit().Exe();
 }
Beispiel #6
0
    private void StartNode()
    {
        PrintTitle("StartNode");
        api.SwitchToCurWindow(0);
        api.SwitchToFrame("rightFrame", 0);
        api.ByXpath("//tr[2]/td/a[5]/font").Click();    // start kernel

        string main; object subobj;

        api.GetWinHandle(out main, out subobj);
        IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

        List <string> items = new List <string>();

        while (windowIterator.MoveNext())
        {
            items.Add(windowIterator.Current);
        }

        if (main != items[1])
        {
            api.SwitchToWinHandle(items[1]);
        }
        else
        {
            api.SwitchToWinHandle(items[0]);
        }
        api.ByName("submit").Enter("").Submit().Exe();
        PrintStep();
        System.Threading.Thread.Sleep(5000); // Wait 30s for start kernel finish
        api.Close();
        api.SwitchToWinHandle(main);         // switch back to original window

        PrintStep();
    }
Beispiel #7
0
        public void StopKernel(IAdvSeleniumAPI api, bool bRedundancyTest)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[6]/font").Click();    // Stop kernel
            Thread.Sleep(2000);

            EventLog.AddLog("Find pop up StopNode window handle");
            string main; object subobj;

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }

            if (bRedundancyTest == true)
            {
                Thread.Sleep(500);
                api.ByXpath("(//input[@name='SECONDARY_CONTROL'])[2]").Click();
                Thread.Sleep(1000);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            if (bRedundancyTest == true)
            {
                EventLog.AddLog("Stop node and wait 100 seconds for redundancy test...");
                Thread.Sleep(100000);    // Wait 100s for Stop kernel finish
                EventLog.AddLog("It's been wait 100 seconds");
            }
            else
            {
                EventLog.AddLog("Stop node and wait 30 seconds...");
                Thread.Sleep(30000);    // Wait 30s for Stop kernel finish
                EventLog.AddLog("It's been wait 30 seconds");
            }

            EventLog.PrintScreen("Stop Node result");
            api.Close();
            EventLog.AddLog("Close stop node window and switch to main window");
            api.SwitchToWinHandle(main); // switch back to original window
        }                                // for Redundancy test
Beispiel #8
0
    private void StopNode()
    {
        PrintTitle("StopNode");
        api.LinkWebUI(txtCloudIp.Text + "/broadWeb/bwconfig.asp?username=admin");
        api.ById("userField").Enter("").Submit().Exe();
        PrintStep();

        string sProjectName = "WISE%2DDQA"; // WISE-DQA

        api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
        PrintStep();

        api.SwitchToCurWindow(0);
        api.SwitchToFrame("rightFrame", 0);
        api.ByXpath("//tr[2]/td/a[6]/font").Click();    // Stop kernel
        System.Threading.Thread.Sleep(2000);

        string main; object subobj;

        api.GetWinHandle(out main, out subobj);
        IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

        List <string> items = new List <string>();

        while (windowIterator.MoveNext())
        {
            items.Add(windowIterator.Current);
        }

        if (main != items[1])
        {
            api.SwitchToWinHandle(items[1]);
        }
        else
        {
            api.SwitchToWinHandle(items[0]);
        }
        //if (bRedundancyTest == true)
        //{
        //    Thread.Sleep(500);
        //    api.ByXpath("(//input[@name='SECONDARY_CONTROL'])[2]").Click();
        //    Thread.Sleep(1000);
        //}
        api.ByName("submit").Enter("").Submit().Exe();

        System.Threading.Thread.Sleep(30000); // Wait 30s for Stop kernel finish
        api.Close();
        api.SwitchToWinHandle(main);          // switch back to original window
        PrintStep();
    }
Beispiel #9
0
        private void StartDownload(IAdvSeleniumAPI api, string sTestLogFolder)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[3]/font").Click();    // "Download" click
            Thread.Sleep(2000);
            EventLog.AddLog("Find pop up download window handle");
            string main; object subobj;                     // Find pop up download window handle

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            EventLog.AddLog("Start to download and wait 80 seconds...");
            Thread.Sleep(80000);    // Wait 80s for Download finish
            EventLog.AddLog("It's been wait 80 seconds");

            api.Close();
            EventLog.AddLog("Close download window and switch to main window");
            api.SwitchToWinHandle(main);

            PrintStep("Download");
        }
Beispiel #10
0
        public void StartKernel(IAdvSeleniumAPI api)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[5]/font").Click();    // start kernel
            Thread.Sleep(2000);
            EventLog.AddLog("Find pop up StartNode window handle");
            string main; object subobj;

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            EventLog.AddLog("Start node and wait 30 seconds...");
            Thread.Sleep(30000);    // Wait 30s for start kernel finish
            EventLog.AddLog("It's been wait 30 seconds");
            EventLog.PrintScreen("Start Node result");
            api.Close();
            EventLog.AddLog("Close start node window and switch to main window");
            api.SwitchToWinHandle(main);        // switch back to original window
        }
Beispiel #11
0
    private void StartDownload(IAdvSeleniumAPI api)
    {
        PrintTitle("StartDownload");
        api.SwitchToCurWindow(0);
        api.SwitchToFrame("rightFrame", 0);
        api.ByXpath("//tr[2]/td/a[3]/font").Click();    // "Download" click

        string main; object subobj;                     // Find pop up download window handle

        api.GetWinHandle(out main, out subobj);
        IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

        List <string> items = new List <string>();

        while (windowIterator.MoveNext())
        {
            items.Add(windowIterator.Current);
        }

        if (main != items[1])
        {
            api.SwitchToWinHandle(items[1]);
        }
        else
        {
            api.SwitchToWinHandle(items[0]);
        }
        api.ByName("submit").Enter("").Submit().Exe();

        System.Threading.Thread.Sleep(80000);
        //PrintScreen("Download result", sTestLogFolder);
        api.Close();
        api.SwitchToWinHandle(main);

        PrintStep();
    }
Beispiel #12
0
 private void CreateSystemTag()
 {
     EventLog.AddLog("Create System tags start...");
     api.SwitchToCurWindow(0);
     api.SwitchToFrame("rightFrame", 0);
     api.ByXpath("//a[7]/font/b").Click();
     api.ByXpath("//a[contains(@href, '/broadWeb/tag/tagPg.asp') and contains(@href, 'dt=SysType')]").Click();
     api.ByName("ParaName").SelectVal("TM_Sec").Exe();
     Thread.Sleep(500);
     SetupBasicSystemTagConfig();
     for (int i = 1; i <= 5; i++)
     {
         try
         {
             api.ByName("TagName").Clear();
             api.ByName("TagName").Enter("SystemSec_" + i.ToString("0000")).Submit().Exe();
         }
         catch (Exception ex)
         {
             EventLog.AddLog("CreateSystemTag error: " + ex.ToString());
             i--;
         }
     }
 }
Beispiel #13
0
        private void CreateModbusServerConfig()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/ModbusSrvPortLst.asp')]").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/addupModbusSrvPort.asp') and contains(@href, 'act=add')]").Click();

            api.ByName("srvName").Enter("ModbusServer").Exe();
            api.ById("PortType").SelectVal("TCPIP").Exe();
            api.ByName("ENABLE_EXCEPTION").Click();
            api.ByXpath("//button[@type='submit']").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/addModbusSrvTag.asp')]").Click();

            for (int i = 1; i <= 10; i++)
            {
                api.ByName("Address").Clear();
                api.ByName("Address").Enter("4" + i.ToString("0000")).Exe();
                api.ByName("TagName").Clear();
                api.ByName("TagName").Enter("ConAna_" + i.ToString("0000")).Submit().Exe();
            }
        }
Beispiel #14
0
 private void PowerUserSetting()
 {
     EventLog.AddLog("Add power user");
     api.ByName("UserName").Clear();
     api.ByName("UserName").Enter("PowerUser").Exe();
     api.ByName("Password").Clear();
     api.ByName("Password").Enter("12345678").Exe(); // max is 8
     api.ByName("Password2").Clear();
     api.ByName("Password2").Enter("12345678").Exe();
     api.ByName("DfGphName").Clear();
     api.ByName("DfGphName").Enter("PowerUser.bgr").Exe();
     api.ByName("Description").Clear();
     api.ByName("Description").Enter("Password=12345678").Submit().Exe();
     PrintStep("Add power user");
 }
Beispiel #15
0
 private void SetupBasicAnalogTagConfig()
 {
     api.ByName("Datalog").Click();
     api.ByName("DataLogDB").Clear();
     api.ByName("DataLogDB").Enter("0").Exe();
     api.ByName("ChangeLog").Click();
     api.ByName("SpanHigh").Clear();
     api.ByName("SpanHigh").Enter("1000").Exe();
     api.ByName("OutputHigh").Clear();
     api.ByName("OutputHigh").Enter("1000").Exe();
     api.ByName("ReservedInt1").SelectTxt("2").Exe();
     api.ByXpath("(//input[@name='LogTmRadio'])[2]").Click();
 }
Beispiel #16
0
        private void AnalogTagUpdateSetting(string sTagName)
        {
            EventLog.AddLog("<GroundPC> Update " + sTagName);
            Thread.Sleep(2000);
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/tag/TagPg.asp?pos=tag') and contains(@href, 'action=tag_property')]").Click();
            switch (slanguage)
            {
            case "ENG":
                api.ByName("AlarmStatus").SelectTxt("Alarm").Exe();
                break;

            case "CHT":
                api.ByName("AlarmStatus").SelectTxt("警報").Exe();
                break;

            case "CHS":
                api.ByName("AlarmStatus").SelectTxt("报警").Exe();
                break;

            case "JPN":
                api.ByName("AlarmStatus").SelectTxt("アラーム").Exe();
                break;

            case "KRN":
                api.ByName("AlarmStatus").SelectTxt("알람").Exe();
                break;

            case "FRN":
                api.ByName("AlarmStatus").SelectTxt("Alarme").Exe();
                break;

            default:
                api.ByName("AlarmStatus").SelectTxt("Alarm").Exe();
                break;
            }

            Thread.Sleep(1500);
            api.ByName("Description").Clear();
            api.ByName("Description").Enter("Plug and play update tag test from ground to cloud").Exe();
            api.ByName("HHPriority").SelectVal("8").Exe();
            api.ByName("HHAlarm").Clear();
            api.ByName("HHAlarm").Enter("7").Exe();
            api.ByName("HiPriority").SelectVal("6").Exe();
            api.ByName("HiAlarm").Clear();
            api.ByName("HiAlarm").Enter("5").Exe();
            api.ByName("LoPriority").SelectVal("1").Exe();
            api.ByName("LoAlarm").Clear();
            api.ByName("LoAlarm").Enter("4").Exe();
            api.ByName("LLPriority").SelectVal("2").Exe();
            api.ByName("LLAlarm").Clear();
            api.ByName("LLAlarm").Enter("3").Exe();
            api.ByName("TagName").Clear();
            api.ByName("TagName").Enter(sTagName + "_Test").Submit().Exe();
            PrintStep(api, "<GroundPC> Update " + sTagName);

            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
        }
Beispiel #17
0
        private void GroundPlugandPlaySetting(string sBrowser, string sProjectName, string sProjectName2, string sWebAccessIP, string sWebAccessIP2, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<GroundPC> Browser= Internet Explorer");
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<GroundPC> Browser= Mozilla FireFox");
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep(api, "<GroudPC> Login WebAccess");

            // Configure project by project name
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep(api, "<GroundPC> Configure project");

            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/node/nodePg.asp?') and contains(@href, 'action=node_property')]").Click();

            EventLog.AddLog("<GroundPC> Cloud Connection Settings");
            api.ByName("CLOUD_ENABLE").Click();
            Thread.Sleep(500);
            api.ByName("CLOUD_PROJNAME").Clear();
            api.ByName("CLOUD_PROJNAME").Enter(sProjectName2).Exe();
            api.ByName("CLOUD_SCADANAME").Clear();
            api.ByName("CLOUD_SCADANAME").Enter("CTestSCADA").Exe();
            api.ByName("DEFAULT_BUTTON").Click();
            api.ByName("CLOUD_IP").Clear();
            api.ByName("CLOUD_IP").Enter(sWebAccessIP2).Exe();

            /*
             * TCP comport-1883             -> win7 / win8 / win10
             * WebSocket and SSL -443       -> win8 / win10
             * WebSocket and Non-SSL=80     -> win8 / win 10
             */
            api.ByName("CLOUD_COMPORT").Clear();
            api.ByName("CLOUD_COMPORT").Enter("1883").Exe();            // port = 1883
            api.ByXpath("(//input[@name='CLOUD_TCP'])[2]").Click();     // Connection Type = TCP

            api.ByName("CLOUD_USERNAME").Clear();
            api.ByName("CLOUD_USERNAME").Enter("admin").Exe();
            api.ByName("CLOUD_PASSWORD").Clear();
            api.ByName("CLOUD_PASSWORD").Enter("12345").Submit().Exe();
            PrintStep(api, "Cloud Connection Settings");

            EventLog.AddLog("<GroundPC> Cloud White list setting");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/WaCloudWhitelist/CloudWhitelist.asp?')]").Click();

            ////////////////////////////////// Cloud White list Setting //////////////////////////////////
            {   // AI/AO/DI/DO
                EventLog.AddLog("<GroundPC> Modbus tag setting");

                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠3(tcpip)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口3(tcpip)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트3(tcpip)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 500; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                //api.ByXpath("//input[@value='Save']").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }

                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);

                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(3000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Port4(opc)
            {
                EventLog.AddLog("<GroundPC> Port4(opc) setting");
                //api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠4(opc)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口4(opc)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트4(opc)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Port5(tcpip)
            {
                EventLog.AddLog("<GroundPC> Port5(tcpip) setting");
                //api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠5(tcpip)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口5(tcpip)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트5(tcpip)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Acc Point
            {
                EventLog.AddLog("<GroundPC> Acc Point setting");
                //api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("累算點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("累算点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("누적 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point d'accumul.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Calc Point
            {
                EventLog.AddLog("<GroundPC> Calc Point setting");
                //api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("計算點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("计算点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("산출 포인트").Exe();     // 翻譯可能有問題 與acc一樣
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point calc.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Const Point
            {
                EventLog.AddLog("<GroundPC> Const Point setting");
                //api.ById("tagTypes").SelectTxt("Const Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("常數點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("常数点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("상수 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point const.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);

                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(3000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // System Point
            {
                EventLog.AddLog("<GroundPC> System Point setting");
                //api.ById("tagTypes").SelectTxt("System Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("系統點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("系统点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("시스템 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            ////////////////////////////////// Cloud White list Setting //////////////////////////////////
            PrintStep(api, "CloudWhitelistSetting");
            ReturnSCADAPage(api);

            EventLog.AddLog("<GroundPC> Download...");
            wacf.Download(api);

            api.Quit();
            PrintStep(api, "Quit browser");
        }
Beispiel #18
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            baseUrl = "http://" + sWebAccessIP;

            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("Browser= Internet Explorer");
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("Browser= Mozilla FireFox");
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            EventLog.AddLog("Go to Event log setting page");
            api.ByXpath("//a[contains(@href, '/broadWeb/syslog/LogPg.asp?pos=event')]").Click();

            // select project name
            EventLog.AddLog("select project name");
            api.ByName("ProjNameSel").SelectTxt(sProjectName).Exe();
            Thread.Sleep(3000);

            // set today as start date
            string sToday  = string.Format("{0:dd}", DateTime.Now);
            int    iToday  = Int32.Parse(sToday); // 為了讓讀出來的日期去掉第一個零 ex: "06" -> "6"
            string ssToday = string.Format("{0}", iToday);

            api.ByName("DateStart").Click();
            Thread.Sleep(1000);
            api.ByTxt(ssToday).Click();
            Thread.Sleep(1000);
            EventLog.AddLog("select start date to today: " + ssToday);

            api.ByName("PageSizeSel").Enter("").Submit().Exe();
            PrintStep("Set and get Event Log data");
            EventLog.AddLog("Get Event Log data");

            Thread.Sleep(10000); // wait to get ODBC data

            // print screen
            string fileNameTar = string.Format("EventLogData_{0:yyyyMMdd_hhmmss}", DateTime.Now);

            EventLog.PrintScreen(fileNameTar);

            /*
             * EventLog.AddLog("Save data to excel");
             * SaveDatatoExcel(sProjectName, sTestLogFolder);
             */
            EventLog.AddLog("Check event log data");
            bool bCheckResult = CheckEventLogData();

            PrintStep("CheckEventLogData");

            Thread.Sleep(500);
            api.Quit();
            PrintStep("Quit browser");

            bool bSeleniumResult      = true;
            int  iTotalSeleniumAction = dataGridView1.Rows.Count;

            for (int i = 0; i < iTotalSeleniumAction - 1; i++)
            {
                DataGridViewRow row             = dataGridView1.Rows[i];
                string          sSeleniumResult = row.Cells[2].Value.ToString();
                if (sSeleniumResult != "pass")
                {
                    bSeleniumResult = false;
                    EventLog.AddLog("Test Fail !!");
                    EventLog.AddLog("Fail TestItem = " + row.Cells[0].Value.ToString());
                    EventLog.AddLog("BrowserAction = " + row.Cells[1].Value.ToString());
                    EventLog.AddLog("Result = " + row.Cells[2].Value.ToString());
                    EventLog.AddLog("ErrorCode = " + row.Cells[3].Value.ToString());
                    EventLog.AddLog("ExeTime(ms) = " + row.Cells[4].Value.ToString());
                    break;
                }
            }

            if (bSeleniumResult && bCheckResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }

            //return 0;
        }
Beispiel #19
0
        private void Create_DailyReport_ExcelReport(string sUserEmail)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/WaExlViewer/WaExlViewer.asp')]").Click();

            for (int t = 1; t <= 4; t++)   /////// template 1~4 ; 8min
            {
                api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click();

                api.ByName("rptName").Clear();
                api.ByName("rptName").Enter(string.Format("ER_ODBC_T{0}_DR_8min_LastValue_ER", t)).Exe();
                api.ByXpath("(//input[@name='dataSrc'])[2]").Click();   // ODBC
                api.ByName("selectTemplate").SelectVal(string.Format("template{0}.xlsx", t)).Exe();

                switch (slanguage)
                {
                case "ENG":
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;

                case "CHT":
                    api.ByName("speTimeFmt").SelectTxt("日報表").Exe();
                    break;

                case "CHS":
                    api.ByName("speTimeFmt").SelectTxt("日报表").Exe();
                    break;

                case "JPN":
                    api.ByName("speTimeFmt").SelectTxt("日報").Exe();
                    break;

                case "KRN":
                    api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe();
                    break;

                case "FRN":
                    api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe();
                    break;

                default:
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;
                }

                // set end date
                api.ByName("tEnd").Click();
                Thread.Sleep(500);
                api.ByXpath("//button[@type='button']").Click();
                api.ByXpath("(//button[@type='button'])[2]").Click();

                api.ByName("interval").Clear();
                api.ByName("interval").Enter("8").Exe();                // Time Interval = 8
                api.ByXpath("(//input[@name='fileType'])[2]").Click();  // Time Unit: Minute
                api.ByXpath("//input[@name='valueType']").Click();      // Data Type: Last Value
                // 湊到最大上限32個TAG
                string[] ReportTagName = { "Calc_ConAna",       "Calc_ConDis",   "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI",  "Calc_ModBusDO",     "Calc_OPCDA",        "Calc_OPCUA", "Calc_System",
                                           "Calc_ANDConDisAll", "Calc_ANDDIAll", "Calc_ANDDOAll", "Calc_AvgAIAll", "Calc_AvgAOAll",  "Calc_AvgConAnaAll", "Calc_AvgSystemAll",
                                           "AT_AI0050",         "AT_AI0100",     "AT_AI0150",     "AT_AO0050",     "AT_AO0100",      "AT_AO0150",         "AT_DI0050",         "AT_DI0100",  "AT_DI0150",  "AT_DO0050",
                                           "AT_DO0100",         "AT_DO0150",     "ConAna_0100",   "ConDis_0100",   "SystemSec_0100", "SystemSec_0200" };

                for (int i = 0; i < ReportTagName.Length; i++)
                {
                    api.ById("tagsLeftList").SelectTxt(ReportTagName[i]).Exe();
                }
                api.ById("torightBtn").Click();

                api.ById("tagsRightList").SelectTxt(ReportTagName[0]).Exe();

                api.ByXpath("(//input[@name='attachFormat'])[2]").Click();  // Send Email: Excel Report
                api.ByName("emailto").Clear();
                api.ByName("emailto").Enter(sUserEmail).Exe();
                //api.ByName("rptName").Enter("").Submit().Exe();   這邊不能用這種方式submit...很奇怪 反而按submit的button可以正常送出
                api.ByName("cfgSubmit").Click();
            }

            for (int t = 1; t <= 4; t++)   ////// template 1~4 ; 1hour
            {
                api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click();

                api.ByName("rptName").Clear();
                api.ByName("rptName").Enter(string.Format("ER_ODBC_T{0}_DR_1hour_LastValue_ER", t)).Exe();
                api.ByXpath("(//input[@name='dataSrc'])[2]").Click();   // ODBC
                api.ByName("selectTemplate").SelectVal(string.Format("template{0}.xlsx", t)).Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;

                case "CHT":
                    api.ByName("speTimeFmt").SelectTxt("日報表").Exe();
                    break;

                case "CHS":
                    api.ByName("speTimeFmt").SelectTxt("日报表").Exe();
                    break;

                case "JPN":
                    api.ByName("speTimeFmt").SelectTxt("日報").Exe();
                    break;

                case "KRN":
                    api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe();
                    break;

                case "FRN":
                    api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe();
                    break;

                default:
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;
                }

                // set end date
                api.ByName("tEnd").Click();
                Thread.Sleep(500);
                api.ByXpath("//button[@type='button']").Click();
                api.ByXpath("(//button[@type='button'])[2]").Click();

                api.ByName("interval").Clear();
                api.ByName("interval").Enter("1").Exe();                // Time Interval = 1
                api.ByXpath("(//input[@name='fileType'])[3]").Click();  // Time Unit: hour
                api.ByXpath("//input[@name='valueType']").Click();      // Data Type: Last Value
                // 湊到最大上限32個TAG
                string[] ReportTagName = { "Calc_ConAna",       "Calc_ConDis",   "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI",  "Calc_ModBusDO",     "Calc_OPCDA",        "Calc_OPCUA", "Calc_System",
                                           "Calc_ANDConDisAll", "Calc_ANDDIAll", "Calc_ANDDOAll", "Calc_AvgAIAll", "Calc_AvgAOAll",  "Calc_AvgConAnaAll", "Calc_AvgSystemAll",
                                           "AT_AI0050",         "AT_AI0100",     "AT_AI0150",     "AT_AO0050",     "AT_AO0100",      "AT_AO0150",         "AT_DI0050",         "AT_DI0100",  "AT_DI0150",  "AT_DO0050",
                                           "AT_DO0100",         "AT_DO0150",     "ConAna_0100",   "ConDis_0100",   "SystemSec_0100", "SystemSec_0200" };

                for (int i = 0; i < ReportTagName.Length; i++)
                {
                    try
                    {
                        api.ById("tagsLeftList").SelectTxt(ReportTagName[i]).Exe();
                    }
                    catch (Exception ex)
                    {
                        EventLog.AddLog("CreateExcelReport error: " + ex.ToString());
                        i--;
                    }
                }
                api.ById("torightBtn").Click();
                api.ById("tagsRightList").SelectTxt(ReportTagName[0]).Exe();

                api.ByXpath("(//input[@name='attachFormat'])[2]").Click();  // Send Email: Excel Report
                api.ByName("emailto").Clear();
                api.ByName("emailto").Enter(sUserEmail).Exe();
                api.ByName("cfgSubmit").Click();
            }

            for (int d = 1; d <= 3; d++)   ////// data type = Maximum or  Minimum or  Average
            {
                api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click();

                api.ByName("rptName").Clear();

                if (d == 1)
                {
                    api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Max_ER").Exe();
                }
                else if (d == 2)
                {
                    api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Min_ER").Exe();
                }
                else if (d == 3)
                {
                    api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Avg_ER").Exe();
                }

                api.ByXpath("(//input[@name='dataSrc'])[2]").Click();   // ODBC
                api.ByName("selectTemplate").SelectVal("template1.xlsx").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;

                case "CHT":
                    api.ByName("speTimeFmt").SelectTxt("日報表").Exe();
                    break;

                case "CHS":
                    api.ByName("speTimeFmt").SelectTxt("日报表").Exe();
                    break;

                case "JPN":
                    api.ByName("speTimeFmt").SelectTxt("日報").Exe();
                    break;

                case "KRN":
                    api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe();
                    break;

                case "FRN":
                    api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe();
                    break;

                default:
                    api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe();
                    break;
                }

                // set end date
                api.ByName("tEnd").Click();
                Thread.Sleep(500);
                api.ByXpath("//button[@type='button']").Click();
                api.ByXpath("(//button[@type='button'])[2]").Click();

                api.ByName("interval").Clear();
                api.ByName("interval").Enter("1").Exe();                                        // Time Interval = 1
                api.ByXpath("(//input[@name='fileType'])[3]").Click();                          // Time Unit: hour
                api.ByXpath(string.Format("(//input[@name='valueType'])[{0}]", d + 1)).Click(); // Data Type
                // 湊到最大上限32個TAG
                string[] ReportTagName = { "Calc_ConAna",       "Calc_ConDis",   "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI",  "Calc_ModBusDO",     "Calc_OPCDA",        "Calc_OPCUA", "Calc_System",
                                           "Calc_ANDConDisAll", "Calc_ANDDIAll", "Calc_ANDDOAll", "Calc_AvgAIAll", "Calc_AvgAOAll",  "Calc_AvgConAnaAll", "Calc_AvgSystemAll",
                                           "AT_AI0050",         "AT_AI0100",     "AT_AI0150",     "AT_AO0050",     "AT_AO0100",      "AT_AO0150",         "AT_DI0050",         "AT_DI0100",  "AT_DI0150",  "AT_DO0050",
                                           "AT_DO0100",         "AT_DO0150",     "ConAna_0100",   "ConDis_0100",   "SystemSec_0100", "SystemSec_0200" };

                for (int i = 0; i < ReportTagName.Length; i++)
                {
                    try
                    {
                        api.ById("tagsLeftList").SelectTxt(ReportTagName[i]).Exe();
                    }
                    catch (Exception ex)
                    {
                        EventLog.AddLog("CreateExcelReport error: " + ex.ToString());
                        i--;
                    }
                }
                api.ById("torightBtn").Click();
                api.ById("tagsRightList").SelectTxt(ReportTagName[0]).Exe();

                api.ByXpath("(//input[@name='attachFormat'])[2]").Click();  // Send Email: Excel Report
                api.ByName("emailto").Clear();
                api.ByName("emailto").Enter(sUserEmail).Exe();
                api.ByName("cfgSubmit").Click();
            }
        }
Beispiel #20
0
        private void CreateEventLogData(string sProjectName)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);

            api.ByXpath("//a[contains(@href, '/broadWeb/eventlog/EveLogList.asp')]").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/eventLog/eveLogPg.asp') and contains(@href, 'pos=add')]").Click();

            switch (slanguage)
            {
            case "ENG":
                api.ByName("EventTypeSel").SelectTxt("Event Tag == Reference Value").Exe();
                break;

            case "CHT":
                api.ByName("EventTypeSel").SelectTxt("事件測點 == 參考值").Exe();
                break;

            case "CHS":
                api.ByName("EventTypeSel").SelectTxt("事件点 == 参考值").Exe();
                break;

            case "JPN":
                api.ByName("EventTypeSel").SelectTxt("イベントタグ == 参照値").Exe();
                break;

            case "KRN":
                api.ByName("EventTypeSel").SelectTxt("이벤트 태그 == Reference Value").Exe();
                break;

            case "FRN":
                api.ByName("EventTypeSel").SelectTxt("Repère d'Evénement == Valeur de Référence").Exe();
                break;

            default:
                api.ByName("EventTypeSel").SelectTxt("Event Tag == Reference Value").Exe();
                break;
            }

            api.ByName("EventLogName").Clear();
            api.ByName("EventLogName").Enter("EventLog_" + sProjectName).Exe();
            api.ByName("EventTag").Clear();
            api.ByName("EventTag").Enter("ConAna_0241").Exe();
            api.ByName("EventRefVal").Clear();
            api.ByName("EventRefVal").Enter("51").Exe();
            PrintStep("Set Event Log trigger event");

            api.ByName("EventLogTag").Click();

            api.ByName("ChSel").SelectVal("240").Exe();
            Thread.Sleep(2000);
            api.Accept();
            Thread.Sleep(1000);

            for (int i = 1; i <= 9; i++)
            {
                try
                {
                    api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_000{0}", i)).Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateEventLogData 1~9 error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create 1~9  tags to log");
            EventLog.AddLog("Create 1~9  tags to log");

            for (int i = 10; i <= 99; i++)
            {
                try
                {
                    api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_00{0}", i)).Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateEventLogData 10~99 error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create 10~99  tags to log");
            EventLog.AddLog("Create 10~99  tags to log");

            for (int i = 100; i <= 240; i++)
            {
                try
                {
                    if (i == 240)
                    {
                        api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_0{0}", i)).Submit().Exe();
                    }
                    else
                    {
                        api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_0{0}", i)).Exe();
                    }
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateEventLogData 100~240 error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create 100~240 tags to log");
            EventLog.AddLog("Create 100~240  tags to log");

            Thread.Sleep(1000);

            api.ByName("EventRefVal").Enter("").Submit().Exe();
            Thread.Sleep(1000);
        }
Beispiel #21
0
        private void CreateAccTag()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[4]/font/b").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/tag/tagPg.asp') and contains(@href, 'dt=AccType')]").Click();

            // Acc point
            EventLog.AddLog("Create  accumulation point");
            api.ByName("AccFreq").Clear();
            api.ByName("AccFreq").Enter("5").Exe();

            SetupBasicAnalogTagConfig();

            for (int i = 1; i <= 5; i++)
            {
                try
                {
                    api.ByName("TagName").Clear();
                    api.ByName("TagName").Enter("Acc_" + i.ToString("0000")).Exe();
                    api.ByName("Source").Clear();
                    api.ByName("Source").Enter("ConDis_" + i.ToString("0000")).Submit().Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateAccTag error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create  accumulation point");
        }
Beispiel #22
0
 private void AddComport()
 {
     api.SwitchToCurWindow(0);
     api.SwitchToFrame("rightFrame", 0);
     api.ByXpath("//a[3]/font/b").Click();
     Thread.Sleep(500);
     api.ByName("infName").SelectVal("TCPIP").Exe();
     Thread.Sleep(500);
     api.ByName("ComportNbr").Clear();
     api.ByName("ComportNbr").Enter("3").Submit().Exe();  // comport = 3
 }
Beispiel #23
0
        private void CreateOPCComportDevice(string sIP)
        {
            // Create com port
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            Thread.Sleep(1000);
            api.ByName("infName").SelectVal("TCPIP").Exe();
            Thread.Sleep(1000);
            api.ByName("ComportNbr").Clear();
            api.ByName("ComportNbr").Enter("5").Submit().Exe();  // comport = 5
            //api.ByName("submit").Click();
            Thread.Sleep(1000);
            PrintStep("Create OPC Communication Port");

            // add device
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=comport') and contains(@href, 'name=5')]").Click(); // name = 5
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/device/devPg.asp') and contains(@href, 'action=add')]").Click();    // add

            api.ByName("DeviceTypeSel").SelectVal("OPCUA").Exe();
            Thread.Sleep(1000);
            api.ByName("P_IPAddr").Clear();
            api.ByName("P_IPAddr").Enter(sIP).Exe();
            api.ByName("P_PortNbr").Clear();
            api.ByName("P_PortNbr").Enter("49320").Exe();
            api.ByName("DeviceName").Clear();
            api.ByName("DeviceName").Enter("OPCUA").Submit().Exe();
            //api.ByName("submit").Click();
            api.Refresh();
            PrintStep("Create OPCUA Device");
        }
Beispiel #24
0
        private bool bAlarmLogCheck(string sProjectName)
        {
            bool bCheckAlarm = true;

            //string[] ToBeTestTag = { "AT_AI0001", "AT_AO0001", "AT_DI0001", "AT_DO0001", "Calc_ConAna", "Calc_ConDis", "ConAna_0001", "ConDis_0001", "SystemSec_0001" };
            string[] ToBeTestTag = { "Calc_ConAna", "SystemSec_0001", "AT_AO0001", "AT_AI0001", "ConDis_0001", "ConAna_0001", "ConAna_0125", "ConAna_0250" };

            for (int i = 0; i < ToBeTestTag.Length; i++)
            {
                EventLog.AddLog("Go to Alarm log setting page");
                api.ByXpath("//a[contains(@href, '/broadWeb/syslog/LogPg.asp') and contains(@href, 'pos=alarm')]").Click();

                // select project name
                EventLog.AddLog("select project name");
                api.ByName("ProjNameSel").SelectTxt(sProjectName).Exe();
                Thread.Sleep(3000);

                // set today as start date
                string sToday = DateTime.Now.ToString("%d");
                api.ByName("DateStart").Click();
                Thread.Sleep(1000);
                api.ByTxt(sToday).Click();
                Thread.Sleep(1000);
                EventLog.AddLog("select start date to today: " + sToday);

                // select one tag to get ODBC data
                EventLog.AddLog("select " + ToBeTestTag[i] + " to get ODBC data");
                api.ById("alltags").Click();

                api.ById("TagNameSel").SelectTxt(ToBeTestTag[i]).Exe();

                api.ById("addtag").Click();
                api.ById("TagNameSelResult").SelectTxt(ToBeTestTag[i]).Exe();

                Thread.Sleep(1000);
                api.ByName("PageSizeSel").Enter("").Submit().Exe();
                PrintStep("Set and get " + ToBeTestTag[i] + " alarm ODBC tag data");
                EventLog.AddLog("Get " + ToBeTestTag[i] + " ODBC data");

                Thread.Sleep(5000);                                              // wait to get ODBC data

                api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[3]/a").Click(); // click time to sort data
                Thread.Sleep(5000);
                //api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[4]/a").Click();    // click tagname to sort data
                //Thread.Sleep(5000);

                bool bRes_ConAna = true;
                if (ToBeTestTag[i] == "ConAna_0001" || ToBeTestTag[i] == "ConAna_0125" || ToBeTestTag[i] == "ConAna_0250")
                {
                    bRes_ConAna = bCheckConAnaRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_ConDis = true;
                if (ToBeTestTag[i] == "ConDis_0001")
                {
                    bRes_ConDis = bCheckConDisRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_AI = true;
                if (ToBeTestTag[i] == "AT_AI0001")
                {
                    bRes_AI = bCheckAIRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_AO = true;
                if (ToBeTestTag[i] == "AT_AO0001")
                {
                    bRes_AO = bCheckAORecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_Sys = true;
                if (ToBeTestTag[i] == "SystemSec_0001")
                {
                    bRes_Sys = bCheckSysRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_Calc = true;
                if (ToBeTestTag[i] == "Calc_ConAna")
                {
                    bRes_Calc = bCheckCalcRecordAlarm(ToBeTestTag[i]);
                }

                if ((bRes_ConAna && bRes_AI && bRes_AO && bRes_Sys && bRes_Calc) == false)
                {
                    bCheckAlarm = false;
                    break;
                }
                // print screen
                EventLog.PrintScreen(ToBeTestTag[i] + "_AlarmLogData");

                api.ByXpath("//*[@id=\"div1\"]/table/tbody/tr[1]/td[3]/a[5]/font").Click();     //return to homepage
            }

            return(bCheckAlarm);
        }
Beispiel #25
0
        private void CreateMap(string sTestLogFolder)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);

            if (slanguage == "CHS")     // f**k china special case..
            {
                api.ByXpath("//a[contains(@href, '/broadWeb/bmap/bmapcreate.asp?')]").Click();
                System.Threading.Thread.Sleep(2000);

                EventLog.AddLog("Click 'New Google Map' test");
                api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp?')]").ClickAndWait(1000);
                EventLog.PrintScreen("CreateMapTest_GoogleMap");

                PrintStep("Google Map click test");
            }
            else
            {
                api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp')]").Click();
                System.Threading.Thread.Sleep(2000);

                //TestGoogleMap/BaiduMap
                EventLog.AddLog("Click 'New Baidu Map' test");
                api.ByXpath("//a[contains(@href, '/broadWeb/bmap/bmapcreate.asp?')]").ClickAndWait(1000);
                EventLog.PrintScreen("CreateMapTest_BiaduMap");

                EventLog.AddLog("Click 'New Google Map' test");
                api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp?')]").ClickAndWait(1000);
                EventLog.PrintScreen("CreateMapTest_GoogleMap");
                PrintStep("Google&Baidu Map click test");
            }

            //Excel-In sample map
            EventLog.AddLog("Excel in sample map");
            api.ByXpath("//a[contains(@href, 'gmaptoJsPg1.asp?pos=import')]").Click();
            string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location);
            string sourceSampleFile = sCurrentFilePath + "\\MapSample\\MapSample.xls";
            string destWApath       = @"C:\Inetpub\wwwroot\broadweb\gmap\MapSample.xls";

            System.IO.File.Copy(sourceSampleFile, destWApath, true);
            api.ByName("dataFileName").Clear();
            api.ByName("dataFileName").Enter("MapSample").Submit().Exe();
            api.ByName("act").Click();
            System.Threading.Thread.Sleep(2000);
            EventLog.PrintScreen("CreateMapTest_Import_SampleMap");
            PrintStep("Excel In Map");

            //Options
            EventLog.AddLog("Options setting...");
            EventLog.AddLog("Marker title font set");
            api.ByXpath("(//a[contains(@href, '#')])[4]").Click();
            System.Threading.Thread.Sleep(1000);
            api.ByXpath("(//input[@name='aa'])[2]").Click();
            System.Threading.Thread.Sleep(500);
            api.ByXpath("(//input[@name='aa'])[3]").Click();
            System.Threading.Thread.Sleep(500);
            api.ByXpath("(//input[@name='aa'])[1]").Click();
            System.Threading.Thread.Sleep(500);

            api.ByXpath("(//input[@name='bb'])[2]").Click();
            System.Threading.Thread.Sleep(500);
            api.ByXpath("(//input[@name='bb'])[1]").Click();
            System.Threading.Thread.Sleep(500);

            api.ByXpath("//input[@id='cc']").Click();
            api.ByXpath("//div[@id='fontpicker']/div").Click(); //Font Family = "Microsoft YaHei"
            System.Threading.Thread.Sleep(500);
            api.ByXpath("//select[@id='dd']").Click();
            api.ByXpath("//select[@id='dd']").Enter("16").Exe();   //Font Size = 16
            System.Threading.Thread.Sleep(500);
            //api.ById("ee").Clear();
            //api.ById("ee").Enter("FF0000").Exe();   //Title Color = RED
            //System.Threading.Thread.Sleep(1000);
            PrintStep("Marker Title Font setting");

            EventLog.AddLog("Marker label font set");
            api.ByXpath("//input[@id='ff']").Click();
            api.ByXpath("//div[@id='fontpicker']/div[19]").Click(); //Font Family = "Bookman Old Style"
            System.Threading.Thread.Sleep(500);
            api.ByXpath("//select[@id='gg']").Click();
            api.ByXpath("//select[@id='gg']").Enter("16").Exe();   //Font Size = 16
            System.Threading.Thread.Sleep(500);
            api.ById("hh").Clear();
            api.ById("hh").Enter("0000FF").Exe();   //Title Color = Bule
            System.Threading.Thread.Sleep(500);

            api.ById("ee").Clear();
            api.ById("ee").Enter("FF00EE").Exe();   //Title Color = Purple
            System.Threading.Thread.Sleep(500);

            api.ByXpath("//div[@id='opt']/div[27]/input").Click();
            System.Threading.Thread.Sleep(500);
            PrintStep("Marker Label Font");

            //Save
            EventLog.AddLog("Save map");
            api.ByXpath("(//a[contains(@href, '#')])[2]").Click();
            System.Threading.Thread.Sleep(1000);
            SendKeys.SendWait("{ENTER}");
            System.Threading.Thread.Sleep(1000);
            PrintStep("Save");
            EventLog.PrintScreen("CreateMapTest_ModifiedMap");
            System.Threading.Thread.Sleep(1000);

            //Excel-Out
            EventLog.AddLog("Excel out modified map");
            api.ByXpath("//a[contains(@href, 'gmaptoJsPg1.asp?pos=export')]").Click();
            api.ByName("chk").Click();
            api.ByName("dataFileName").Clear();
            api.ByName("dataFileName").Enter("gmap_" + DateTime.Now.ToString("yyyyMMdd")).Submit().Exe();
            api.ByName("act").Click();
            PrintStep("Excel Out Map");

            try
            {
                string sourceFile = @"C:\Inetpub\wwwroot\broadweb\gmap\gmap_" + DateTime.Now.ToString("yyyyMMdd") + ".xls";
                string destFile   = sTestLogFolder + "\\CreateMapTest_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".xls";
                EventLog.AddLog("Copy export file form " + sourceFile + " to " + destFile);
                System.IO.File.Copy(sourceFile, destFile, true);
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                EventLog.AddLog(ex.ToString());
            }

            //Delete
            EventLog.AddLog("Delete map");
            api.ByXpath("(//a[contains(@href, '#')])[3]").Click();
            System.Threading.Thread.Sleep(1000);
            api.Accept();
            System.Threading.Thread.Sleep(1000);
            PrintStep("Delete");
        }
Beispiel #26
0
        private void CreateGlobalScript()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/GbScript/GbScriptPg.asp')]").Click();

            switch (slanguage)
            {
            case "ENG":
                api.ByName("StatusSel_1").SelectTxt("Enable").Exe();
                break;

            case "CHT":
                api.ByName("StatusSel_1").SelectTxt("啟用").Exe();
                break;

            case "CHS":
                api.ByName("StatusSel_1").SelectTxt("允许").Exe();
                break;

            case "JPN":
                api.ByName("StatusSel_1").SelectTxt("稼動").Exe();
                break;

            case "KRN":
                api.ByName("StatusSel_1").SelectTxt("가동").Exe();
                break;

            case "FRN":
                api.ByName("StatusSel_1").SelectTxt("Activer").Exe();
                break;

            default:
                api.ByName("StatusSel_1").SelectTxt("Enable").Exe();
                break;
            }
            api.ByName("Description_1").Clear();
            api.ByName("Description_1").Enter("Set each Const tag plus 1").Exe();
            api.ByName("RunScript_1").Clear();
            api.ByName("RunScript_1").Enter("ConstTag_Set.scr").Exe();
            api.ByName("RunInterval_1").Clear();
            api.ByName("RunInterval_1").Enter("200").Exe();

            switch (slanguage)
            {
            case "ENG":
                api.ByName("StatusSel_2").SelectTxt("Enable").Exe();
                break;

            case "CHT":
                api.ByName("StatusSel_2").SelectTxt("啟用").Exe();
                break;

            case "CHS":
                api.ByName("StatusSel_2").SelectTxt("允许").Exe();
                break;

            case "JPN":
                api.ByName("StatusSel_2").SelectTxt("稼動").Exe();
                break;

            case "KRN":
                api.ByName("StatusSel_2").SelectTxt("가동").Exe();
                break;

            case "FRN":
                api.ByName("StatusSel_2").SelectTxt("Activer").Exe();
                break;

            default:
                api.ByName("StatusSel_2").SelectTxt("Enable").Exe();
                break;
            }
            api.ByName("Description_2").Clear();
            api.ByName("Description_2").Enter("Set all ConAna 51").Exe();
            api.ByName("StartScript_2").Clear();
            api.ByName("StartScript_2").Enter("alm_set_ConAna_51.scr").Exe();

            switch (slanguage)
            {
            case "ENG":
                api.ByName("StatusSel_3").SelectTxt("Enable").Exe();
                break;

            case "CHT":
                api.ByName("StatusSel_3").SelectTxt("啟用").Exe();
                break;

            case "CHS":
                api.ByName("StatusSel_3").SelectTxt("允许").Exe();
                break;

            case "JPN":
                api.ByName("StatusSel_3").SelectTxt("稼動").Exe();
                break;

            case "KRN":
                api.ByName("StatusSel_3").SelectTxt("가동").Exe();
                break;

            case "FRN":
                api.ByName("StatusSel_3").SelectTxt("Activer").Exe();
                break;

            default:
                api.ByName("StatusSel_3").SelectTxt("Enable").Exe();
                break;
            }
            api.ByName("RunScript_3").Clear();
            api.ByName("RunScript_3").Enter("alm_ack.scr").Exe();
            api.ByName("RunInterval_3").Clear();
            api.ByName("RunInterval_3").Enter("2400").Submit().Exe();   // 2400 = 60s
        }
Beispiel #27
0
        private void CreateConstantTag()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[6]/font/b").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/tag/tagPg.asp') and contains(@href, 'dt=ConType')]").Click();

            // Constant  (analog)
            EventLog.AddLog("create analog constant");
            api.ByName("ParaName").SelectVal("ConAna").Exe();
            Thread.Sleep(1000);

            switch (slanguage)
            {
            case "ENG":
                api.ByName("AlarmStatus").SelectTxt("Alarm").Exe();
                break;

            case "CHT":
                api.ByName("AlarmStatus").SelectTxt("警報").Exe();
                break;

            case "CHS":
                api.ByName("AlarmStatus").SelectTxt("报警").Exe();
                break;

            case "JPN":
                api.ByName("AlarmStatus").SelectTxt("アラーム").Exe();
                break;

            case "KRN":
                api.ByName("AlarmStatus").SelectTxt("알람").Exe();
                break;

            case "FRN":
                api.ByName("AlarmStatus").SelectTxt("Alarme").Exe();
                break;

            default:
                api.ByName("AlarmStatus").SelectTxt("Alarm").Exe();
                break;
            }

            Thread.Sleep(1000);
            api.ByName("RocPriority").SelectVal("1").Exe();
            Thread.Sleep(500);
            api.ByName("RateOfChange").Clear();
            api.ByName("RateOfChange").Enter("5").Exe();    //設定數值據烈變化大於5%發出警報
            SetupBasicAnalogTagConfig();
            for (int i = 1; i <= 5; i++)
            {
                try
                {
                    //api.ByName("Value").Clear();
                    //api.ByName("Value").Enter(string.Format("{0}", i * i * 10)).Exe();
                    api.ByName("TagName").Clear();
                    api.ByName("TagName").Enter("ConAna_" + i.ToString("0000")).Submit().Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateConstantTag error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create Analog Constant Tags");

            // Constant  (discrete)
            EventLog.AddLog("create discrete constant");
            api.ByName("ParaName").SelectVal("ConDis").Exe();
            Thread.Sleep(1000);
            SetupBasicDigitalTagConfig();
            for (int i = 1; i <= 5; i++)
            {
                try
                {
                    api.ByName("TagName").Clear();
                    api.ByName("TagName").Enter("ConDis_" + i.ToString("0000")).Submit().Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateConstantTag error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create DiscreteConstant Tags");

            // Constant  (text)
            EventLog.AddLog("create text constant");
            api.ByName("ParaName").SelectVal("ConTxt").Exe();
            Thread.Sleep(1000);
            SetupBasicTextTagConfig();
            for (int i = 1; i <= 5; i++)
            {
                try
                {
                    api.ByName("TagName").Clear();
                    api.ByName("TagName").Enter("ConTxt_" + i.ToString("0000")).Submit().Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateConstantTag error: " + ex.ToString());
                    i--;
                }
            }
            PrintStep("Create Text Constant Tags");
        }
Beispiel #28
0
        bool CreateRecipe(string Recipe_File_Name, string Unit_Name, string Recipe_Name, string Value)
        {
            try
            {
                api.ByName("FileName").Clear();
                api.ByName("FileName").Enter(Recipe_File_Name).Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("UnitName").Clear();
                api.ByName("UnitName").Enter(Unit_Name).Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("RecipeName").Clear();
                api.ByName("RecipeName").Enter(Recipe_Name).Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("ItemName_1").Clear();
                api.ByName("ItemName_1").Enter("ItemName_1").Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("ItemName_2").Clear();
                api.ByName("ItemName_2").Enter("ItemName_2").Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("TagName001").Clear();
                api.ByName("TagName001").Enter("ConAna_0249").Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("TagName002").Clear();
                api.ByName("TagName002").Enter("ConAna_0250").Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("PreValue_1").Clear();
                api.ByName("PreValue_1").Enter(Value).Exe();
                System.Threading.Thread.Sleep(1000);
                api.ByName("PreValue_2").Clear();
                api.ByName("PreValue_2").Enter(Value).Exe();
                System.Threading.Thread.Sleep(1000);

                int iSubmitResult = api.ByName("PreValue_3").Enter("").Submit().Exe();
                if (iSubmitResult == 0)
                {
                    EventLog.AddLog("Create success!!");
                    return(true);
                }
                else
                {
                    EventLog.AddLog("Create fail!!");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                EventLog.AddLog(ex.ToString());
                return(false);
            }
        }
Beispiel #29
0
        private void Create_Report()
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/syslog/RptList.asp')]").Click();
            api.ByXpath("//a[contains(@href, '/broadWeb/syslog/rptPg.asp') and contains (@href, 'action=new')]").Click();

            api.ByName("ReportName").Clear();
            api.ByName("ReportName").Enter("ReportTest").Exe();
            api.ByName("Title1").Clear();
            api.ByName("Title1").Enter("OverAll Title").Exe();
            api.ByName("Title2").Clear();
            api.ByName("Title2").Enter("Page Title").Exe();
            api.ByName("Title3").Clear();
            api.ByName("Title3").Enter("SubTitle").Exe();
            api.ByName("ReportText1").Clear();
            api.ByName("ReportText1").Enter("ReportTest").Exe();

            // 最大上限12個tag
            string[] ReportTagName = { "Calc_ConAna", "Calc_ConDis", "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI", "Calc_ModBusDO",
                                       "Calc_OPCDA",  "Calc_OPCUA",  "Calc_System",   "AT_AI0100",     "AT_DI0100",     "ConAna_0100" };
            for (int i = 1; i <= 12; i++)
            {
                api.ByName("TagName" + i.ToString("000")).Clear();
                api.ByName("TagName" + i.ToString("000")).Enter(ReportTagName[i - 1]).Exe();
            }

            //Shift Report//
            api.ByName("ShiftReport").Click();
            api.ByName("ShiftEmailTo").Clear();
            api.ByName("ShiftEmailTo").Enter("*****@*****.**").Exe();
            api.ByName("ExcelRpt1").Click();

            //api.ByName("ShiftEditTag").Click();
            api.ByXpath("//input[@name='ShiftEditTag']").Click();
            for (int m = 1; m <= 4; m++)
            {
                api.ByName("Title" + m.ToString("0") + "_1").Clear();
                api.ByName("Title" + m.ToString("0") + "_1").Enter("shift_tag1_title" + m).Exe();
            }
            api.ByName("DispFactor").Clear();
            api.ByName("DispFactor").Enter("10").Submit().Exe();

            //Daily Report//
            api.ByName("DailyReport").Click();
            api.ByName("DailyEmailTo").Clear();
            api.ByName("DailyEmailTo").Enter("*****@*****.**").Exe();
            api.ByName("ExcelRpt2").Click();

            //api.ByName("DailyEditTag").Click();
            api.ByXpath("//input[@name='DailyEditTag']").Click();
            for (int m = 1; m <= 4; m++)
            {
                api.ByName("Title" + m.ToString("0") + "_1").Clear();
                api.ByName("Title" + m.ToString("0") + "_1").Enter("daily_tag1_title" + m).Exe();
            }
            api.ByName("DispFactor").Clear();
            api.ByName("DispFactor").Enter("10").Submit().Exe();

            //Monthly Report//
            api.ByName("MonthReport").Click();
            api.ByName("MonthEmailTo").Clear();
            api.ByName("MonthEmailTo").Enter("*****@*****.**").Exe();
            api.ByName("ExcelRpt3").Click();

            //api.ByName("MonthEditTag").Click();
            api.ByXpath("//input[@name='MonthEditTag']").Click();
            for (int m = 1; m <= 4; m++)
            {
                api.ByName("Title" + m.ToString("0") + "_1").Clear();
                api.ByName("Title" + m.ToString("0") + "_1").Enter("month_tag1_title" + m).Exe();
            }
            api.ByName("DispFactor").Clear();
            api.ByName("DispFactor").Enter("10").Submit().Exe();


            api.ByName("ReportName").Enter("").Submit().Exe();
        }
Beispiel #30
0
        private void CreateOPCComportDevice()
        {
            // Create com port
            EventLog.AddLog("Create com port");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            Thread.Sleep(1000);
            api.ByName("infName").SelectVal("OPC").Exe();
            Thread.Sleep(1000);
            api.ByName("ComportNbr").Clear();
            api.ByName("ComportNbr").Enter("4").Exe();  // comport = 4
            api.ByName("OPCServer").Clear();
            api.ByName("OPCServer").Enter("Kepware.KEPServerEX.V5").Submit().Exe();
            //api.ByName("submit").Click();
            Thread.Sleep(1000);
            PrintStep("Create OPC Communication Port");

            // add device
            EventLog.AddLog("add device");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=comport') and contains(@href, 'name=4')]").Click(); // name = 4
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            api.ByName("DeviceName").Clear();
            api.ByName("DeviceName").Enter("OPCDA").Submit().Exe();
            //api.ByName("submit").Click();
            api.Refresh();
            PrintStep("Create OPCDA Device");
        }