Esempio n. 1
0
def cb_indicator(n, msg):
    global Indicates
    item = Indicates[n]
    if msg.data:
        timeout.set(functools.partial(cb_turnon, n), 0)
    else:
        if "sto" in item: timeout.clear(item["sto"])
        timeout.set(functools.partial(cb_turnoff, n), 0)
Esempio n. 2
0
def cb_run(n):
    global Launches, msgBox, msgBoxWait
    if msgBoxWait is not None: return
    item = Launches[n]
    if item["state"] == 0:
        if ".launch" in item["file"]:
            cmd = ["roslaunch", item["package"], item["file"]]
        else:
            cmd = ["xterm", "-e", "rosrun", item["package"], item["file"]]
        if "args" in item:
            for k in item["args"]:
                cmd.append(k + ":=" + str(item["args"][k]))
        proc = subprocess.Popen(cmd)
        item["tag"]["foreground"] = litcolor
        item["tag"]["font"] = boldfont
        item["button"]["image"] = stopicon
        item["process"] = proc
        item["state"] = 1
        timeout.set(functools.partial(cb_runstat, (n, 2)), 3)
        if "pre" in item:
            print "dash pre", item["pre"]
            subprocess.Popen(item["pre"].split())
    elif item["state"] == 2:
        if "confirm" in item:
            if item["confirm"]:
                w = item["tag"]
                msgBox = tk.Tk()
                msgBox.title("Confirm")
                msgBox.geometry("100x30+" + str(w.winfo_rootx()) + "+" +
                                str(w.winfo_rooty() + 30))
                msgBoxWait = msgBox.after(Config["autoclose"] * 1000,
                                          cb_autoclose)
                msg = Config["confirm"]
                if "message" in Config:
                    if "halt" in Config["message"]:
                        msg = Config["message"]["halt"]
                    elif "launch" in Config["message"]:
                        msg = Config["message"]["launch"]
                elif "label" in Config:
                    if "confirm" in Config["label"]:
                        msg = Config["label"]["confirm"]
                f = tkMessageBox.askyesno("Confirm", msg, parent=msgBox)
                if msgBoxWait is None: return
                msgBox.after_cancel(msgBoxWait)
                msgBoxWait = None
                msgBox.destroy()
                if f is False: return
        item["process"].terminate()
        item["state"] = 3
        timeout.set(functools.partial(cb_stop, n), 1)
        if "post" in item:
            print "dash post", item["post"]
            subprocess.Popen(item["post"].split())
Esempio n. 3
0
def cb_display(n):
    global Displays
    item = Displays[n]
    widget = item["tag"]
    try:
        val = str(rospy.get_param(item["name"]))
        if val != widget["text"]:
            widget.configure(text=val)
    except Exception:
        print "cb_display::get param failed", item["name"]
    n = n + 1
    if n >= len(Displays): n = 0
    timeout.set(functools.partial(cb_display, n), 0.5)
Esempio n. 4
0
def cb_load(msg):
  if wRecipe is None: return
  Param["recipe"]=msg.data
  timeout.set(functools.partial(cb_wRecipe,Param["recipe"]),0)
  if os.system("ls "+dirpath+"/"+Param["recipe"])==0:
    rospy.set_param("/dashboard",Param)
    commands.getoutput("rm "+linkpath+";ln -s "+dirpath+"/"+Param["recipe"]+" "+linkpath)
    commands.getoutput("rosparam load "+linkpath+"/param.yaml")
    res=Bool(); res.data=True; pub_Y3.publish(res)
    pub_msg.publish("recipe_manager::cb_load "+Param["recipe"])
  else:
    pub_E3.publish(Bool())
    pub_msg.publish("recipe_manager::cb_load failed "+Param["recipe"])
Esempio n. 5
0
def cb_turnon(n):
  global Indicates
  item=Indicates[n]
  item["tag"]["foreground"]=litcolor
  item["tag"]["font"]=boldfont
  if "sto" in item: timeout.clear(item["sto"])
  item["sto"]=timeout.set(functools.partial(cb_turnoff,n),item["timeout"])
Esempio n. 6
0
def cb_load(msg):
    global Param, RecipeName
    if wRecipe is None: return
    Param["recipe"] = msg.data
    recipe = msg.data.split(':')
    RecipeName = recipe[0]
    timeout.set(functools.partial(cb_wRecipe, Param["recipe"]), 0)
    if os.system("ls " + dirpath + "/" + RecipeName) == 0:
        set_param_sync("/dashboard", Param)
        commands.getoutput("rm " + linkpath)
        commands.getoutput("ln -s " + dirpath + "/" + RecipeName + " " +
                           linkpath)
        commands.getoutput("rosparam load " + linkpath + "/param.yaml")
        if len(recipe) > 1:
            commands.getoutput("rosparam load " + linkpath + "/" +
                               str(recipe[1]) + ".yaml")
        pub_Y3.publish(mTrue)
    else:
        pub_E3.publish(mFalse)
Esempio n. 7
0
def cb_mbox_push(n, msg):
    if n == 0:
        timeout.set(functools.partial(mbox.push, msg), 0)
    else:
        timeout.set(functools.partial(ebox.push, msg), 0)
Esempio n. 8
0
def cb_redraw():
    timeout.set(lambda: pub_redraw.publish(mTrue), 0)
Esempio n. 9
0
                          background=maskcolor,
                          foreground=unlitcolor)
        wlabel.pack(side='left', fill='y', anchor='w')
        wbtn = tk.Button(root,
                         image=starticon,
                         background=bgcolor,
                         bd=0,
                         highlightthickness=0,
                         command=functools.partial(cb_run, n))
        wbtn.pack(side='left', fill='y', anchor='w', padx=(0, 10))
        item["tag"] = wlabel
        item["button"] = wbtn
        item["state"] = 0
        if "auto" in item:
            if item["auto"] >= 0:
                timeout.set(functools.partial(cb_run, n), item["auto"])
        Launches.append(item)

tk.Button(root,
          image=redrawicon,
          bd=0,
          background=bgcolor,
          highlightthickness=0,
          command=cb_redraw).pack(side='right', anchor='nw', padx=(0, 0))
ckeys.sort(reverse=True)
for key in ckeys:
    if key.startswith('indic'):
        item = Config[key]
        n = len(Indicates)
        wlabel = tk.Label(root,
                          text=item["label"],
Esempio n. 10
0
def cb_update(s):
  timeout.set(to_update,0)
Esempio n. 11
0
def cb_report(s):
  ss=s.data[-1:-1]
  dic=eval(s.data)
  timeout.set(functools.partial(to_report,dic),0)