def test_testcase3(self):
        """
        测试用例如下:
        implementation: s0 -but?-> s1, s1 -liq!-> s2, s1 -choc!-> s3
        specification: s0 -but?-> s1, s1 -liq!-> s2
        :return:
        """
        # implementation
        imp_root = Node(None, State("s0"))
        node1 = Node(Action("but", ActionEnum.INPUT), State("s1"))
        node2 = Node(Action("liq", ActionEnum.OUTPUT), State("s2"))
        node3 = Node(Action("choc", ActionEnum.OUTPUT), State("s3"))
        imp_root.children = [node1]
        node1.children = [node2, node3]
        imp = LTSTree(imp_root)

        # specification
        spec_root = Node(None, State("s0"))
        node1 = Node(Action("but", ActionEnum.INPUT), State("s1"))
        node2 = Node(Action("liq", ActionEnum.OUTPUT), State("s2"))
        spec_root.children = [node1]
        node1.children = [node2]
        spec = LTSTree(spec_root)

        self.assertFalse(imp.io_conform(spec),
                         msg="Error, test result: io conform!")
    def test_testcase2(self):
        """
        测试用例如下:
        implementation: s0 -but?-> s1, s1 -liq!-> s2
        specification: s0 -but?-> s1, s1 -liq!-> s2, s1 -choc-> s3
        :return: None
        """
        # implementation
        imp_root = Node(None, State("s0"))
        node1 = Node(Action("but", ActionEnum.INPUT), State("s1"))
        node2 = Node(Action("liq", ActionEnum.OUTPUT), State("s2"))
        imp_root.children = [node1]
        node1.children = [node2]
        imp = LTSTree(imp_root)

        # specification
        spec_root = Node(None, State("s0"))
        node1 = Node(Action("but", ActionEnum.INPUT), State("s1"))
        node2 = Node(Action("liq", ActionEnum.OUTPUT), State("s2"))
        node3 = Node(Action("choc", ActionEnum.OUTPUT), State("s3"))
        spec_root.children = [node1]
        node1.children = [node2, node3]
        spec = LTSTree(spec_root)

        self.assertTrue(imp.io_conform(spec), msg="io not conform")
 def test_testcase1(self):
     """
     测试用例如下:
     implementation:s0 -act1?-> s1
     specification: s0 -act1?-> s1
     :return: None
     """
     imp_root = Node(None, State("s0"))
     imp_root.children = [
         Node(Action("act1", ActionEnum.INPUT), State("s1"))
     ]
     spec_root = Node(None, State("s0"))
     spec_root.children = [
         Node(Action("act1", ActionEnum.INPUT), State("s1"))
     ]
     imp = LTSTree(imp_root)
     spec = LTSTree(spec_root)
     self.assertTrue(imp.io_conform(spec), msg="io not conform")
Esempio n. 4
0
 def executeAction(self, action, depth):
     log.info("%d -- Executing action: %s" % (depth, str(action)))
     node = self.nodes[action.node_name]
     action2 = action
     if hasattr(node,
                "discover_packets") and action.target == "send_packet":
         action2 = Action(action.node_name, action.target, [])
     if action2 not in self.actionList:
         self.actionList.append(action2)
     node.runAction(action)
Esempio n. 5
0
 def _get_action(self):
     """Return an action that can be used to activate the tool"""
     if not self._action:
         a = partial(active_tool.activate_tool, tool=self)
         self._action = Action(a,
                               self.menu,
                               group=self.group,
                               icon=self.icon,
                               shortcut=self.shortcut,
                               checkable=True,
                               parent=None)
     return self._action
Esempio n. 6
0
 def enableAction(self, target, args=(), skip_dup=False):
     if not isinstance(args, tuple):
         args = (args, )
     action = Action(self.name, target, args)
     action = self.model_checker.onEnableAction(self, action)
     if skip_dup == True and action in self.enabled_actions:
         return False
     self.log.debug("New enabled action: %s" % str(action))
     self.enabled_actions.append(action)
     self.log.debug("Enabled actions for '%s': %s" %
                    (self.name, self.enabled_actions))
     return True
