Example #1
0
 public BottomWnd()
 {
     InitializeComponent();
     this.BackColor = SingleModeWnd.bgWindow;
     vib_intf = new Intf(0);
     btn_ret.Focus();
     UpdateDisplay();
     btn_ret.Click += new EventHandler(btn_return_Click);
     btn_ret_run.Click += new EventHandler(btn_ret_run_Click);
     intf_ckb_delay.GotFocus += new EventHandler(TextBox_GotFocus);
     intf_pulse_width.GotFocus += new EventHandler(TextBox_GotFocus);
     intf_lb_feed_times.GotFocus += new EventHandler(TextBox_GotFocus);
     intf_input_trigger.SelectedIndexChanged += new EventHandler(intf_input_trigger_GotFocus);
     intf_output_trigger.SelectedIndexChanged += new EventHandler(intf_input_trigger_GotFocus);
     intf_handshake.Click +=new EventHandler(intf_handshake_Click);
     intf_ckb_mem.Click += new EventHandler(intf_handshake_Click);
     btn_run.Click += new EventHandler(btn_run_Click);
     this.panel1.BackColor = SingleModeWnd.bgWindow;
 }
Example #2
0
 public BottomWnd()
 {
     InitializeComponent();
     this.BackColor = SingleModeWnd.bgWindow;
     vib_intf       = new Intf(0);
     btn_ret.Focus();
     UpdateDisplay();
     btn_ret.Click                            += new EventHandler(btn_return_Click);
     btn_ret_run.Click                        += new EventHandler(btn_ret_run_Click);
     intf_ckb_delay.GotFocus                  += new EventHandler(TextBox_GotFocus);
     intf_pulse_width.GotFocus                += new EventHandler(TextBox_GotFocus);
     intf_lb_feed_times.GotFocus              += new EventHandler(TextBox_GotFocus);
     intf_input_trigger.SelectedIndexChanged  += new EventHandler(intf_input_trigger_GotFocus);
     intf_output_trigger.SelectedIndexChanged += new EventHandler(intf_input_trigger_GotFocus);
     intf_handshake.Click                     += new EventHandler(intf_handshake_Click);
     intf_ckb_mem.Click                       += new EventHandler(intf_handshake_Click);
     btn_run.Click                            += new EventHandler(btn_run_Click);
     this.panel1.BackColor                     = SingleModeWnd.bgWindow;
 }
Example #3
0
 internal VibrateNode(SPort _port,byte node_addr): base(_port,node_addr)
 {
     intf_byte = new Intf(0);
 }
Example #4
0
        public void Step()
        {
            //phase 0_start, 1_collect weight, 2_comb_release, 3 packer,
            if (phase == 0)
            {
                NodeMaster.ClearWeights(packer.wn_addrs);
                NodeMaster.Action(packer.wn_addrs, "query");
                phase = 10;
                return;
            }
            //collect weight
            if (phase == 10)
            {
                int cnt = packer.wn_addrs.Length;
                foreach (byte addr in packer.wn_addrs)
                {
                    double wt = NodeMaster.GetWeight(addr);
                    if(NodeMaster.GetStatus(addr) != NodeStatus.ST_IDLE)
                    {
                        cnt--;
                        continue;
                    }
                    if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                    cnt--;                 
                }
                if (cnt <= NodeAgent.LASTCOMB_NUM)
                {
                    phase = 20;
                    return;
                }
                //prepare for next round query
                if (cnt > 0)
                {
                byte[] addrs = new byte[cnt];
                    //
                int idx = 0;
                foreach (byte addr in packer.wn_addrs)
                {
                    if (NodeMaster.GetStatus(addr) != NodeStatus.ST_IDLE)
                    {
                            continue;
                        }
                        double wt = NodeMaster.GetWeight(addr);
                        if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                            continue;
                        
                        addrs[idx++] = addr;
                }
                }
                NodeMaster.Action(packer.wn_addrs, "query");
                return;
            }
            if (phase == 20)
            {
                if (packer.status != PackerStatus.RUNNING)
                {
                    phase = 0;
                    return;
                }
                //do simulated combination
                bSimCombine = true;
                foreach (byte b in packer.weight_nodes)
                    bSimNodeValid[b] = true;
                while (CheckCombination())
                    ;
                bSimCombine = false;
                foreach (byte b in packer.weight_nodes)
                {
                    if (!bSimNodeValid[b]) //has a combination
                    {
                        phase = 30;
                    }
                }
                if (phase == 30)
                    ProcessGoonNodes();
                else  //no combination at all
                {
                    while (ProcessGoonNodes())
                        ;
                    CheckNodeStatus();
                    phase = 0;
                    return;
                }
            }
            if (phase == 30)
            {
                if (!CheckCombination())
                {
                    phase = 50;
                    return;
                }
                ProcessGoonNodes();
                ReleaseAction(release_addrs, release_weight);
                q_hits.Enqueue(new CombineEventArgs((byte)packer._pack_id, release_addrs, release_wts, release_weight));
                

                Intf intf_reg = new Intf(Convert.ToUInt16(NodeMaster.GetNodeReg(packer.vib_addr, "target_weight")));
                //if (pack_cnt % (intf_reg.feed_times + 1) != 0)
                //{
                //    phase = 30;
                //    return;
                //}
                {
                    pack_cnt = 0;
                    NodeMaster.Action(new byte[] { packer.vib_addr }, "trigger");
                    ProcessGoonNodes();
                    phase = 40;
                }
            }
            if (phase == 40)
            {
                NodeMaster.RefreshNodeReg(packer.vib_addr, new string[] { "pack_rel_cnt" });
                UInt32 lw_ub = NodeMaster.GetNodeReg(packer.vib_addr, "pack_rel_cnt");
                if (lw_ub != release_cnt)
                {
                    release_cnt = lw_ub;
                    release_timeout = 0;
                    phase = 30;
                }
                else
                {
                    if (release_timeout++ > 4)
                    {
                        release_timeout = 0;
                        NodeMaster.Action(new byte[] { packer.vib_addr }, "trigger");
                    }
                    ProcessGoonNodes();
                    return;
                }
            }
            if (phase == 50)
            {
                NodeMaster.Action(new byte[] { packer.vib_addr }, "fill");
                while (ProcessGoonNodes())
                    ;
                CheckNodeStatus();
                phase = 0;
                return;
            }
           
            //do combination 
            //release action
        }
