Beispiel #1
0
 private void base_bt_fresh_Click(object sender, EventArgs e)
 {
     if (PayBox != null)
     {
         PayBox.Dispose();
         PayBox = null;
     }
     for (int i = 0; i < base_comname.Items.Count; i++)
     {
         try
         {
             CNGPI.CNGPIPayBox box = new CNGPI.CNGPIPayBox(Devinfo, base_comname.Items[i].ToString());
             box.OnIODebug   += Box_OnIODebug;
             box.OnReviceMsg += Box_OnReviceMsg;
             if (box.ConnectAndShakeHands())
             {
                 PayBox = box;
                 break;
             }
         }
         catch (Exception ex)
         {
             event_txt.AppendText(ex.ToString());
         }
     }
     PayBoxConnect();
 }
Beispiel #2
0
 private void base_bt_conn_Click(object sender, EventArgs e)
 {
     if (PayBox == null)
     {
         try
         {
             CNGPI.CNGPIPayBox box = new CNGPI.CNGPIPayBox(Devinfo, base_comname.Text.ToString());
             box.OnIODebug   += Box_OnIODebug;
             box.OnReviceMsg += Box_OnReviceMsg;
             if (box.ConnectAndShakeHands())
             {
                 PayBox = box;
             }
         }
         catch (Exception ex)
         {
             event_txt.AppendText(ex.ToString());
         }
         if (PayBox != null)
         {
             base_bt_conn.Text = "断开连接";
         }
     }
     else
     {
         PayBox.Dispose();
         PayBox            = null;
         base_bt_conn.Text = "连接并握手";
     }
     PayBoxConnect();
 }