Esempio n. 7
0
class RemoteApp:
    usb_active = False
    remote = False

    def __init__(self):
        self.logger = Logger()
        self.main_loop = MainLoop()
        self.usb = Usb()
        self.action = Action()
        Logger.log('Init RemoteApp', True)

    def run(self):
        self.main_loop.set_interval(self.main, .1)

    def find_usb_device(self):
        tty_usb = self.usb.find()
        if tty_usb:
            try:
                success = self.usb.setup(tty_usb)
                if success:
                    self.usb_active = True
            except Exception as error:
                Logger.error(error)

    def remote_action(self):
        error = self.usb.get_errors()
        if len(error):
            Logger.error(error)
            self.usb_active = False
        else:
            action_codes = self.usb.get_codes()
            for code in action_codes:
                self.action.run(code)

    def main(self):
        if not self.usb_active:
            self.find_usb_device()
        else:
            self.remote_action()
Esempio n. 8
0
 def run(self):
     """
     和某一台客户端通信
     :return:
     """
     while True:
         client_bytes = self.conn.recv(BUFFER_SIZE)
         if not client_bytes:  # 如果客户端断开,则跳出
             break
         client_str = str(client_bytes, 'utf8').strip()
         obj = Action(self.conn)
         cmd = client_str.split('|')
         if len(cmd) == 1:  # 为普通命令
             if client_str == 'exit':
                 break
             obj.cmd(client_str)
         elif len(cmd) > 1:  # 为传输文件的命令, 和客户端规定好,put|file;get|file
             action = cmd[1]
             file = cmd[2]
             is_exist = hasattr(obj, action)
             if is_exist:
                 func = getattr(obj, action)
                 func(file)
 def run(self):
     """
     和某一台客户端通信
     :return:
     """
     while True:
         client_bytes = self.conn.recv(BUFFER_SIZE)
         if not client_bytes:  # 如果客户端断开,则跳出
             break
         client_str = str(client_bytes, 'utf8').strip()
         obj = Action(self.conn)
         cmd = client_str.split('|')
         if len(cmd) == 1:   # 为普通命令
             if client_str == 'exit':
                 break
             obj.cmd(client_str)
         elif len(cmd) > 1:    # 为传输文件的命令, 和客户端规定好,put|file;get|file
             action = cmd[1]
             file = cmd[2]
             is_exist = hasattr(obj, action)
             if is_exist:
                 func = getattr(obj, action)
                 func(file)
Esempio n. 10
0
    def portStatsSpecial(self, state, dp_id):
        cnt_state = state.model.getControllerAppState()
        ser_state = cPickle.dumps((dp_id, cnt_state), -1)
        if ser_state not in self.contr_app_states_stats:
            self.contr_app_states_stats[ser_state] = self.generatePortStats(
                ser_state)
        else:
            #print "stats from cache"
            pass

        inputs = self.contr_app_states_stats[ser_state]
        assert len(inputs) > 0
        for inp in inputs:
            a = Action("ctrl", "port_stats", (dp_id, inp["ports"]))
            state.model.controller.enableAction("port_stats",
                                                (dp_id, inp["ports"]))
Esempio n. 11
0
def redo_():
    doc_ctrl.redo()
    viewer_3d.context.CloseLocalContext()
    viewer_3d.repaint0()
    viewer_3d.context.OpenLocalContext()
    if not doc_ctrl.document.GetAvailableRedos():
        redo.setEnabled(False)
    undo.setEnabled(True)


def on_doc_modified():
    redo.setEnabled(False)
    undo.setEnabled(True)


std_events.document_modified.connect(on_doc_modified)

undo = Action(undo_, ['&Edit', '&Undo'],
              icon='edit-undo',
              shortcut=QKeySequence.Undo,
              enabled=False)

redo = Action(redo_, ['&Edit', '&Redo'],
              icon='edit-redo',
              shortcut=QKeySequence.Redo,
              enabled=False)

toolbar_visible = True

list = [undo, redo]
Esempio n. 12
0
from lib.user import User
import socket
from lib.action import Action
import json

action = Action("SIGNIN", User("Jodic"))
print(action)

# connect 2 the server
HOST = "localhost"
PORT = 7777
clientSocked = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientSocked.connect((HOST, PORT))

clientSocked.send(action.toJSON().encode())

data = json.loads(clientSocked.recv(1024))
action = Action(data["type"])
print(action)
Esempio n. 13
0
 def __init__(self):
     self.logger = Logger()
     self.main_loop = MainLoop()
     self.usb = Usb()
     self.action = Action()
     Logger.log('Init RemoteApp', True)
