Пример #1
0
        public short AB_LoadConf()
        {
            string tmpstr;
            short  ret;
            short  i, j;
            int    id, port;

            byte [] ip = new byte[20];

            GwCnt = API2.AB_GW_Cnt();
            if (GwCnt == 0)
            {
                return(0);
            }

            for (i = 0; i < GwCnt; i++)
            {
                ret = API2.AB_GW_Conf(i, out id, out ip[0], out port);
                if (ret >= 0)
                {
                    GwConf[i].gw_id = (short)id;
                    GwConf[i].port  = (short)port;

                    for (j = 0; j < 20; j++)
                    {
                        if (ip[j] == 0)
                        {
                            break;
                        }
                    }

                    tmpstr       = System.Text.Encoding.ASCII.GetString(ip, 0, j);
                    GwConf[i].ip = tmpstr;
                }
                else
                {
                    GwConf[i].gw_id = 0;
                    GwConf[i].port  = 0;
                    GwConf[i].ip    = "";
                }
            }
            return(GwCnt);
        }
Пример #2
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            int i, cnt, ret;

            btnRecv_Click(sender, e);
            loopcnt++;
            if (loopcnt < 50)
            {
                return;
            }

            loopcnt = 0;
            cnt     = API2.AB_GW_Cnt();
            for (i = 0; i < cnt; i++)
            {
                ret = API2.AB_GW_Status(GwConf[i].gw_id);
                lstGwStatus.Items[i] = "Gateway index:" + Convert.ToString(i + 1) + " " + AB_ErrMsg(ret);
            }
        }