public void RefreshRunNodeUI() //node ui update at run time { lbl_status.Content = ""; foreach (UIPacker pk in currentApp().packers) { foreach (byte naddr in pk.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 = pk.agent; 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; btn.ApplyTemplate(); } string err = agent.GetErrors(n); if (err != "" && AlertWnd.b_turnon_alert && AlertWnd.b_show_alert) { lbl_status.Content = n.ToString() + ":" + StringResource.str(err.Substring(0, err.IndexOf(';'))) + "\n"; } } if (pk.status == PackerStatus.RUNNING) { lbl_speed.Content = pk.speed.ToString(); lbl_lastweight.Content = pk.last_pack_weight.ToString("F1"); lbl_totalpack.Content = pk.total_packs.ToString(); RefreshVibUI(); } } if (lbl_status.Content.ToString() == "") { lbl_status.Content = StringResource.str("normal"); lbl_status.Foreground = Brushes.Green; } else { lbl_status.Foreground = Brushes.Red; if (AlertWnd.b_turnon_alert && AlertWnd.b_stop_onalert && (curr_packer.status == PackerStatus.RUNNING)) { btn_start_click(null, null); } } }
private void RefreshNodeUI() { foreach (UIPacker pk in currentApp().packers) { foreach (byte naddr in pk.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[pk._pack_id].agent; double wt = agent.weight(n); if (wt > -1000 && wt <= WeighNode.MAX_VALID_WEIGHT) { lb.Content = agent.weight(n).ToString("F1"); } else { if (wt > WeighNode.MAX_VALID_WEIGHT && wt < 65537) { lb.Content = "ERR"; } } if (agent.GetStatus(n) == NodeStatus.ST_LOST || agent.GetStatus(n) == NodeStatus.ST_DISABLED) { btn.Template = this.FindResource("WeightBarError") as ControlTemplate; } if (agent.GetStatus(n) == NodeStatus.ST_IDLE) { if (btn == curr_btn || bSelectAll) { btn.Template = this.FindResource("WeightBarFocus") as ControlTemplate; } else { btn.Template = this.FindResource("WeightBar") as ControlTemplate; } } btn.ApplyTemplate(); } } UIPacker p = curr_packer; 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_sim_packs.ToString(); lbl_totalweights.Content = p.total_sim_weights.ToString("F1"); } }
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(); } }