Esempio n. 14
0
            _save()
        elif value == QMessageBox.Discard:
            sys.exit()
    # The value of 'dirty' was probably modified by _save()
    if not appdata.get('dirty'):
        sys.exit()


def on_dirty_changed():
    save.setEnabled(appdata.get('dirty'))


std_events.dirty_changed.connect(on_dirty_changed)

new = Action(new_, ['&File', '&New'],
             icon='document-new',
             shortcut=QtGui.QKeySequence.New)
open = Action(open_, ['&File', '&Open'],
              icon='document-open',
              shortcut=QtGui.QKeySequence.Open)
save = Action(_save, ['&File', '&Save'],
              icon='document-save',
              shortcut=QtGui.QKeySequence.Save)
save_as = Action(_save_as, ['&File', 'Save &As'],
                 icon='document-save-as',
                 shortcut=QtGui.QKeySequence.SaveAs)
quit = Action(quit_, ['&File', '&Quit'],
              icon='application-exit',
              shortcut=QtGui.QKeySequence.Quit)

toolbar_visible = False
Esempio n. 15
0
from functools import partial

from lib.action import Action

from app import app

toolbar_visible = True

actions = [['file', 'Load File Actions'], ['edit', 'Load Edit Actions'],
           ['view', 'Load View Actions'], ['option', 'Load Option Actions'],
           ['help', 'Load Help Actions'], ['test', 'Load Test Actions'],
           ['unit_test', 'Load Unit Test Actions'],
           ['my_actions', 'Load My Actions']]

tools = [['select', 'Load Select Tool'], ['delete', 'Load Delete Tool'],
         ['primitives', 'Load Primitives Tools'],
         ['transform', 'Load Transfrom Tools'],
         ['expand', 'Load Expand Tools'], ['boolean', 'Load Boolean Tools'],
         ['test', 'Load Test Tools']]

list = []

for action, menu in actions:
    ac = Action(partial(app.load_actions, 'actions.' + action),
                ['&Modules', menu])
    list.append(ac)

for tool, menu in tools:
    ac = Action(partial(app.load_tools, 'tools.' + tool), ['&Modules', menu])
    list.append(ac)
Esempio n. 16
0
import socket
import json
from lib.action import Action
from lib.user import User

HOST = "localhost"
PORT = 7777
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.bind((HOST, PORT))
serverSocket.listen()
conn, addr = serverSocket.accept()
data = json.loads(conn.recv(1024))
action = Action(data["type"], User(data["target"]["nickname"]))

if action.type == "SIGNIN":
    print("User has logged in")
    conn.send(Action("Success").toJSON().encode())
print("Client sent:", data)
print("SERVER FINESHED")
Esempio n. 17
0
    qtest.click_at([250, 180])
    qtest.click_at([210, 440])
    qtest.click_at([650, 400])
    QTest.keyPress(win, Qt.Key_X, Qt.AltModifier)
    qtest.click_at([400, 50])
    qtest.click_at([400, 400])
    QTest.keyPress(win, Qt.Key_Space, Qt.NoModifier)
    qtest.click_at([700, 100])
    QTest.keyPress(win, Qt.Key_G, Qt.ControlModifier)
    qtest.click_at([215, 440])
    QTest.keyPress(win, Qt.Key_Space)
    QTest.keyPress(win, Qt.Key_Space)
    qtest.click_at([660, 90])


cube_diagonal = Action(cube_diagonal_, ('&Unit Tests', 'Cube &Diagonal'))


