public static UsbPollModem ModemInstance()
 {
     if (PollModem == null)
     {
         PollModem = new UsbPollModem();
     }
     return(PollModem);
 }
        public void Config(param p_inst)
        {
            inst   = p_inst;
            custid = inst.cust_id;
            conn   = inst.conn; // db connection
            //selectedDate = inst.dt;
            org  = inst.org;
            indx = inst.indx;
            tc   = inst.tc; // used to select next index


            String dbconn = ConfigurationManager.AppSettings["ConnectionString"];

            conn = new SqlConnection(dbconn);
            try
            {
                // conn.Open();
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                SqlCommand cmd2 = new SqlCommand(SqlPCustAll, conn);
                using (SqlDataReader reader = cmd2.ExecuteReader())
                {
                    c_cuidList.Clear();
                    c_pollList.Clear();
                    // OrgList.Clear();
                    while (reader.Read())
                    {
                        c_cuidList.Add(Convert.ToInt32(reader[0])); // p cust id
                        this.listBoxOrgs.Items.Add(Convert.ToString(reader[1]));
                        c_pollList.Add(Convert.ToBoolean(reader[2]));
                    }
                    reader.Close();
                }
                if (c_cuidList.Count > 0)
                {
                    listBoxOrgs.SelectedIndex = 0;
                    // gen event
                    object    sender = new object();
                    EventArgs e      = new EventArgs();
                    this.listBoxOrgs_SelectedIndexChanged(sender, e);
                }
                lblPollSeconds.Text = Convert.ToString(ConfigurationManager.AppSettings["GenPollTime"]) + " Seconds";;
                // Modem Set up
                BaudRate = Convert.ToInt16(ConfigurationManager.AppSettings["GPRSBaudRate"]);
                try
                {
                    //com = "COM10";
                    com = Convert.ToString(ConfigurationManager.AppSettings["PollMODEM"]);
                    if (com != null)
                    {
                        //gprs = new GsmCommMain(port, BaudRate, 1000);              //
                        gprsPoll = new UsbPollModem();
                        // gprsPoll.smsEvent += new SmsMessageIndication(gprs_smsEvent);
                        // gprsPoll.MsgRxdEnableInterrupt(this.usbPollport);
                        try
                        {
                            this.usbPollport = gprsPoll.OpenPort(com, BaudRate, 8, 300, 300);
                            if (gprsPoll != null) //if (ModemSts)
                            {
                                // Attach SMS message event handler
                                // gprsPoll.smsEvent +=new SmsMessageIndication(gprs_smsEvent);
                                gprsPoll.ModemStatus = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            // ModemSts = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    //ModemSts = false;
                    // EventLog.WriteEntry("AeiGenAlert: Comm  is Closed");
                }

                this.usbPollport.DataReceived += new SerialDataReceivedEventHandler(gprs_dataReceived);
                // Attach SMS message event handler
                // gprs.smsEvent +=new SmsMessageIndication(gprs_smsEvent);
                gprsPoll.MsgRxdEnableInterrupt(this.usbPollport);
                //; ;............ end Modem .....
                timer1.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["GenPollTime"]) * 1000;
                timer1.Enabled  = true;
                timer1.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(" PollGens - Initz error: " + ex.Message);
            }
        }  // End of init/config