Ejemplo n.º 1
0
        public OpcReaJetAdapter()
        {
            this.IsInitialized = false;
            this.IsActive = false;

            this.m_Settings = new OpcReajetAdapterSettings();

            InitializeLogging();
        }
Ejemplo n.º 2
0
        private static OpcReajetAdapterSettings ReadSettings()
        {
            OpcReajetAdapterSettings settings = null;
               // SiAuto.Main.EnterMethod(this, "ReadSettings");
            try
            {
                /*--------- Your code goes here-------*/
                settings = new OpcReajetAdapterSettings();

                settings.portName = ConfigurationManager.AppSettings["Stencil_RS232_portName"];
                //settings.s = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_startBit"]);
                settings.dataBits = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_dataBits"]);
                settings.baudRate = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_baudRate"]);
                settings.readTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_readTimeOut"]);
                settings.writeTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_writeTimeOut"]);
                settings.ackTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_ackTimeOut"]);
                settings.replyTelegramTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["Stencil_RS232_replyTelegramTimeOut"]);
                settings.HSK_INPUT_PARAMS_TAG = ConfigurationManager.AppSettings["Handshake_InputParamsTag"];
                settings.HSK_TRIGGER_TAG = ConfigurationManager.AppSettings["Handshake_TriggerTag"];
                settings.HSK_TRIGGER_FROM = Convert.ToByte(ConfigurationManager.AppSettings["Handshake_triggerFromValue"]);
                settings.HSK_TRIGGER_TO = Convert.ToByte(ConfigurationManager.AppSettings["Handshake_triggerToValue"]);
                settings.HSK_OUTPUT_PARAMS_TAG = ConfigurationManager.AppSettings["Handshake_OutputParamsTag"];
                settings.HSK_ACK_TAG = ConfigurationManager.AppSettings["Handshake_AckTag"];

                switch (ConfigurationManager.AppSettings["Stencil_RS232_parity"].ToString().ToLower())
                {
                    case "none":
                        settings.parity = Parity.None;
                        break;
                    case "odd":
                        settings.parity = Parity.Odd;
                        break;
                    case "even":
                        settings.parity = Parity.Even;
                        break;
                    default:
                        settings.parity = Parity.None;
                        break;
                }
                switch (ConfigurationManager.AppSettings["Stencil_RS232_stopBits"].ToLower())
                {
                    case "none":
                    case "0":
                        settings.stopBits = StopBits.None;
                        break;
                    case "one":
                    case "1":
                        settings.stopBits = StopBits.One;
                        break;
                    case "onepointfive":
                    case "one_point_five":
                    case "1.5":
                        settings.stopBits = StopBits.OnePointFive;
                        break;
                    case "two":
                    case "2":
                        settings.stopBits = StopBits.Two;
                        break;
                    default:
                        settings.stopBits = StopBits.One;
                        break;
                }
                /*------------------------------------*/
            }
            catch (Exception ex)
            {
                SiAuto.Main.LogException(ex);
                throw ex;
            }
            finally
            {
               // SiAuto.Main.LeaveMethod(this, "ReadSettings");
            }

            return settings;
        }