227 def _apply(mask, is_neg):
229 QView._glb_filter &= ~mask
231 QView._glb_filter |= mask
233 QView._glb_filter = 0
238 if isinstance(arg, str):
239 is_neg = (arg[0] ==
'-')
243 arg = QSpy._QS.index(arg)
246 'arg="' + arg +
'"\n' +
247 traceback.format_exc(3))
255 _apply(1 << arg, is_neg)
257 _apply(QSpy._GLB_FLT_MASK_ALL, is_neg)
259 _apply(QSpy._GLB_FLT_MASK_SM, is_neg)
261 _apply(QSpy._GLB_FLT_MASK_AO, is_neg)
263 _apply(QSpy._GLB_FLT_MASK_MP, is_neg)
265 _apply(QSpy._GLB_FLT_MASK_EQ, is_neg)
267 _apply(QSpy._GLB_FLT_MASK_TE, is_neg)
269 _apply(QSpy._GLB_FLT_MASK_QF, is_neg)
271 _apply(QSpy._GLB_FLT_MASK_SC, is_neg)
273 _apply(QSpy._GLB_FLT_MASK_SEM, is_neg)
275 _apply(QSpy._GLB_FLT_MASK_MTX, is_neg)
277 _apply(QSpy._GLB_FLT_MASK_U0, is_neg)
279 _apply(QSpy._GLB_FLT_MASK_U1, is_neg)
281 _apply(QSpy._GLB_FLT_MASK_U2, is_neg)
283 _apply(QSpy._GLB_FLT_MASK_U3, is_neg)
285 _apply(QSpy._GLB_FLT_MASK_U4, is_neg)
287 _apply(QSpy._GLB_FLT_MASK_UA, is_neg)
289 assert 0,
"invalid global filter arg=0x%X"%(arg)
291 QSpy._sendTo(pack(
"<BBQQ", QSpy._TRGT_GLB_FILTER, 16,
292 QView._glb_filter & 0xFFFFFFFFFFFFFFFF,
293 QView._glb_filter >> 64))
492 Tk.report_callback_exception = QView._trap_error
495 main_menu = Menu(root, tearoff=0)
496 root.config(menu=main_menu)
499 m = Menu(main_menu, tearoff=0)
500 m.add_command(label=
"Save QSPY Dictionaries",
501 command=QView._onSaveDict)
502 m.add_command(label=
"Toggle QSPY Text Output",
503 command=QView._onSaveText)
504 m.add_command(label=
"Toggle QSPY Binary Output",
505 command=QView._onSaveBin)
506 m.add_command(label=
"Toggle Matlab Output",
507 command=QView._onSaveMatlab)
508 m.add_command(label=
"Toggle Sequence Output",
509 command=QView._onSaveSequence)
511 m.add_command(label=
"Exit", command=QView._quit)
512 main_menu.add_cascade(label=
"File", menu=m)
515 m = Menu(main_menu, tearoff=0)
516 QView._view_canvas = IntVar()
517 QView._view_frame = IntVar()
518 m.add_checkbutton(label=
"Canvas", variable=QView._view_canvas,
519 command=QView._onCanvasView)
520 m.add_checkbutton(label=
"Frame", variable=QView._view_frame,
521 command=QView._onFrameView)
522 main_menu.add_cascade(label=
"View", menu=m)
525 m = Menu(main_menu, tearoff=0)
526 m.add_command(label=
"SM Group...", accelerator=
"[NONE]",
527 command=QView._onGlbFilter_SM)
528 m.add_command(label=
"AO Group...", accelerator=
"[NONE]",
529 command=QView._onGlbFilter_AO)
530 m.add_command(label=
"QF Group...", accelerator=
"[NONE]",
531 command=QView._onGlbFilter_QF)
532 m.add_command(label=
"TE Group...", accelerator=
"[NONE]",
533 command=QView._onGlbFilter_TE)
534 m.add_command(label=
"MP Group...", accelerator=
"[NONE]",
535 command=QView._onGlbFilter_MP)
536 m.add_command(label=
"EQ Group...", accelerator=
"[NONE]",
537 command=QView._onGlbFilter_EQ)
538 m.add_command(label=
"SC Group...", accelerator=
"[NONE]",
539 command=QView._onGlbFilter_SC)
540 m.add_command(label=
"SEM Group...", accelerator=
"[NONE]",
541 command=QView._onGlbFilter_SEM)
542 m.add_command(label=
"MTX Group...", accelerator=
"[NONE]",
543 command=QView._onGlbFilter_MTX)
545 m.add_command(label=
"U0 Group...", accelerator=
"[NONE]",
546 command=QView._onGlbFilter_U0)
547 m.add_command(label=
"U1 Group...", accelerator=
"[NONE]",
548 command=QView._onGlbFilter_U1)
549 m.add_command(label=
"U2 Group...", accelerator=
"[NONE]",
550 command=QView._onGlbFilter_U2)
551 m.add_command(label=
"U3 Group...", accelerator=
"[NONE]",
552 command=QView._onGlbFilter_U3)
553 m.add_command(label=
"U4 Group...", accelerator=
"[NONE]",
554 command=QView._onGlbFilter_U4)
555 main_menu.add_cascade(label=
"Global-Filters", menu=m)
556 QView._menu_glb_filter = m
559 m = Menu(main_menu, tearoff=0)
560 m.add_command(label=
"AO IDs...", accelerator=
"[NONE]",
561 command=QView._onLocFilter_AO)
562 m.add_command(label=
"EP IDs...", accelerator=
"[NONE]",
563 command=QView._onLocFilter_EP)
564 m.add_command(label=
"EQ IDs...", accelerator=
"[NONE]",
565 command=QView._onLocFilter_EQ)
566 m.add_command(label=
"AP IDs...", accelerator=
"[NONE]",
567 command=QView._onLocFilter_AP)
569 m.add_command(label=
"AO-OBJ...", command=QView._onLocFilter_AO_OBJ)
570 main_menu.add_cascade(label=
"Local-Filters", menu=m)
571 QView._menu_loc_filter = m
574 m = Menu(main_menu, tearoff=0)
575 m.add_command(label=
"SM_OBJ", command=QView._onCurrObj_SM)
576 m.add_command(label=
"AO_OBJ", command=QView._onCurrObj_AO)
577 m.add_command(label=
"MP_OBJ", command=QView._onCurrObj_MP)
578 m.add_command(label=
"EQ_OBJ", command=QView._onCurrObj_EQ)
579 m.add_command(label=
"TE_OBJ", command=QView._onCurrObj_TE)
580 m.add_command(label=
"AP_OBJ", command=QView._onCurrObj_AP)
582 m1 = Menu(m, tearoff=0)
583 m1.add_command(label=
"SM_OBJ", command=QView._onQueryCurr_SM)
584 m1.add_command(label=
"AO_OBJ", command=QView._onQueryCurr_AO)
585 m1.add_command(label=
"MP_OBJ", command=QView._onQueryCurr_MP)
586 m1.add_command(label=
"EQ_OBJ", command=QView._onQueryCurr_EQ)
587 m1.add_command(label=
"TE_OBJ", command=QView._onQueryCurr_TE)
588 m1.add_command(label=
"AP_OBJ", command=QView._onQueryCurr_AP)
589 m.add_cascade(label=
"Query Current", menu=m1)
590 main_menu.add_cascade(label=
"Current-Obj", menu=m)
591 QView._menu_curr_obj = m
594 m = Menu(main_menu, tearoff=0)
595 m.add_command(label=
"Reset Target", command=QView.reset_target)
596 m.add_command(label=
"Query Target Info", command=QView._onTargetInfo)
597 m.add_command(label=
"Tick[0]", command=QView._onTick0)
598 m.add_command(label=
"Tick[1]", command=QView._onTick1)
601 m.add_command(label=
"Clear QSPY Screen", command=QView._onClearQspy)
605 main_menu.add_cascade(label=
"Commands", menu=m)
606 QView._menu_commands = m
609 m = Menu(main_menu, tearoff=0)
610 m.add_command(label=
"Publish...", command=QView._onEvt_PUBLISH)
611 m.add_command(label=
"Post...", command=QView._onEvt_POST)
612 m.add_command(label=
"Init SM", command=QView._onEvt_INIT)
613 m.add_command(label=
"Dispatch...", command=QView._onEvt_DISPATCH)
614 main_menu.add_cascade(label=
"Events", menu=m)
615 QView._menu_events = m
618 m = Menu(main_menu, tearoff=0)
620 main_menu.add_cascade(label=
"Custom", menu=m)
621 QView.custom_menu = m
624 m = Menu(main_menu, tearoff=0)
625 m.add_command(label=
"Online Help", command=QView._onHelp)
627 m.add_command(label=
"About...", command=QView._onAbout)
628 main_menu.add_cascade(label=
"Help", menu=m)
631 QView._scroll_text = IntVar()
632 QView._scroll_text.set(1)
633 QView._echo_text = IntVar()
634 QView._echo_text.set(0)
635 frame = Frame(root, borderwidth=1, relief=
"raised")
636 QView._target = Label(frame, height=2,
637 text=
"Target: " + QSpy._fmt_target)
638 QView._target.pack(side=
"left")
639 c = Checkbutton(frame, text=
"Scroll", variable=QView._scroll_text)
641 c = Checkbutton(frame, text=
"Echo", variable=QView._echo_text,
642 command=QSpy._reattach)
644 QView._tx = Label(frame, width=6, anchor=E,
645 borderwidth=1, relief=
"sunken")
646 QView._tx.pack(side=
"right")
647 Label(frame, text=
"Tx ").pack(side=
"right")
648 QView._rx = Label(frame, width=8, anchor=E,
649 borderwidth=1, relief=
"sunken")
650 QView._rx.pack(side=
"right")
651 Label(frame, text=
"Rx ").pack(side=
"right")
652 frame.pack(side=
"bottom", fill=
"x", pady=0)
655 frame = Frame(root, borderwidth=1, relief=
"sunken")
656 scrollbar = Scrollbar(frame)
657 QView._text = Text(frame, width=100, height=30,
658 wrap=
"word", yscrollcommand=scrollbar.set)
659 QView._text.bind(
"<Key>",
lambda e:
"break")
660 scrollbar.config(command=QView._text.yview)
661 scrollbar.pack(side=
"right", fill=
"y")
662 QView._text.pack(side=
"left", fill=
"both", expand=
True)
663 frame.pack(side=
"left", fill=
"both", expand=
True)
666 QView._canvas_toplevel = Toplevel()
667 QView._canvas_toplevel.withdraw()
668 QView._canvas_toplevel.protocol(
"WM_DELETE_WINDOW",
669 QView._onCanvasClose)
670 QView._canvas_toplevel.title(
"QView -- Canvas")
671 QView.canvas = Canvas(QView._canvas_toplevel)
675 QView._frame_toplevel = Toplevel()
676 QView._frame_toplevel.withdraw()
677 QView._frame_toplevel.protocol(
"WM_DELETE_WINDOW",
679 QView._frame_toplevel.title(
"QView -- Frame")
680 QView.frame = Frame(QView._frame_toplevel)
684 QView._locAO_OBJ = StringVar()
685 QView._currObj = (StringVar(), StringVar(), StringVar(),
686 StringVar(), StringVar(), StringVar())
687 QView._command = StringVar()
688 QView._command_p1 = StringVar()
689 QView._command_p2 = StringVar()
690 QView._command_p3 = StringVar()
691 QView._note = StringVar()
692 QView._note_kind = StringVar(value=0)
693 QView._peek_offs = StringVar()
694 QView._peek_dtype = StringVar(value=QView._dtypes[2])
695 QView._peek_len = StringVar()
696 QView._poke_offs = StringVar()
697 QView._poke_dtype = StringVar(value=QView._dtypes[2])
698 QView._poke_data = StringVar()
699 QView._evt_act = StringVar()
700 QView._evt_sig = StringVar()
701 QView._evt_par = (StringVar(), StringVar(), StringVar(),
702 StringVar(), StringVar(), StringVar(),
703 StringVar(), StringVar(), StringVar())
704 QView._evt_dtype = (StringVar(), StringVar(), StringVar(),
705 StringVar(), StringVar(), StringVar(),
706 StringVar(), StringVar(), StringVar())
707 for i
in range(len(QView._evt_par)):
708 QView._evt_dtype[i].set(QView._dtypes[2])
767 def _update_glb_filter_menu(label, mask):
768 x = (QView._glb_filter & mask)
775 QView._menu_glb_filter.entryconfig(label,
779 def _update_loc_filter_menu(label, mask):
780 x = (QView._loc_filter & mask)
787 QView._menu_loc_filter.entryconfig(label,
790 for i
in range(len(QView._currObj)):
791 QView._menu_curr_obj.entryconfig(i,
792 accelerator=QView._currObj[i].get())
793 QView._menu_events.entryconfig(0,
794 accelerator=QView._currObj[QView.OBJ_AO].get())
795 QView._menu_events.entryconfig(1,
796 accelerator=QView._currObj[QView.OBJ_AO].get())
797 QView._menu_events.entryconfig(2,
798 accelerator=QView._currObj[QView.OBJ_SM].get())
799 QView._menu_events.entryconfig(3,
800 accelerator=QView._currObj[QView.OBJ_SM].get())
801 QView._menu_commands.entryconfig(8,
802 accelerator=QView._currObj[QView.OBJ_AP].get())
803 QView._menu_commands.entryconfig(9,
804 accelerator=QView._currObj[QView.OBJ_AP].get())
808 if QView._currObj[QView.OBJ_SM].get() ==
"":
809 state_SM =
"disabled"
810 if QView._currObj[QView.OBJ_AO].get() ==
"":
811 state_AO =
"disabled"
812 if QView._currObj[QView.OBJ_AP].get() ==
"":
814 QView._menu_events.entryconfig(0, state=state_AO)
815 QView._menu_events.entryconfig(1, state=state_AO)
816 QView._menu_events.entryconfig(2, state=state_SM)
817 QView._menu_events.entryconfig(3, state=state_SM)
818 QView._menu_commands.entryconfig(8, state=state_AP)
819 QView._menu_commands.entryconfig(9, state=state_AP)
821 _update_glb_filter_menu(
"SM Group...", QSpy._GLB_FLT_MASK_SM)
822 _update_glb_filter_menu(
"AO Group...", QSpy._GLB_FLT_MASK_AO)
823 _update_glb_filter_menu(
"QF Group...", QSpy._GLB_FLT_MASK_QF)
824 _update_glb_filter_menu(
"TE Group...", QSpy._GLB_FLT_MASK_TE)
825 _update_glb_filter_menu(
"MP Group...", QSpy._GLB_FLT_MASK_MP)
826 _update_glb_filter_menu(
"EQ Group...", QSpy._GLB_FLT_MASK_EQ)
827 _update_glb_filter_menu(
"SC Group...", QSpy._GLB_FLT_MASK_SC)
828 _update_glb_filter_menu(
"SEM Group...", QSpy._GLB_FLT_MASK_SEM)
829 _update_glb_filter_menu(
"MTX Group...", QSpy._GLB_FLT_MASK_MTX)
830 _update_glb_filter_menu(
"U0 Group...", QSpy._GLB_FLT_MASK_U0)
831 _update_glb_filter_menu(
"U1 Group...", QSpy._GLB_FLT_MASK_U1)
832 _update_glb_filter_menu(
"U2 Group...", QSpy._GLB_FLT_MASK_U2)
833 _update_glb_filter_menu(
"U3 Group...", QSpy._GLB_FLT_MASK_U3)
834 _update_glb_filter_menu(
"U4 Group...", QSpy._GLB_FLT_MASK_U4)
836 _update_loc_filter_menu(
"AO IDs...", QSpy._LOC_FLT_MASK_AO)
837 _update_loc_filter_menu(
"EP IDs...", QSpy._LOC_FLT_MASK_EP)
838 _update_loc_filter_menu(
"EQ IDs...", QSpy._LOC_FLT_MASK_EQ)
839 _update_loc_filter_menu(
"AP IDs...", QSpy._LOC_FLT_MASK_AP)
840 QView._menu_loc_filter.entryconfig(
"AO-OBJ...",
841 accelerator=QView._locAO_OBJ.get())