Esempio n. 1
0
        /// <summary>
        /// Call out Window Setting of Wireless module
        /// </summary>
        /// <param name="lstlstobjInput"></param>
        /// <param name="lstlstobjOutput"></param>
        /// <returns></returns>
        public object PluginWirelessModule1000(List <List <object> > lstlstobjInput, out List <List <object> > lstlstobjOutput)
        {
            lstlstobjOutput = new List <List <object> >();
            List <object> lstObj = new List <object>();

            ///////////////////////////////////////////////////////
            if (this.clsNECWirelessControl == null)
            {
                this.clsNECWirelessControl = new clsWirelessCom();
            }

            this.clsNECWirelessControl.WindowSettingNEC = new windowWirelessSetting();
            this.clsNECWirelessControl.IniFormSetting();

            int intProcessID = 0;

            if (int.TryParse(lstlstobjInput[0][1].ToString(), out intProcessID) == false)
            {
                return("Error: Process ID is not integer!");
            }

            this.clsNECWirelessControl.WindowSettingNEC.intProcessID = intProcessID;
            this.clsNECWirelessControl.WindowSettingNEC.Show();

            ///////////////////////////////////////////////////////
            return("0");
        }
Esempio n. 2
0
        /// <summary>
        /// Ini for class Wireless control & Reading Comport setting for Receiver unit from User.ini
        ///     + para 1 (13) : Name of Setting File
        ///     + para 2 (14) : Section Name
        ///     + para 3 (15): Name Port
        ///     + para 4 (16): Baud Rate
        ///     + para 5 (17): DataBits
        ///     + para 6 (18): Parity
        ///     + Para 7 (19): StopBits
        ///     + Para 8 (20): Module Serial - Default value
        /// </summary>

        public object PluginWirelessModule0(List <List <object> > lstlstobjInput, out List <List <object> > lstlstobjOutput)
        {
            lstlstobjOutput = new List <List <object> >();
            string strAppPath  = lstlstobjInput[0][0].ToString();
            string strFileName = @"\" + lstlstobjInput[0][13].ToString();

            strFileName = strAppPath + strFileName;
            if (MyLibrary.ChkExist.CheckFileExist(strFileName) == false)
            {
                return("Error: Setting file is not exist");
            }
            string strTmp         = "";
            string strSectionName = lstlstobjInput[0][14].ToString();
            string strKeyPortName = "";
            string strKeyBaudRate = "";
            string strKeyDataBits = "";
            string strKeyParity   = "";
            string strKeyStopBits = "";
            string strKeyModuleID = "";

            //Ini for class
            if (this.clsNECWirelessControl == null)
            {
                this.clsNECWirelessControl = new clsWirelessCom();
            }


            //calculate string File name
            int strProcessID = 0;

            if (int.TryParse(lstlstobjInput[0][1].ToString(), out strProcessID) == false)
            {
                return("Error: Process ID is not numeric");
            }

            strKeyPortName = lstlstobjInput[0][15].ToString().Trim();
            strKeyBaudRate = lstlstobjInput[0][16].ToString().Trim();
            strKeyDataBits = lstlstobjInput[0][17].ToString().Trim();
            strKeyParity   = lstlstobjInput[0][18].ToString().Trim();
            strKeyStopBits = lstlstobjInput[0][19].ToString().Trim();
            strKeyModuleID = lstlstobjInput[0][20].ToString().Trim();

            //reading COM port Name
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyPortName, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find " + strKeyPortName + " setting in " + strSectionName);   //getting key value fail
            }
            this.clsNECWirelessControl.COMPort.PortName = strTmp.ToUpper();
            //reading BaudRate
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyBaudRate, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find 'BaudRate' setting in " + strSectionName);   //getting key value fail
            }
            this.clsNECWirelessControl.COMPort.BaudRate = Convert.ToInt32(strTmp);

            //reading DataBits
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyDataBits, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find 'DataBits' setting in " + strSectionName);   //getting key value fail
            }
            this.clsNECWirelessControl.COMPort.DataBits = Convert.ToInt32(strTmp);

            //reading Parity
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyParity, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find 'Parity' setting in " + strSectionName);   //getting key value fail
            }
            switch (strTmp.ToUpper())
            {
            case "EVEN":
                this.clsNECWirelessControl.COMPort.Parity = System.IO.Ports.Parity.Even;
                break;

            case "ODD":
                this.clsNECWirelessControl.COMPort.Parity = System.IO.Ports.Parity.Odd;
                break;

            case "NONE":
                this.clsNECWirelessControl.COMPort.Parity = System.IO.Ports.Parity.None;
                break;

            default:
                this.clsNECWirelessControl.COMPort.Parity = System.IO.Ports.Parity.Even;
                break;
            }

            //reading stopBits
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyStopBits, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find 'StopBits' setting in " + strSectionName);   //getting key value fail
            }
            switch (strTmp.ToUpper())
            {
            case "ONE":
                this.clsNECWirelessControl.COMPort.StopBits = System.IO.Ports.StopBits.One;
                break;

            case "TWO":
                this.clsNECWirelessControl.COMPort.StopBits = System.IO.Ports.StopBits.Two;
                break;

            case "ONEPOITFIVE":
                this.clsNECWirelessControl.COMPort.StopBits = System.IO.Ports.StopBits.OnePointFive;
                break;

            case "NONE":
                this.clsNECWirelessControl.COMPort.StopBits = System.IO.Ports.StopBits.None;
                break;

            default:
                this.clsNECWirelessControl.COMPort.StopBits = System.IO.Ports.StopBits.One;
                break;
            }

            //Getting Module ID - Default
            strTmp = MyLibrary.ReadFiles.IniReadValue(strSectionName, strKeyModuleID, strFileName);
            if (strTmp.ToLower() == "error")
            {
                return("Error: cannot find 'ModuleID' setting in " + strSectionName);   //getting key value fail
            }
            this.clsNECWirelessControl.strModuleSerial = strTmp;

            //Try to Open COMPort
            try
            {
                if (this.clsNECWirelessControl.COMPort.IsOpen == false) //Not yet open
                {
                    this.clsNECWirelessControl.COMPort.Open();
                }
                else //Already open => Try to close & open again
                {
                    this.clsNECWirelessControl.COMPort.Close();
                    this.clsNECWirelessControl.COMPort.Open();
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            //Return Class of NEC Wireless control through User Return data
            List <object> lstobjTemp = new List <object>();

            lstobjTemp.Add("NEC");
            lstobjTemp.Add(this.clsNECWirelessControl);
            lstlstobjOutput.Add(lstobjTemp);

            //Return 0 if everything is OK
            return("0");
        }