Exemple #1
0
        private void btn_changeaddr_Click(object sender, EventArgs e)
        {
            if (lb_addrfrom.SelectedIndex <= 0)
            {
                Program.MsgShow(GetText("select_addrfrom"));
                return;
            }
            if (lb_addrto.SelectedIndex < 0)
            {
                Program.MsgShow(GetText("select_addrto"));
                return;
            }
            btn_changeaddr.Visible = false;
            SubNode n = nodemap[nodelist[lb_addrfrom.SelectedIndex]];

            n["test_mode_reg2"] = Convert.ToByte(0xC0 + lb_addrto.SelectedIndex + 1);
            Thread.Sleep(500);
            this.Invoke(new CompleteFlashHandler(CompleteFlash), new object[] { Convert.ToByte(lb_addrto.SelectedIndex + 1), btn_changeaddr });
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            sp         = null;
            nodemap    = new Dictionary <byte, SubNode>();
            nodestatus = new Dictionary <byte, Pernode>();
            nodelist   = new List <byte>();
            lb_addrto.SelectedIndex = 0;
            cb_com.SelectedIndex    = 0;
//            lb_typeto.SelectedIndex = 0;
            if (GetRegistData("locale") == "zh-CN")
            {
                language = "zh-CN";
            }
            else
            {
                language = "en-US";
            }
            SubNode.Dummy();
            panel4.Visible = false;
//            panel2.Visible = false;
            panel3.Visible = false;
        }
Exemple #3
0
        private void UpdateAllNodeStatus()
        {
            if (bOpen == false)
            {
                panel4.Visible = false;
                panel3.Visible = false;
                lb_addrfrom.Items.Clear();
                btn_open.Text = GetText("Open");
                return;
            }
            else
            {
                panel4.Visible = true;
                panel3.Visible = true;
            }
            btn_open.Text = GetText("Close");

            nodemap.Clear();
            nodestatus.Clear();
            nodelist.Clear();
            lb_addrfrom.Items.Clear();

            lb_addrfrom.Items.Add("All boards");
            nodelist.Add(0);
            byte[] tofind = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36 };
            foreach(byte i in tofind)
            {
                SubNode n = new SubNode(sp, i);
                n.status = NodeStatus.ST_IDLE;
                n["addr"] = null;
                if (!WaitForIdleSlow(n))
                    continue;
                n["board_id"] = null;//get board typ
                if (!WaitForIdleSlow(n))
                    continue;
                string org = n["board_id"].Value.ToString();
                n["fw_rev_uw"] = null;//get revistion
                if (!WaitForIdleSlow(n))
                    continue;
                nodemap[i] = n;
                nodestatus[i] = new Pernode();
                
                string type = "Unknown";
                if(n["board_id"].Value >= 16 && n["board_id"].Value < 32)
                    type = "Weight Node";
                if(n["board_id"].Value < 16)
                    type = "Top Node    ";
                lb_addrfrom.Items.Add("Node " + i.ToString("D2") + "  ; Type: " + type + "  ; Rev: " + n["fw_rev_uw"].Value.ToString());
                nodelist.Add(i);
            }
        }
Exemple #4
0
 private bool WaitForIdleSlow(SubNode n)
 {
     int i = 2;
     //int j = 0;
     while (n.status == NodeStatus.ST_BUSY)
     {
         Thread.Sleep(5);
         //i = i + (i + 1) / 2; //8,12,18,28,42,64,96,
         if (i++ > 30)
         {
             return false;
         }
     }
     return true;
 }
Exemple #5
0
        private void UpdateAllNodeStatus()
        {
            if (bOpen == false)
            {
                panel4.Visible = false;
                panel3.Visible = false;
                lb_addrfrom.Items.Clear();
                btn_open.Text = GetText("Open");
                return;
            }
            else
            {
                panel4.Visible = true;
                panel3.Visible = true;
            }
            btn_open.Text = GetText("Close");

            nodemap.Clear();
            nodestatus.Clear();
            nodelist.Clear();
            lb_addrfrom.Items.Clear();

            lb_addrfrom.Items.Add("All boards");
            nodelist.Add(0);
            byte[] tofind = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36 };
            foreach (byte i in tofind)
            {
                SubNode n = new SubNode(sp, i);
                n.status  = NodeStatus.ST_IDLE;
                n["addr"] = null;
                if (!WaitForIdleSlow(n))
                {
                    continue;
                }
                n["board_id"] = null;//get board typ
                if (!WaitForIdleSlow(n))
                {
                    continue;
                }
                string org = n["board_id"].Value.ToString();
                n["fw_rev_uw"] = null;//get revistion
                if (!WaitForIdleSlow(n))
                {
                    continue;
                }
                nodemap[i]    = n;
                nodestatus[i] = new Pernode();

                string type = "Unknown";
                if (n["board_id"].Value >= 16 && n["board_id"].Value < 32)
                {
                    type = "Weight Node";
                }
                if (n["board_id"].Value < 16)
                {
                    type = "Top Node    ";
                }
                lb_addrfrom.Items.Add("Node " + i.ToString("D2") + "  ; Type: " + type + "  ; Rev: " + n["fw_rev_uw"].Value.ToString());
                nodelist.Add(i);
            }
        }
Exemple #6
0
 public bootloader(SubNode n)
 {
     node = n;
 }
Exemple #7
0
 public bootloader(SubNode n)
 {
     node = n;
 }