예제 #1
2
        private void CombinationLoop()
        {
            while (true)
            {
                if (!bRun)
                {
                    if (bRunCmd)
                        bRunCmd = false;
                    Thread.Sleep(100);
                    continue;
                }
                
                if (packer.status == PackerStatus.RUNNING)
                {
                    if (agent.bWeightReady)
                    {
                        TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                        bSimCombine = true;
                        foreach (byte b in packer.weight_nodes)
                        {
                            bSimNodeValid[b] = true;
                            Debug.WriteLine(agent.weight(b) + ",");
                        }

                        while (CheckCombination())
                            ;
                        CheckCombination();
                        bSimCombine = false;

                        ProcessGoonNodes();
                        while (CheckCombination())
                        {
                            while ((vibstate != VibStatus.VIB_READY) && bRun)
                            {
                                vibstate = agent.UpdateVibStatus(packer.vib_addr,vibstate);
                            }
                            if (bRun)
                            {
                                ReleaseAction(release_addrs, release_weight); //send release command and clear weight, trigger the packer, goon the nodes
                                vibstate = agent.TriggerPacker(packer.vib_addr);
                                if (vibstate == VibStatus.VIB_WORKING)
                                {
                                    ProcessGoonNodes();
                                    agent.WaitUntilFlagSent((agent[packer.vib_addr] as VibrateNode));
                                }
                                while ((vibstate == VibStatus.VIB_WORKING && bRun))
                                {
                                    ProcessGoonNodes();
                                    vibstate = agent.UpdateVibStatus(packer.vib_addr, vibstate);
                                }
                                
                                q_hits.Enqueue(new CombineEventArgs((byte)packer._pack_id, release_addrs, release_wts, release_weight));
                            }
                            if (!bRun)
                                break;
                        }
                        if (!bRun)
                            continue;
                        
                        while (ProcessGoonNodes())
                            ;
                        CheckNodeStatus();
                        agent.ClearWeights();
                        logTimeStick(ts1, "fina:");  
                        agent.bWeightReady = false;
                        agent.Action(packer.vib_addr, "fill");
                    }
                }
                else
                {
                  
                    if (vibstate != VibStatus.VIB_READY)
                    {
                        vibstate = agent.UpdateVibStatus(packer.vib_addr,vibstate);
                        
                    }
                }
                Thread.Sleep(20);
            }
        }
예제 #2
0
        internal NodeAgent()
        {
            allports = new List<SPort>();
            weight_nodes = new List<WeighNode>();
            nodemap = new Dictionary<byte, SubNode>();
            lastrelease = new Dictionary<byte, DateTime>();
            vibstate = VibStatus.VIB_INIDLE;
            

            msg_loop = new Thread(new ThreadStart(MessageLoop));
            msg_loop.IsBackground = true;


            LoadConfiguration();
            
            
        }
예제 #3
0
        public VibStatus UpdateVibStatus(byte vibaddr,VibStatus vibstate)
        {
            VibrateNode vn = this[vibaddr] as VibrateNode;
            if (!vn.intf_byte.b_Handshake)
            {
                return VibStatus.VIB_READY;
            }

            VibStatus oldstate = vibstate;
            if(!mut.WaitOne(300))
                return vibstate;
            if (vibstate == VibStatus.VIB_WORKING)
            {
                
                if (CheckPackerDone(vibaddr)) //check botton pack count increase
                {
                    vibstate = VibStatus.VIB_INIDLE;
                    Debug.WriteLine("idle");
                }
            }
            if (vibstate == VibStatus.VIB_INIDLE)
            {
                if (CheckPackerReady(vibaddr))//hw_status == 0
                {
                    Debug.WriteLine("ready");
                    vibstate = VibStatus.VIB_READY;
                }
            }
            mut.ReleaseMutex();
            if (vibstate != oldstate)
                RefreshEvent(this);
            
            return vibstate;
        }
예제 #4
0
 public void ResetStatus()
 {
     agent.ClearWeights();
     vibstate = agent.ResetVibStatus(packer.vib_addr);
 }