class Battery: def __init__(self, client, display): self.minVoltage = PowerSupply().min_voltage self.maxVoltage = PowerSupply().max_voltage self.medVoltage = self.maxVoltage * 0.5 self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05) self.action = Actions() self.client = client self.display = display print("Starting battery thread") # Execute battery thread batteryThread = Thread(target=self.chargeStatus, args=()) batteryThread.start() # Get current user's voltage def getCurrentVoltage(self): return PowerSupply().measured_voltage * 10 # Check if Ev3 has to be charged def chargeStatus(self): while True: if self.getCurrentVoltage() <= self.exitVoltage: # Exit system self.action.exit(self.client, self.display) else: # Sleep for 1 min and 30 sec time.sleep(90)
def main() -> int: server = WebServer( port=8085 ) # Change this number to change the web server port being served. robot = Robot( port=None ) # Change this number to change the serial port number being used to control the robot. detector = ImageDetector( resolution_front=Resolution(1280, 720), resolution_bottom=Resolution(1280, 720), in_video_front= 'f.mp4', # Set the in_video_front and in_video_bottom to 0 and 1 for cameras. in_video_bottom='b.mp4', # video_path_front=f'output_f_{time.time()}.avi', # video_path_bottom=f'output_b_{time.time()}.avi', ) detector_thread = Thread(target=detector_loop(detector, robot)) detector_thread.daemon = False detector_thread.start() actions = Actions(robot=robot, detector=detector) robot.set_handler(actions.on_read) for name, action in actions.list.items(): server.add_rule(name, action) server.run() actions.run() def on_exit(): robot.close() server.close() register_exit_event(on_exit) return 0
def sc_test013(test_suite_details): ''' This test creates a Sharing Agreement subcategory and adds it to a select patient's eligibility ''' testname = sys._getframe().f_code.co_name test_driver = TestHelper.TestDriver(testname) test_driver.pre_test_run(test_suite_details) if sys.platform == 'win32': try: # Create Sharing Agreement sub-category VistA1 = test_driver.connect_VistA(test_suite_details) aa = Actions(VistA1) aa.signon() aa.addSAsubtype(subcat='subcat1') aa.signon() aa.addSAsubtype(subcat='SUBCAT2') # Add Sharing Agreement to Patient Eligibility VistA1 = test_driver.connect_VistA(testname + '_1', result_dir, namespace) adt = ADTActions(VistA1) adt.signon() adt.gotoADTmenu() adt.eligverific(patient='333224444', eligtype='SHARING AGREEMENT') adt.signoff() # Make Appointment using new sub-category VistA1 = test_driver.connect_VistA(testname + '_2', result_dir, namespace) SC = SCActions(VistA1, user='******', code='1SWUSH12345!!') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+9@5AM', fresh='No', apptype='SHARING AGREEMENT', subcat=['subcat1', 'SUBCAT2']) SC.signoff() except TestHelper.TestError, e: test_driver.exception_handling(test_suite_details, e) finally:
def sc_test013(resultlog, result_dir, namespace): ''' This test creates a Sharing Agreement subcategory and adds it to a select patient's eligibility ''' testname = sys._getframe().f_code.co_name resultlog.write('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') logging.debug('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') if sys.platform == 'win32': try: # Create Sharing Agreement sub-category VistA1 = connect_VistA(testname, result_dir, namespace) aa = Actions(VistA1) aa.signon() aa.addSAsubtype(subcat='subcat1') aa.signon() aa.addSAsubtype(subcat='SUBCAT2') # Add Sharing Agreement to Patient Eligibility VistA1 = connect_VistA(testname + '_1', result_dir, namespace) adt = ADTActions(VistA1) adt.signon() adt.gotoADTmenu() adt.eligverific(patient='333224444', eligtype='SHARING AGREEMENT') adt.signoff() # Make Appointment using new sub-category VistA1 = connect_VistA(testname + '_2', result_dir, namespace) SC = SCActions(VistA1, user='******', code='1SWUSH12345!!') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+9@5AM', fresh='No', apptype='SHARING AGREEMENT', subcat=['subcat1', 'SUBCAT2']) SC.signoff() except TestHelper.TestError, e: resultlog.write('\nEXCEPTION ERROR:' + str(e)) logging.error('*****exception*********' + str(e)) else: resultlog.write('Pass\n')
def buttonCB_generateGraph(self): if (not self.transient and len(self.cellDict) == 0): self.stringVar_status.set("No cells have been loaded") return try: coords = [ int(x.strip()) for x in self.stringVar_entry_coords.get().split(",") ] except ValueError: self.stringVar_status.set("Invalid coordinate format") print( f"WARNING: Invalid coordinate string ({self.stringVar_entry_coords.get()})" ) return self.stringVar_status.set("Searching for coordinates...") self.update() if (self.transient): self.graphThread = Actions.GraphThread( graphicalElements=self.graphicalElements, filename=self.filename, coords=coords) else: self.graphThread = Actions.GraphThread( graphicalElements=self.graphicalElements, cellDict=self.cellDict, coords=coords) # Do not wait for this thread (it disables the graph generation button until completed) # The thread is a daemon and will terminate when finished or when the main thread terminates self.graphThread.start()
def process_event(self, event): # return event in generic type from websocket # if this event in general type it was send from start function and need call firs_copy if 'exchange' in event: return event if event['e'] == 'outboundAccountPosition': self.is_last_order_event_completed = True if event['e'] == 'executionReport': if event['X'] == 'FILLED': return elif event['x'] == 'CANCELED': return Actions.ActionCancel( event['s'], event['p'], event['i'], self.exchange_name, event ) self.last_order_event = event # store event order_event coz we need in outboundAccountInfo event # sometimes can came event executionReport x == filled and x == new together so we need flag self.is_last_order_event_completed = False return elif event['e'] == 'outboundAccountInfo': if self.is_last_order_event_completed: return order_event = self.last_order_event if order_event['s'] not in self.pairs: return if order_event['o'] == 'MARKET': # if market order, we haven't price and cant calculate quantity order_event['p'] = self.connection.get_ticker(symbol=order_event['s'])['lastPrice'] # part = self.get_part(order_event['s'], order_event['q'], order_event['p'], order_event['S']) self.on_balance_update(event) # shortcut mean https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md#order-update order = Order(order_event['p'], order_event['q'], self.get_part(order_event['s'], order_event['q'], order_event['p'], order_event['S']), order_event['i'], order_event['s'], order_event['S'], order_event['o'], self.exchange_name, order_event['P']) return Actions.ActionNewOrder(order, self.exchange_name, event)
def process_event(self, event): # self.update_balance() self.balance_updated = False if event['action'] == "insert": check_result = self.check_expected_order(event) if check_result: return check_result data = event['data'][0] if data['ordStatus'] == 'New' \ or (data['ordStatus'] == 'Filled' and 'ordType' in data): if event['data'][0]['execInst'] == 'Close': # order to close position came close_order = event['data'][0] if close_order['ordType'] == 'Market': price = None else: price = close_order['price'] return Actions.ActionClosePosition( self.translate(close_order['symbol']), self.translate(close_order['ordType']), price, close_order['orderID'], self.exchange_name, event ) else: order = self._self_order_to_global(event['data'][0]) return Actions.ActionNewOrder( order, self.exchange_name, event) elif event['action'] == 'update': if 'ordStatus' not in event['data'][0]: return if event['data'][0]['ordStatus'] == 'Canceled': orders = self.socket[event['data'][0]['symbol']].open_orders(clOrdIDPrefix="") order = list(filter(lambda o: o['orderID'] == event['data'][0]['orderID'], orders))[0] global_order = self._self_order_to_global(order) return Actions.ActionCancel( global_order.symbol, global_order.price, global_order.id, self.exchange_name, event )
def __init__(self, speed): self.button = TouchSensor() self.action = Actions(speed) # Get current time HH:MM:SS now = datetime.now() time = now.strftime("%H:%M:%S") print(str(time) + "\tExecuting Touch Sensor Thread\n") # Execute button thread buttonThread = Thread(target=self.isPressed, args=()) buttonThread.start()
def __init__(self, client, display): self.minVoltage = PowerSupply().min_voltage self.maxVoltage = PowerSupply().max_voltage self.medVoltage = self.maxVoltage * 0.5 self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05) self.action = Actions() self.client = client self.display = display print("Starting battery thread") # Execute battery thread batteryThread = Thread(target=self.chargeStatus, args=()) batteryThread.start()
def round_start(): # resets all the players best hand values reset_best() # to generate the deck global deck deck_obj = Deck() deck_obj.generate_deck() deck_obj.shuffle_deck() deck = deck_obj.get_deck() # to deal the players their cards for i in range(0, num_players): cards.append(Actions(deck)) cards[i].initial_deal() deck = cards[i].get_deck() # to get the images corresponding to the players cards for i in range(0, num_players): p_cards = cards[i].get_player_cards() for j in range(0, 2): if p_cards[j][-1] == 'D': player_card_images[i][j] = card_images[0][int(p_cards[j][:-1])-1] elif p_cards[j][-1] == 'C': player_card_images[i][j] = card_images[1][int(p_cards[j][:-1])-1] elif p_cards[j][-1] == 'H': player_card_images[i][j] = card_images[2][int(p_cards[j][:-1])-1] else: player_card_images[i][j] = card_images[3][int(p_cards[j][:-1])-1]
def __init__(self, speed): self.minVoltage = PowerSupply().min_voltage self.maxVoltage = PowerSupply().max_voltage self.medVoltage = self.maxVoltage * 0.5 self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05) self.action = Actions(speed) # Get current time HH:MM:SS now = datetime.now() time = now.strftime("%H:%M:%S") print(str(time) + "\tExecuting Battery Thread\n") # Execute battery thread batteryThread = Thread(target=self.chargeStatus, args=()) batteryThread.start()
def __init__(self, launchpad, UI, profiles): if not launchpad.Open(): print("No Launchpad found") return self.profiles: List[profiles] = profiles self.actions: Actions = Actions(self) self.launchpad = launchpad self.pressedButton = [None, None] self.GUI = UI self.setButtons() self.GUI.colorUIButtons(self.buttons, True)
def createCellDictionary (self): if (not self.transient): self.stringVar_status.set("Populating data point storage...") self.update() print("Populating data point storage...") self.loadThread = Actions.LoadThread(graphicalElements=self.graphicalElements, filename=self.filename, cellDict=self.cellDict) # Do not wait for this thread (it disables the graph generation and file selection buttons until completed) # The thread is a daemon and will terminate when finished or when the main thread terminates self.loadThread.start()
class Button: def __init__(self, speed): self.button = TouchSensor() self.action = Actions(speed) # Get current time HH:MM:SS now = datetime.now() time = now.strftime("%H:%M:%S") print(str(time) + "\tExecuting Touch Sensor Thread\n") # Execute button thread buttonThread = Thread(target=self.isPressed, args=()) buttonThread.start() # Check if Ev3 button was pressed and program has to terminate def isPressed(self): while True: if self.button.is_pressed == True: # Exit system self.action.exit()
def __init__(self): print("initializing") ##def main IO classes self.actions = Actions(self) ##routines to publish actions to mavros self.perceptions = Perceptions(self) ##listeners to the perceptions coming from mav-ros self.comFMC = Com_FMC(self) ##communication with the Fire Monitoring Center, represented by a human user in this system self.slamHandler = SlamHandler(self) ##Map handler, slam-sensor topic listener, colision detection ##some important constants self.TAKEOFF_ALT_DEF = 7 ##default altitude to take off ##start state machine self.stateLock = RLock() self.currentState = self.S_Awaiting self.stateChanged = True self.trajectoryState = self.T_None self.trajectory = [[0, 0, 0]] ##trajectory will always be a finite 3d array of points self.trajPointer = -1 ##pointer which shows the current destination in the array above that drone is following
class Battery: def __init__(self, speed): self.minVoltage = PowerSupply().min_voltage self.maxVoltage = PowerSupply().max_voltage self.medVoltage = self.maxVoltage * 0.5 self.exitVoltage = self.minVoltage + (self.minVoltage * 0.05) self.action = Actions(speed) # Get current time HH:MM:SS now = datetime.now() time = now.strftime("%H:%M:%S") print(str(time) + "\tExecuting Battery Thread\n") # Execute battery thread batteryThread = Thread(target=self.chargeStatus, args=()) batteryThread.start() # Get current user's voltage def getCurrentVoltage(self): return PowerSupply().measured_voltage * 10 # Check if Ev3 has to be charged def chargeStatus(self): while True: if self.getCurrentVoltage() <= self.exitVoltage: # Exit system self.action.exit() else: # Sleep for 1 min and 30 sec time.sleep(90) # Get the current percentage of the battery def getPercentage(self): percent = (self.getCurrentVoltage() / self.maxVoltage) * 100 return str(round(percent)) + "%"
def sc_test013(resultlog, result_dir, namespace): """ This test creates a Sharing Agreement subcategory and adds it to a select patient's eligibility """ testname = sys._getframe().f_code.co_name resultlog.write("\n" + testname + ", " + str(datetime.datetime.today()) + ": ") logging.debug("\n" + testname + ", " + str(datetime.datetime.today()) + ": ") if sys.platform == "win32": try: # Create Sharing Agreement sub-category VistA1 = connect_VistA(testname, result_dir, namespace) aa = Actions(VistA1) aa.signon() aa.addSAsubtype(subcat="subcat1") aa.signon() aa.addSAsubtype(subcat="SUBCAT2") # Add Sharing Agreement to Patient Eligibility VistA1 = connect_VistA(testname + "_1", result_dir, namespace) adt = ADTActions(VistA1) adt.signon() adt.gotoADTmenu() adt.eligverific(patient="333224444", eligtype="SHARING AGREEMENT") adt.signoff() # Make Appointment using new sub-category VistA1 = connect_VistA(testname + "_2", result_dir, namespace) SC = SCActions(VistA1, user="******", code="1SWUSH12345!!") SC.signon() SC.gotoApptMgmtMenu() SC.makeapp( patient="333224444", clinic="Clinic1", datetime="t+9@5AM", fresh="No", apptype="SHARING AGREEMENT", subcat=["subcat1", "SUBCAT2"], ) SC.signoff() except TestHelper.TestError, e: resultlog.write("\nEXCEPTION ERROR:" + str(e)) logging.error("*****exception*********" + str(e)) else: resultlog.write("Pass\n")
def init_window(self): # changing the title of our master widget self.master.title("SoapBox") # allowing the widget to take the full space of the root window self.pack(fill=BOTH, expand=1) # creating a menu instance menu = Menu(self.master) self.master.config(menu=menu) # creating a close button instance closeButton = Button(self, text="Close Page", command=self.client_exit) # placing the button on my window closeButton.place(x=250, y=125) # creating a scan button instance # scanButton = Button(self, text="Run!",command=lambda: Actions.SoapBox) scanButton = Button( self, text="Run!", command=lambda: Actions.SoapBox(self, var1, var2, var3)) # , command = lambda: Actions.SoapBox(.get() # placing the button on my window scanButton.place(x=500, y=425) #place some checkboxes # option =["https://old.reddit.com/","b","c","d"] # x = 350 # y = 225 # for item in option: # item = Checkbutton(self, text=str(item), fg="red") # item.place(x=x,y=y) # y+=20 #reddit button var1 = IntVar() chk1 = Checkbutton(self, text=str("Reddit"), fg="red", variable=var1) chk1.place(x=350, y=225) #twitter button var2 = IntVar() chk2 = Checkbutton(self, text=str("Twitter"), fg="red", variable=var2) chk2.place(x=350, y=245) #LinkedIn button var3 = IntVar() chk3 = Checkbutton(self, text=str("LinkedIn"), fg="red", variable=var3) chk3.place(x=350, y=265)
def __init__(self): rospy.init_node('project_3', anonymous=True) self.state_manager = StateManager() self.Pos1 = True self.pose = None self.spawned = False self.actions = Actions() self.q_table = QTable(self.state_manager) self.stuck_count = 0 self.max_stuck = 10 self.prev_pose = None self.poses = [] self.Episode = 1 self.poses.append(add_pose(0.0, 2.0, 6.15)) self.poses.append(add_pose(-1.8, -1.8, 0.0)) rospy.Subscriber("/scan", LaserScan, self.laser_callback) rospy.Subscriber("/gazebo/model_states", ModelStates, self.wait_for_models) rospy.wait_for_service('/gazebo/set_model_state') rospy.wait_for_service('/gazebo/get_model_state') self.move_model = rospy.ServiceProxy('/gazebo/set_model_state', SetModelState)
def __init__(self, state_manager): # type: (StateManager) -> None self.changed = False self.state_manager = state_manager self.NUM_STATES = self.state_manager.NUM_STATES self.actions = Actions() self.q_table = np.zeros((self.NUM_STATES, len(self.actions))) self.load_table() for val in range(0, self.NUM_STATES): self.rewards[val] = 0 # setting negative rewards for being too close to any side for rightVal in self.state_manager.sensors[0].distances: for rightFrontVal in self.state_manager.sensors[1].distances: for frontVal in self.state_manager.sensors[2].distances: for leftVal in self.state_manager.sensors[3].distances: if rightVal == "too_far" \ or rightVal == "too_close" \ or frontVal == "too_close" \ or leftVal == "too_close": self.rewards[self.state_manager \ .generate_state_index(rightVal, rightFrontVal, frontVal, leftVal)] = -1
def reg_test007(resultlog, result_dir, namespace): '''Add a new doctor, wait 2 minutes, add another doctor, then attempt to add doctor during patient admitting using a prior date (REF-218) ''' testname = sys._getframe().f_code.co_name resultlog.write('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') logging.debug('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') try: VistA1 = connect_VistA(testname, result_dir, namespace) reg = Actions(VistA1, user='******', code='SM12345!!') reg.signon() reg.adduser(name='JONES,JOE', ssn='000000050', gender='M', initials='JJ', acode='fakejoe1', vcode1='1SWUSH1234!!') VistA1 = connect_VistA(testname + '_01', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakejoe1', vcode1='1SWUSH1234!!', vcode2='1SWUSH12345!!', sigcode='JOEJ123') VistA1 = connect_VistA(testname + '_02', result_dir, namespace) reg = Actions(VistA1, user='******', code='SM12345!!') reg.signon() reg.adduser(name='BURKE,BARBARA', ssn='000000051', gender='F', initials='BB', acode='fakebar1', vcode1='1OIG1234!!') VistA1 = connect_VistA(testname + '_03', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakebar1', vcode1='1OIG1234!!', vcode2='1OGI12345!!', sigcode='BARB123') reg.signoff() VistA1 = connect_VistA(testname + '_04', result_dir, namespace) reg = ADTActions(VistA1, user='******', code='1Doc!@#$') reg.signon() reg.admit_a_patient(ssn='666551234', bed='2-B', time='t-1@01am', doctorlist=['BURKE', 'Alexander', 'JONES', 'Alexander']) reg.signoff() except TestHelper.TestError, e: resultlog.write(e.value) logging.error(testname + ' EXCEPTION ERROR: Unexpected test result')
def qbasic(): global atmOn, accountsList, transactionSummary, totalAmount, deletedAccounts, newlyCreatedAccounts, testMode userInput = Console() # tester = Validity() currentSession = Session() actions = Actions() # infinite loop while bank machine is "on" while atmOn == True: # retrieve user input try: cmd = userInput.commandInput(testMode) except EOFError: cmd = "off" # go through the possible input cases if cmd == "off": atmOn = False # ends the program elif (cmd == "ignore"): # input was invalid, do nothing pass elif (cmd == "login"): currentSession.login(testMode) elif (cmd == "logout"): currentSession.logout(transactionSummary) totalAmount = 0 # reset session's totalAmount elif (cmd == "create"): accountNumber = 0000000 if (currentSession.loggedInAgent == True): accountNumber = userInput.accountNumberInput(testMode) if accountNumber == "ignore": continue newlyCreatedAccounts.append(int(accountNumber)) actions.create(currentSession, transactionSummary, accountsList, deletedAccounts, accountNumber, testMode) elif (cmd == "delete"): accountNumber = 0000000 if (currentSession.loggedInAgent == True): accountNumber = userInput.accountNumberInput(testMode) if accountNumber == "ignore": continue deletedAccounts.append(int(accountNumber)) actions.delete(currentSession, transactionSummary, accountsList, accountNumber, deletedAccounts, newlyCreatedAccounts, testMode) elif (cmd == "deposit"): actions.deposit(currentSession, transactionSummary, deletedAccounts, newlyCreatedAccounts, accountsList, testMode) elif (cmd == "withdraw"): accountNumber = 0000000 amount = 0 if (currentSession.loggedInGeneral == True): accountNumber = userInput.accountNumberInput(testMode) if accountNumber == "ignore": continue amount = userInput.amountInput(testMode, currentSession) if amount == "ignore": continue totalAmount += int(amount) actions.withdraw(currentSession, transactionSummary, accountNumber, amount, totalAmount, deletedAccounts, newlyCreatedAccounts, accountsList, testMode) elif (cmd == "transfer"): actions.transfer(currentSession, transactionSummary, accountsList, deletedAccounts, newlyCreatedAccounts, testMode) transactionSummary.close()
def __init__(self, VistAconn, user=None, code=None): Actions.__init__(self, VistAconn, user, code)
from Actions import Actions if __name__ == "__main__": print(Request.delete('instance')) json = Request.post('instance') if json == -1: print("No JSON") curr_state = State(json) c_map = curr_state.curr_map robot = Robot(json) while not curr_state.finished: if 'U' in curr_state.curr_map[robot.pos[1]][robot.pos[0]]: Actions().scan(curr_state, robot.pos[0], robot.pos[1]) robot.next_objective = ["", -1, -1, 0] # Get next instruction [next_instr, x, y] = Decisions().eval_function(state=curr_state, robot=robot) print(next_instr, x, y) print("Next instruction: ", next_instr) print("Target x: ", x) print("Target y: ", y) print("Current x: ", robot.pos[0]) print("Current y: ", robot.pos[1]) print("Current direction: ", robot.pos[2]) # Robot executes next instruction if at target location
def reg_test007(test_suite_details): '''Add a new doctor, wait 2 minutes, add another doctor, then attempt to add doctor during patient admitting using a prior date (REF-218) ''' testname = sys._getframe().f_code.co_name test_driver = TestHelper.TestDriver(testname) test_driver.pre_test_run(test_suite_details) try: VistA1 = test_driver.connect_VistA(test_suite_details) reg = Actions(VistA1, user='******', code='SM1234!!!') reg.signon() reg.adduser(name='JONES,JOE', ssn='000000050', gender='M', initials='JJ', acode='fakejoe1', vcode1='1SWUSH1234!!') VistA1 = test_driver.connect_VistA(testname + '_01', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakejoe1', vcode1='1SWUSH1234!!', vcode2='1SWUSH12345!!', sigcode='JOEJ123') VistA1 = test_driver.connect_VistA(testname + '_02', result_dir, namespace) reg = Actions(VistA1, user='******', code='SM1234!!!') reg.signon() reg.adduser(name='BURKE,BARBARA', ssn='000000051', gender='F', initials='BB', acode='fakebar1', vcode1='1OIG1234!!') VistA1 = test_driver.connect_VistA(testname + '_03', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakebar1', vcode1='1OIG1234!!', vcode2='1OGI12345!!', sigcode='BARB123') reg.signoff() VistA1 = test_driver.connect_VistA(testname + '_04', result_dir, namespace) reg = ADTActions(VistA1, user='******', code='1Doc!@#$') reg.signon() reg.admit_a_patient( ssn='666551234', bed='2-B', time='t-1@01am', doctorlist=['BURKE', 'Alexander', 'JONES', 'Alexander']) reg.signoff() test_driver.post_test_run(test_suite_details) except TestHelper.TestError, e: test_driver.exception_handling(test_suite_details, e)
class Controler: ##state machine constants S_Awaiting = 0 S_takeOff = 1 S_HoldPos = 2 S_RunTrajAlgo = 3 S_Moving = 4 S_TrackSmoke = 5 S_InformFMC = 6 S_Landing = 7 S_InformAndWaitFMC = 8 S_Fatal_Error = 9 ##trajectory algorithm constants T_None = 0 T_Calculating = 1 T_Active = 2 #constructor def __init__(self): print("initializing") ##def main IO classes self.actions = Actions(self) ##routines to publish actions to mavros self.perceptions = Perceptions(self) ##listeners to the perceptions coming from mav-ros self.comFMC = Com_FMC(self) ##communication with the Fire Monitoring Center, represented by a human user in this system self.slamHandler = SlamHandler(self) ##Map handler, slam-sensor topic listener, colision detection ##some important constants self.TAKEOFF_ALT_DEF = 7 ##default altitude to take off ##start state machine self.stateLock = RLock() self.currentState = self.S_Awaiting self.stateChanged = True self.trajectoryState = self.T_None self.trajectory = [[0, 0, 0]] ##trajectory will always be a finite 3d array of points self.trajPointer = -1 ##pointer which shows the current destination in the array above that drone is following #methods def start(self): # init ROS master and python node print("Starting python Agent node on ROS.") try: rospy.init_node('python_agent', log_level=rospy.INFO) signal.signal(signal.SIGINT, signal.SIG_DFL) except: traceback.print_exc() # ros sleeps used in the system self.setupRate = rospy.Rate(0.2) ##on setup, it rests for 5 secs self.operRate = rospy.Rate(5) ##on operation 200ms self.smRate = rospy.Rate(20) ##during statemachine checks, wait 50 ms ##start ros instances on peripheral objects self.perceptions.start() self.actions.start() def isAValidStateChange(self, state): if(state == self.S_Awaiting): if(self.currentState != self.S_Landing): return False elif(state == self.S_takeOff): if(self.currentState != self.S_Awaiting): return False elif(state == self.S_HoldPos): if((self.currentState != self.S_takeOff) and (self.currentState != self.S_Moving) and (self.currentState != self.S_InformFMC)): return False elif(state == self.S_RunTrajAlgo): if((self.currentState != self.S_HoldPos) and (self.currentState != self.S_InformAndWaitFMC)): return False elif(state == self.S_Moving): if(self.currentState != self.S_RunTrajAlgo): return False elif(state == self.S_TrackSmoke): if(self.currentState != self.S_InformFMC): return False elif(state == self.S_InformFMC): if(self.currentState != self.S_HoldPos): return False elif(state == self.S_Landing): if(self.currentState != self.S_InformFMC): return False elif(state == self.S_InformAndWaitFMC): if((self.currentState != self.S_RunTrajAlgo) and (self.currentState != self.S_TrackSmoke)): return False return True def setState(self, state): self.stateLock.acquire() #if system is broken, set fatal error and return directly if((self.currentState == self.S_Fatal_Error) or (state == self.S_Fatal_Error)): self.currentState = self.S_Fatal_Error #check validity of state change elif(self.isAValidStateChange(state)): print("changing to {}".format(state)) #change the state self.currentState = state self.stateChanged = True self.stateLock.release() def controlState(self): ###control the actions done in each of the states start = int(round(time.time() * 1000)) ##get current time in milliseconds --- used for sampling this function while(True): if(self.currentState == self.S_Awaiting): ##wait until comand comes from fmc if(self.stateChanged): self.trajectoryState = self.T_None self.stateChanged = False elif(self.currentState == self.S_takeOff): if(self.stateChanged): self.setupOperation() self.stateChanged = False pos = self.perceptions.getPos() if(matchPositions((0, 0, self.TAKEOFF_ALT_DEF),(0, 0, self.perceptions.getPos()[2]), 0.5)): self.setState(self.S_HoldPos) elif(self.currentState == self.S_HoldPos): ##execute only once, then change the state if(self.stateChanged): pos = self.perceptions.getPos() self.actions.SetPoint(pos) self.stateChanged = False if(matchPositions(pos, (self.actions.des.x, self.actions.des.y, self.actions.des.z), 0.5)): self.setState(self.S_InformFMC) else: self.setState(self.S_RunTrajAlgo) elif(self.currentState == self.S_RunTrajAlgo): ##I am treating the algorithm as a parallel task here if(self.stateChanged): self.trajectoryState = self.T_Calculating self.stateChanged = False self.getTrajectory() ##comand which calculates the new trajectory to destination if(self.trajectoryState == self.T_None): ##algorithm did not find a valid path self.setState(self.S_InformAndWaitFMC) elif(self.trajectoryState == self.T_Active): ##trajectory is set and drone can move self.setState(self.S_Moving) elif(self.currentState == self.S_Moving): if(self.stateChanged): ##no setup needed self.stateChanged = False cur_pos = self.perceptions.getPos() if((self.trajectoryState == self.T_None) or matchPositions(cur_pos, (self.actions.des.x, self.actions.des.y, self.actions.des.z), 0.5)): ##slam found an obstacle or destination reached self.setState(self.S_HoldPos) else: if(self.trajPointer == -1): self.trajPointer = self.trajPointer + 1 self.actions.SetPoint((self.trajectory[0][0], self.trajectory[0][1], self.trajectory[0][2])) des = self.trajectory[self.trajPointer] ##get current destination on trajectory plan if(matchPositions(cur_pos, des, 0.25)): if(self.trajPointer != (len(self.trajectory) - 1)): ## set setpoint to next coordinate on trajectory plan self.trajPointer = self.trajPointer + 1 self.actions.SetPoint(self.trajectory[self.trajPointer][0], self.trajectory[self.trajPointer][1], self.trajectory[self.trajPointer][2]) elif(self.currentState == self.S_TrackSmoke): ##this is a ghost state for now if(self.stateChanged): ##no setup needed self.stateChanged = False self.setState(self.S_InformAndWaitFMC) elif(self.currentState == self.S_InformFMC): if(self.stateChanged): ##no setup needed self.stateChanged = False elif(self.currentState == self.S_Landing): if(self.stateChanged): self.actions.Land() self.stateChanged = False state = self.perceptions.getState() if(not state.armed): ##change to awaiting after drone disarmed the motors self.trajectoryState = self.T_None self.setState(self.S_Awaiting) elif(self.currentState == self.S_InformAndWaitFMC): if(self.stateChanged): ##no setup needed self.stateChanged = False elapsed_time = int(round(time.time() * 1000)) - start ##elapsed time in milliseconds # if((50 - elapsed_time) > 0): # sampling at 50ms time.sleep((50 - elapsed_time) / 1000) ##convert to seconds for sleep function # def setupOperation(self): ##set mode to guided while(not self.perceptions.getState().guided): self.actions.setMode('GUIDED') self.setupRate.sleep() ##arm motors while(not self.perceptions.getState().armed): self.actions.ArmMotors(True) self.setupRate.sleep() self.actions.TakeOff(self.TAKEOFF_ALT_DEF) def getTrajectory(self): ##for testing reasons we will calculate an interpolated number of points on an straight line to the destination pos = self.perceptions.getPos() dest = (self.actions.des.x, self.actions.des.y, self.actions.des.z) self.trajectory = [] self.trajectory.append(dest) self.trajPointer = -1 self.trajectoryState = self.T_Active return #calculate vector pointing to destination with size 1 vector = (dest[0] - pos[0], dest[1] - pos[1], dest[2] - pos[2]) size_raw = sqrt(vector[0]**2 + vector[1]**2 + vector[2]**2) if(size_raw > 10000): ##distance to destination is absurd, some error has happened print("invalid destination provided") self.trajectoryState = self.T_None return vector = (vector[0] / size_raw, vector[1] / size_raw, vector[2] / size_raw) ##normalize vector self.trajectory = [] ##set coordinate values for the trajectory for i in range(int(size_raw)): x = [] x.append(pos[0] + (i + 1) * vector[0]) x.append(pos[1] + (i + 1) * vector[1]) x.append(pos[2] + (i + 1) * vector[2]) self.trajectory.append(x) self.trajectory.append(dest) ##last coordinate is the destination itself ##everything done self.trajPointer = -1 self.trajectoryState = self.T_Active
def sc_test012(resultlog, result_dir, namespace): ''' This test adds a new user with SDOB keys and creates & verifies appointments in timeslots outside a clinic's normal operating window ''' testname = sys._getframe().f_code.co_name resultlog.write('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') logging.debug('\n' + testname + ', ' + str(datetime.datetime.today()) + ': ') try: # Create new user with SDOB keys VistA1 = connect_VistA(testname, result_dir, namespace) SC = Actions(VistA1, user='******', code='SM12345!!') SC.signon() SC.adduser(name='CRANE,JON', ssn='000000065', gender='M', initials='JC', acode='fakejon1', vcode1='1SWUSH1234!!') SC.signoff() VistA1 = connect_VistA(testname + '_01', result_dir, namespace) SC = Actions(VistA1) SC.sigsetup(acode='fakejon1', vcode1='1SWUSH1234!!', vcode2='1SWUSH12345!!', sigcode='JONC123') SC.signoff() # Create appointment outside Clinic1's operating hours via fakedoc1 VistA2 = connect_VistA(testname + '_02', result_dir, namespace) SC = SCActions(VistA2, user='******', code='1Doc!@#$') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+5@9AM', fresh='No', badtimeresp='noslot') SC.signoff() # Create appointment outside Clinic1's operating hours via fakejon1 (SDOB key) VistA3 = connect_VistA(testname + '_02', result_dir, namespace) SC = SCActions(VistA3, user='******', code='1SWUSH12345!!') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+10@9AM', fresh='No', badtimeresp='overbook') SC.signoff() except TestHelper.TestError, e: resultlog.write('\nEXCEPTION ERROR:' + str(e)) logging.error('*****exception*********' + str(e))
def setupUiMainWindow(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(798, 551) self.Frame = QtGui.QFrame() #MainWindow.setCentralWidget(self.Frame) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 798, 27)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") self.menuEdit = QtGui.QMenu(self.menubar) self.menuEdit.setObjectName("menuEdit") self.menuSerach = QtGui.QMenu(self.menubar) self.menuSerach.setObjectName("menuSerach") self.menuHelp = QtGui.QMenu(self.menubar) self.menuHelp.setObjectName("menuHelp") MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.actionNew_File = QtGui.QAction(MainWindow) self.actionNew_File.setObjectName("actionNew_File") self.actionNew_File.setShortcut('Ctrl+N') self.actionOpen_File = QtGui.QAction(MainWindow) self.actionOpen_File.setObjectName("actionOpen_File") self.actionOpen_File.setShortcut('Ctrl+O') self.actionSave_File = QtGui.QAction(MainWindow) self.actionSave_File.setObjectName("actionSave_File") self.actionSave_File.setShortcut('Ctrl+S') self.actionSave_All = QtGui.QAction(MainWindow) self.actionSave_All.setObjectName("actionSave_All") self.actionSave_All.setShortcut('Ctrl+Shift+S') self.actionClose_File = QtGui.QAction(MainWindow) self.actionClose_File.setObjectName("actionClose_File") self.actionClose_File.setShortcut('Ctrl+W') self.actionClose_All = QtGui.QAction(MainWindow) self.actionClose_All.setObjectName("actionClose_All") self.actionClose_All.setShortcut('Ctrl+Shift+S') self.actionExit = QtGui.QAction(MainWindow) self.actionExit.setObjectName("actionExit") self.actionExit.setShortcut('Ctrl+Q') self.actionUndo = QtGui.QAction(MainWindow) self.actionUndo.setObjectName("actionUndo") self.actionUndo.setShortcut('Ctrl+Z') self.actionRedo = QtGui.QAction(MainWindow) self.actionRedo.setObjectName("actionRedo") self.actionRedo.setShortcut('Ctrl+Y') self.actionCut = QtGui.QAction(MainWindow) self.actionCut.setObjectName("actionCut") self.actionCut.setShortcut('Ctrl+X') self.actionCopy = QtGui.QAction(MainWindow) self.actionCopy.setObjectName("actionCopy") self.actionCopy.setShortcut('Ctrl+C') self.actionPaste = QtGui.QAction(MainWindow) self.actionPaste.setObjectName("actionPaste") self.actionPaste.setShortcut('Ctrl+V') self.actionSelect_All = QtGui.QAction(MainWindow) self.actionSelect_All.setObjectName("actionSelect_All") self.actionSelect_All.setShortcut('Ctrl+A') self.actionFind = QtGui.QAction(MainWindow) self.actionFind.setObjectName("actionFind") self.actionFind_Next = QtGui.QAction(MainWindow) self.actionFind_Next.setObjectName("actionFind_Next") self.actionFind_Next.setShortcut('Ctrl+G') self.actionFind.setShortcut('Ctrl+F') self.actionFind_Prev = QtGui.QAction(MainWindow) self.actionFind_Prev.setObjectName("actionFind_Prev") self.actionFind_Prev.setShortcut('Ctrl+Shift+G') self.actionOnline_Help = QtGui.QAction(MainWindow) self.actionOnline_Help.setObjectName("actionOnline_Help") self.actionOnline_Help.setShortcut('F1') self.actionLua_Help = QtGui.QAction(MainWindow) self.actionLua_Help.setObjectName("actionLua_Help") self.actionAbout_Lua = QtGui.QAction(MainWindow) self.actionAbout_Lua.setObjectName("actionAbout_Lua") self.actionAbout_Apolo = QtGui.QAction(MainWindow) self.actionAbout_Apolo.setObjectName("actionAbout_Apolo") self.actionLicense = QtGui.QAction(MainWindow) self.actionLicense.setObjectName("actionLicense") self.actionReport_bug = QtGui.QAction(MainWindow) self.actionReport_bug.setObjectName("actionReport_bug") self.actionSuggestions = QtGui.QAction(MainWindow) self.actionSuggestions.setObjectName("actionSuggestions") self.menuFile.addAction(self.actionNew_File) self.menuFile.addAction(self.actionOpen_File) self.menuFile.addAction(self.actionSave_File) self.menuFile.addAction(self.actionSave_All) self.menuFile.addSeparator() self.menuFile.addAction(self.actionClose_File) self.menuFile.addAction(self.actionClose_All) self.menuFile.addSeparator() self.menuFile.addAction(self.actionExit) self.menuEdit.addAction(self.actionUndo) self.menuEdit.addAction(self.actionRedo) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionCut) self.menuEdit.addAction(self.actionCopy) self.menuEdit.addAction(self.actionPaste) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionSelect_All) self.menuSerach.addAction(self.actionFind) self.menuSerach.addSeparator() self.menuSerach.addAction(self.actionFind_Next) self.menuSerach.addAction(self.actionFind_Prev) self.menuHelp.addAction(self.actionOnline_Help) self.menuHelp.addAction(self.actionLua_Help) self.menuHelp.addSeparator() self.menuHelp.addAction(self.actionSuggestions) self.menuHelp.addAction(self.actionReport_bug) self.menuHelp.addSeparator() self.menuHelp.addAction(self.actionLicense) self.menuHelp.addAction(self.actionAbout_Lua) self.menuHelp.addAction(self.actionAbout_Apolo) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuEdit.menuAction()) self.menubar.addAction(self.menuSerach.menuAction()) self.menubar.addAction(self.menuHelp.menuAction()) self.BtmArea = BottomArea() self.Split = QtGui.QSplitter(QtCore.Qt.Vertical) self.layout = QtGui.QHBoxLayout() self.Frame.setLayout(self.layout) self.Split.insertWidget(0, self.Frame) self.Split.insertWidget(1, self.BtmArea) self.Split.setStretchFactor(0, 10) self.Split.setStretchFactor(1, 5) self.setCentralWidget(self.Split) #instance de tabs self.Tabs = TabWidget() self.layout.addWidget(self.Tabs) #instance editor self.Edt = Editor() self.Edt.setPlainText('Welcome') self.Edt.setReadOnly(True) self.Edt.FileName = 'Start Page' self.Tabs.add_Tab(0, self.Edt, 'Start Page') self.retranslateUi(self) #to turn toolbox visible #instance Actions self.Act = Actions(self) #drawing toolbar self.ToolBar = self.addToolBar('ToolBar') #new File Action_NewFile = QtGui.QAction(QtGui.QIcon('gui/icons/new_file.png'), 'New File', self) self.ToolBar.addAction(Action_NewFile) Action_NewFile.triggered.connect(self.Act.New_File) #Open File self.Action_OpenFile = QtGui.QAction( QtGui.QIcon('gui/icons/open_file.png'), 'Open File', self) self.ToolBar.addAction(self.Action_OpenFile) self.Action_OpenFile.triggered.connect(self.Act.Open_File) #Save File Action_SaveFile = QtGui.QAction(QtGui.QIcon('gui/icons/save_file.png'), 'Save File', self) self.ToolBar.addAction(Action_SaveFile) Action_SaveFile.triggered.connect(self.Act.Save_File) #Save All Action_SaveAll = QtGui.QAction(QtGui.QIcon('gui/icons/save_all.png'), 'Save All', self) self.ToolBar.addAction(Action_SaveAll) Action_SaveAll.triggered.connect(self.Act.Save_All) #Separator self.ToolBar.addSeparator() #Cut Action_Cut = QtGui.QAction(QtGui.QIcon('gui/icons/cut.png'), 'Cut', self) self.ToolBar.addAction(Action_Cut) Action_Cut.triggered.connect(self.Act.Cut) #Copy Action_Copy = QtGui.QAction(QtGui.QIcon('gui/icons/copy.png'), 'Copy', self) self.ToolBar.addAction(Action_Copy) Action_Copy.triggered.connect(self.Act.Copy) #Paste Action_Paste = QtGui.QAction(QtGui.QIcon('gui/icons/paste.png'), 'Paste', self) self.ToolBar.addAction(Action_Paste) Action_Paste.triggered.connect(self.Act.Paste) #Separator self.ToolBar.addSeparator() #Run Action_Run = QtGui.QAction(QtGui.QIcon('gui/icons/run.png'), 'Run', self) self.ToolBar.addAction(Action_Run) Action_Run.triggered.connect(self.Act.Run) #Stop Action_Stop = QtGui.QAction(QtGui.QIcon('gui/icons/stop.png'), 'Stop', self) self.ToolBar.addAction(Action_Stop) Action_Stop.triggered.connect(self.Act.Stop) #tab signal # self.Tabs.tabCloseRequested.connect(self.Act.Close_File) self.Tabs.connect(self.Tabs, QtCore.SIGNAL("tabCloseRequested(int)"), self.Act.Close_File) #menu signals.... self.actionNew_File.triggered.connect(self.Act.New_File) self.actionOpen_File.triggered.connect(self.Act.Open_File) self.actionSave_File.triggered.connect(self.Act.Save_File) self.actionSave_All.triggered.connect(self.Act.Save_All) self.actionClose_File.triggered.connect(self.Act.Close_File) self.actionClose_All.triggered.connect(self.Act.Close_All) self.actionExit.triggered.connect(self.Act.Exit) self.actionRedo.triggered.connect(self.Act.Redo) self.actionUndo.triggered.connect(self.Act.Undo) self.actionCut.triggered.connect(self.Act.Cut) self.actionPaste.triggered.connect(self.Act.Paste) self.actionCopy.triggered.connect(self.Act.Copy) self.actionSelect_All.triggered.connect(self.Act.Select_All) self.actionFind.triggered.connect(self.Act.Find) self.actionFind_Next.triggered.connect(self.Act.Find_Next) self.actionFind_Prev.triggered.connect(self.Act.Find_Prev) self.actionOnline_Help.triggered.connect(self.Act.Online_Help) self.actionLua_Help.triggered.connect(self.Act.Lua_Help) self.actionReport_bug.triggered.connect(self.Act.IDE_Forum) self.actionSuggestions.triggered.connect(self.Act.IDE_Forum) self.actionLicense.triggered.connect(self.Act.Show_License) self.retranslateUi(self) QtCore.QMetaObject.connectSlotsByName(self)
def init_game(width, height, tickrate): Screen.init(width, height) World.init(width, height, tickrate) Actions.set_controls()
def reg_test007(test_suite_details): '''Add a new doctor, wait 2 minutes, add another doctor, then attempt to add doctor during patient admitting using a prior date (REF-218) ''' testname = sys._getframe().f_code.co_name test_driver = TestHelper.TestDriver(testname) test_driver.pre_test_run(test_suite_details) try: VistA1 = test_driver.connect_VistA(test_suite_details) reg = Actions(VistA1, user='******', code='SM1234!!!') reg.signon() reg.adduser(name='JONES,JOE', ssn='000000050', gender='M', initials='JJ', acode='fakejoe1', vcode1='1SWUSH1234!!') VistA1 = test_driver.connect_VistA(testname + '_01', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakejoe1', vcode1='1SWUSH1234!!', vcode2='1SWUSH12345!!', sigcode='JOEJ123') VistA1 = test_driver.connect_VistA(testname + '_02', result_dir, namespace) reg = Actions(VistA1, user='******', code='SM1234!!!') reg.signon() reg.adduser(name='BURKE,BARBARA', ssn='000000051', gender='F', initials='BB', acode='fakebar1', vcode1='1OIG1234!!') VistA1 = test_driver.connect_VistA(testname + '_03', result_dir, namespace) reg = Actions(VistA1) reg.sigsetup(acode='fakebar1', vcode1='1OIG1234!!', vcode2='1OGI12345!!', sigcode='BARB123') reg.signoff() VistA1 = test_driver.connect_VistA(testname + '_04', result_dir, namespace) reg = ADTActions(VistA1, user='******', code='1Doc!@#$') reg.signon() reg.admit_a_patient(ssn='666551234', bed='2-B', time='t-1@01am', doctorlist=['BURKE', 'Alexander', 'JONES', 'Alexander']) reg.signoff() test_driver.post_test_run(test_suite_details) except TestHelper.TestError, e: test_driver.exception_handling(test_suite_details, e)
def sc_test012(resultlog, result_dir, namespace): """ This test adds a new user with SDOB keys and creates & verifies appointments in timeslots outside a clinic's normal operating window """ testname = sys._getframe().f_code.co_name resultlog.write("\n" + testname + ", " + str(datetime.datetime.today()) + ": ") logging.debug("\n" + testname + ", " + str(datetime.datetime.today()) + ": ") try: # Create new user with SDOB keys VistA1 = connect_VistA(testname, result_dir, namespace) SC = Actions(VistA1, user="******", code="SM12345!!") SC.signon() SC.adduser( name="CRANE,JON", ssn="000000065", gender="M", initials="JC", acode="fakejon1", vcode1="1SWUSH1234!!" ) SC.signoff() VistA1 = connect_VistA(testname + "_01", result_dir, namespace) SC = Actions(VistA1) SC.sigsetup(acode="fakejon1", vcode1="1SWUSH1234!!", vcode2="1SWUSH12345!!", sigcode="JONC123") SC.signoff() # Create appointment outside Clinic1's operating hours via fakedoc1 VistA2 = connect_VistA(testname + "_02", result_dir, namespace) SC = SCActions(VistA2, user="******", code="1Doc!@#$") SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient="333224444", clinic="Clinic1", datetime="t+5@9AM", fresh="No", badtimeresp="noslot") SC.signoff() # Create appointment outside Clinic1's operating hours via fakejon1 (SDOB key) VistA3 = connect_VistA(testname + "_02", result_dir, namespace) SC = SCActions(VistA3, user="******", code="1SWUSH12345!!") SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient="333224444", clinic="Clinic1", datetime="t+10@9AM", fresh="No", badtimeresp="overbook") SC.signoff() except TestHelper.TestError, e: resultlog.write("\nEXCEPTION ERROR:" + str(e)) logging.error("*****exception*********" + str(e))
def __init__(self, VistAconn, scheduling=None, user=None, code=None): Actions.__init__(self, VistAconn, scheduling, user, code)
def sc_test012(test_suite_details): ''' This test adds a new user with SDOB keys and creates & verifies appointments in timeslots outside a clinic's normal operating window ''' testname = sys._getframe().f_code.co_name test_driver = TestHelper.TestDriver(testname) test_driver.pre_test_run(test_suite_details) try: # create new user with SDOB keys VistA1 = test_driver.connect_VistA(test_suite_details) SC = Actions(VistA1, user='******', code='SM1234!!!') SC.signon() SC.adduser(name='CRANE,JON', ssn='000000065', gender='M', initials='JC', acode='fakejon1', vcode1='1SWUSH1234!!') SC.signoff() VistA1 = test_driver.connect_VistA(testname + '_01', result_dir, namespace) SC = Actions(VistA1) SC.sigsetup(acode='fakejon1', vcode1='1SWUSH1234!!', vcode2='1SWUSH12345!!', sigcode='JONC123') SC.signoff() # Create appointment outside Clinic1's operating hours via fakedoc1 VistA2 = test_driver.connect_VistA(testname + '_02', result_dir, namespace) SC = SCActions(VistA2, user='******', code='1Doc!@#$') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+5@9AM', fresh='No', badtimeresp='noslot') SC.signoff() # Create appointment outside Clinic1's operating hours via fakejon1 (SDOB key) VistA3 = test_driver.connect_VistA(testname + '_02', result_dir, namespace) SC = SCActions(VistA3, user='******', code='1SWUSH12345!!') SC.signon() SC.gotoApptMgmtMenu() SC.makeapp(patient='333224444', clinic='Clinic1', datetime='t+10@9AM', fresh='No', badtimeresp='overbook') SC.signoff() except TestHelper.TestError, e: test_driver.exception_handling(test_suite_details, e)
def start(self): driver = WebDriverFactory.get_chrome_driver(self.__driver_path) executor = Actions(driver) driver.get(self.__url) # 进入登入界面 executor.click_element('input[title="ログイン"]') # 输入账号密码 登入 executor.input_text('input[id="tel"]', self.__tel) executor.input_text('input[id="pass"]', self.__tel_password) executor.click_element('input[alt="ログイン"]') # 点击ボイスワープ按钮 executor.click_element('input[alt="ボイスワープ"]') # 点击サービス開始/停止按钮 executor.click_element('input[alt="サービス開始/停止"]') # 点击开始单选按钮 设定时间 if self.__start_or_stop: executor.click_element('input[id="r2"]') executor.input_text('input[id="call_sec2"]', '5') else: executor.click_element('input[id="stop"]') # 点击设定按钮 executor.click_element('input[alt="設定"]') # 登出 executor.click_element('input[title="ログアウト"]') # 发送邮件 mail_provider = MailProvider( self.__mail_account, self.__mail_password, self.__mail_subject, self.__mail_text) mail_provider.send_mail(self.__mail_list)