def u_bahn_():
    # cube
    QTest.keyPress(win.viewer_3d, Qt.Key_B, Qt.ControlModifier)
    qtest.mouse_move([350, 320])
    QTest.keyPress(win.viewer_3d, Qt.Key_C, Qt.NoModifier, 100)
    QTest.keyPress(win.command_dock_widget.line_edit, Qt.Key_Z, Qt.NoModifier)
    QTest.keyPress(win.command_dock_widget.line_edit, Qt.Key_Minus,
                   Qt.NoModifier)
    QTest.keyPress(win.command_dock_widget.line_edit, Qt.Key_1, Qt.NoModifier)
    QTest.keyPress(win.command_dock_widget.line_edit, Qt.Key_Return,
                   Qt.NoModifier)
    qtest.mouse_move([430, 320])
    QTest.keyPress(win.command_dock_widget.line_edit, Qt.Key_Return,
Esempio n. 18
0
from gui import win
from doc import doc_ctrl

module = None


def new_():
    """Create a new script and show it in a new window"""
    # FIXME: this does not work on Debian 7, where the python2 binary is missing
    #        use platform.distro_name to check for this case
    fname = path.join(appdata.get('APPDIR'), '__main__.pyw')
    subprocess.Popen([sys.executable, fname, '--mode', 'script'])


new = Action(new_, ['&File', '&New'],
             icon='document-new',
             shortcut=QtGui.QKeySequence.New)


def load(filename):
    """Load a script given its filename. This assumes that no script
    was loaded before.
    This occurs either on startup if a command line argument specifying the
    file to open was provided or when manually opening a file for the first
    time."""
    with open(filename) as file:
        st = file.read()
    editor.setPlainText(st)
    # If the file was opened after startup, 'filename' has not been set before.
    appdata.set('filename', filename)
    exec_script()
Esempio n. 19
0

from lib.action import Action
from gui import viewer_3d


def wireframe_():
    if viewer_3d.view_mode == 'shaded':
        viewer_3d.view_mode = 'wireframe'
    elif viewer_3d.view_mode == 'wireframe':
        viewer_3d.view_mode = 'shaded'
wireframe = Action(wireframe_, ['&View', '&Wireframe'], icon='view-wireframe',
                   checkable=True, checked=False)


def view_angled_():
    viewer_3d.eye = [0.82, 0.45, 0.36]
view_angled = Action(view_angled_, ['&View', '&Angled'], icon='view-angled',
                     shortcut='A')


def view_top_():
    viewer_3d.active_plane = 2
    viewer_3d.eye = [0, 0, 1]
view_top = Action(view_top_, ['&View', '&Top'], icon='view-top', shortcut='1')


def view_front_():
    viewer_3d.active_plane = 0
    viewer_3d.eye = [1, 0, 0]
view_front = Action(view_front_, ['&View', '&Front'], icon='view-front',
Esempio n. 20
0
    from math import pi, sin, cos
    from gui import viewer_3d
    from OCC import BRepPrimAPI

    quader = BRepPrimAPI.BRepPrimAPI_MakeBox(3, 4, 5).Solid()
    viewer_3d.display_shape(quader)
    viewer_3d.view_mode = 'shaded'
    viewer_3d.zoom = 1
    N = 40
    for i in range(N):
        phi = i / N * pi + pi / 6
        viewer_3d.eye = [sin(phi), cos(phi), phi / 5]
        viewer_3d.zoom *= 1.05


demo = Action(demo_, ['M&y Actions', '&Demo'])


def doc_demo_():
    from doc import doc_ctrl
    from OCC import BRepPrimAPI
    quader = BRepPrimAPI.BRepPrimAPI_MakeBox(3, 4, 5).Solid()
    kugel = BRepPrimAPI.BRepPrimAPI_MakeSphere(2).Solid()
    with doc_ctrl.open_command():
        doc_ctrl.add(quader)
        doc_ctrl.set_color(quader, [0, 1, 0])
    with doc_ctrl.open_command():
        doc_ctrl.add(kugel)
        doc_ctrl.set_color(kugel, [1, 0, 0])
    #doc_ctrl.save()
Esempio n. 21
0
from data import appdata
from lib.action import Action
from gui import viewer_3d
from gui import win
from doc import doc_ctrl
from std_events import document_modified


def sphere1_():
    import random
    shape = BRepPrimAPI.BRepPrimAPI_MakeSphere(
        gp_.gp_Pnt_([0, 0, random.random() * 7]), 1).Shape()
    doc.doc_ctrl.add(shape)


sphere1 = Action(sphere1_, ('Te&sts', '&Sphere1'))

from OCC import GC, BRepBuilderAPI


def segment_():

    p0 = gp_.gp_Pnt_([0, 0, 0])
    p1 = gp_.gp_Pnt_([1, 1, 1])
    a = GC.GC_MakeSegment(p0, p1).Value()
    print(type(a))
    print(dir(a.GetObject()))
    final = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(a).Shape()
    print(type(final))
    print(dir(final.TShape().GetObject()))
    print(dir(final))