Example #5
0
        public void Step()
        {
            //phase 0_start, 1_collect weight, 2_comb_release, 3 packer,
            if (phase == 0)
            {
                NodeMaster.ClearWeights(packer.wn_addrs);
                NodeMaster.Action(packer.wn_addrs, "query");
                phase = 10;
                return;
            }
            //collect weight
            if (phase == 10)
            {
                int cnt = packer.wn_addrs.Length;
                foreach (byte addr in packer.wn_addrs)
                {
                    double wt = NodeMaster.GetWeight(addr);
                    if (NodeMaster.GetStatus(addr) != NodeStatus.ST_IDLE)
                    {
                        cnt--;
                        continue;
                    }
                    if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                    {
                        cnt--;
                    }
                }
                if (cnt <= NodeAgent.LASTCOMB_NUM)
                {
                    phase = 20;
                    return;
                }
                //prepare for next round query
                if (cnt > 0)
                {
                    byte[] addrs = new byte[cnt];
                    //
                    int idx = 0;
                    foreach (byte addr in packer.wn_addrs)
                    {
                        if (NodeMaster.GetStatus(addr) != NodeStatus.ST_IDLE)
                        {
                            continue;
                        }
                        double wt = NodeMaster.GetWeight(addr);
                        if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT)
                        {
                            continue;
                        }

                        addrs[idx++] = addr;
                    }
                }
                NodeMaster.Action(packer.wn_addrs, "query");
                return;
            }
            if (phase == 20)
            {
                if (packer.status != PackerStatus.RUNNING)
                {
                    phase = 0;
                    return;
                }
                //do simulated combination
                bSimCombine = true;
                foreach (byte b in packer.weight_nodes)
                {
                    bSimNodeValid[b] = true;
                }
                while (CheckCombination())
                {
                    ;
                }
                bSimCombine = false;
                foreach (byte b in packer.weight_nodes)
                {
                    if (!bSimNodeValid[b]) //has a combination
                    {
                        phase = 30;
                    }
                }
                if (phase == 30)
                {
                    ProcessGoonNodes();
                }
                else  //no combination at all
                {
                    while (ProcessGoonNodes())
                    {
                        ;
                    }
                    CheckNodeStatus();
                    phase = 0;
                    return;
                }
            }
            if (phase == 30)
            {
                if (!CheckCombination())
                {
                    phase = 50;
                    return;
                }
                ProcessGoonNodes();
                ReleaseAction(release_addrs, release_weight);
                q_hits.Enqueue(new CombineEventArgs((byte)packer._pack_id, release_addrs, release_wts, release_weight));


                Intf intf_reg = new Intf(Convert.ToUInt16(NodeMaster.GetNodeReg(packer.vib_addr, "target_weight")));
                //if (pack_cnt % (intf_reg.feed_times + 1) != 0)
                //{
                //    phase = 30;
                //    return;
                //}
                {
                    pack_cnt = 0;
                    NodeMaster.Action(new byte[] { packer.vib_addr }, "trigger");
                    ProcessGoonNodes();
                    phase = 40;
                }
            }
            if (phase == 40)
            {
                NodeMaster.RefreshNodeReg(packer.vib_addr, new string[] { "pack_rel_cnt" });
                UInt32 lw_ub = NodeMaster.GetNodeReg(packer.vib_addr, "pack_rel_cnt");
                if (lw_ub != release_cnt)
                {
                    release_cnt     = lw_ub;
                    release_timeout = 0;
                    phase           = 30;
                }
                else
                {
                    if (release_timeout++ > 4)
                    {
                        release_timeout = 0;
                        NodeMaster.Action(new byte[] { packer.vib_addr }, "trigger");
                    }
                    ProcessGoonNodes();
                    return;
                }
            }
            if (phase == 50)
            {
                NodeMaster.Action(new byte[] { packer.vib_addr }, "fill");
                while (ProcessGoonNodes())
                {
                    ;
                }
                CheckNodeStatus();
                phase = 0;
                return;
            }

            //do combination
            //release action
        }
Example #6
0
 internal VibrateNode(SPort _port, byte node_addr) : base(_port, node_addr)
 {
     intf_byte = new Intf(0);
 }