//update UI when a packer is hitted public void CombineNodeUI(CombineEventArgs ce) { foreach (byte naddr in currentApp().packers[ce.packer_id].weight_nodes) { string param = "wei_node" + naddr.ToString(); Label lb = this.FindName(param) as Label; Button btn = this.FindName(param.Replace("wei_node", "bucket")) as Button; NodeAgent agent = currentApp().packers[ce.packer_id].agent; //update weight first double wt = -100000; for (int i = 0; i < ce.release_addrs.Length; i++) { if (ce.release_addrs[i] == naddr) { wt = ce.release_wts[i]; break; } } if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) lb.Content = wt.ToString("F1"); //update status display if (agent.GetStatus(naddr) == NodeStatus.ST_LOST || agent.GetStatus(naddr) == NodeStatus.ST_DISABLED) { btn.Template = this.FindResource("WeightBarError") as ControlTemplate; } else if (naddr != curr_packer.vib_addr) { if (ce.release_addrs.Contains(naddr)) btn.Template = this.FindResource("WeightBarRelease") as ControlTemplate; else { btn.Template = this.FindResource("WeightBar") as ControlTemplate; } } btn.ApplyTemplate(); } //Update speed information UIPacker p = currentApp().packers[ce.packer_id]; if (p.status == PackerStatus.RUNNING) { lbl_speed.Content = p.speed.ToString(); lbl_lastweight.Content = p.last_pack_weight.ToString("F1"); lbl_totalpack.Content = p.total_packs.ToString(); RefreshVibUI(); } }
private void HitCombineNodeUI(CombineEventArgs ce) { foreach (byte naddr in currentApp().packers[ce.packer_id].weight_nodes) { string param = "wei_node" + naddr.ToString(); Label lb = this.FindName(param) as Label; Button btn = this.FindName(param.Replace("wei_node", "bucket")) as Button; byte n = (byte)(RunMode.StringToId(param)); NodeAgent agent = currentApp().packers[ce.packer_id].agent; if (!ce.release_addrs.Contains(n)) continue; double wt = agent.weight(n); if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) lb.Content = agent.weight(n).ToString("F1"); if (agent.GetStatus(n) == NodeStatus.ST_LOST || agent.GetStatus(n) == NodeStatus.ST_DISABLED) { btn.Template = this.FindResource("WeightBarError") as ControlTemplate; }else{ if (n != curr_packer.vib_addr) { if(ce.release_addrs.Contains(n)) btn.Template = this.FindResource("WeightBarRelease") as ControlTemplate; else{ btn.Template = this.FindResource("WeightBar") as ControlTemplate; if (agent.GetStatus(n) == NodeStatus.ST_IDLE) { if (btn == curr_btn || bSelectAll) btn.Template = this.FindResource("WeightBarFocus") as ControlTemplate; } } } } btn.ApplyTemplate(); } }