How to use initialize_mux method in avocado

Best Python code snippet using avocado_python

test_unit.py

Source:test_unit.py Github

copy

Full Screen

...210 children2 = (tree.TreeNode("child2"), tree.TreeNode("child1"))211 tree2 = tree.TreeNode("root", children=children2)212 mux1 = mux.MuxPlugin()213 mux2 = mux.MuxPlugin()214 mux1.initialize_mux(tree1, "")215 mux2.initialize_mux(tree2, "")216 variant1 = next(iter(mux1))217 variant2 = next(iter(mux2))218 self.assertNotEqual(variant1, variant2)219 # test variant __str__()220 str(variant1)221 variant_list = []222 for item in variant1:223 variant_list.append("'%s': '%s'" % (item, variant1[item]))224 expected_items = ["'paths': ''",225 "'variant': '[TreeNode(name='child1'), "226 "TreeNode(name='child2')]'",227 "'variant_id': 'child1-child2-f47e'"]228 for item in expected_items:229 self.assertIn(item, variant_list)...

Full Screen

Full Screen

MultiRobotRest.py

Source:MultiRobotRest.py Github

copy

Full Screen

...75 except DeviceStateError:76 pass;77 for key, mux_configuration in mux_conf_list.items():78 mux = CardMultiplexer(key, mux_configuration.mac_address, enable_statistics)79 if(False is initialize_mux(key, mux, mux_configuration)):80 error += 181 continue82 device_list.update({key: mux})83 for key, mag_configuration in mag_conf_list.items():84 mag = CardMagstriper(key, mag_configuration.mac_address, enable_statistics)85 if(False is initialize_mux(key, mag, mag_configuration)):86 error += 187 continue88 device_list.update({key: mag})89 for key, ctl_mux_configuration in ctl_mux_conf_list.items():90 ctl_mux = CtlMultiplexer(key, ctl_mux_configuration.mac_address, enable_statistics)91 92 if(False is initialize_mux(key, ctl_mux, ctl_mux_configuration)):93 error += 194 continue95 device_list.update({key: ctl_mux})96 if(not device_list):97 logging.critical("general: fatal error, device list is empty!");98 raise Error("", "Fatal error, device list is empty!");99 logging.info("general: initialization success! warnings: {}".format(error))100 start_rest_server(doPostWork, doGetWork, device_list, port)101 except Error as e:102 traceback.print_exc()103#---------------------------------------------------------------------------------------------------------------#104def SetLoggingLevel(args):105 FORMAT = "%(asctime)-15s %(levelname)s: %(message)s"106 if(args.debug):107 logging.basicConfig(format=FORMAT, level=logging.DEBUG)108 elif(args.verbose):109 logging.basicConfig(format=FORMAT, level=logging.INFO)110 else:111 logging.basicConfig(format=FORMAT, level=logging.WARNING)112#------------------------------------------------------------------------------------------------------------------------#113def EnableAndParseArguments():114 parser = argparse.ArgumentParser(description="AX Robot Integration Layer v{}.{}.{}".format(__major__, __minor__, __service__))115 parser.add_argument("-c", "--config", default=join("Assets", "EntryConfiguration.xml"), help="path to entry configuration xml", required=False)116 parser.add_argument("-p", "--port", default='8000', help="port for the http listener, default is 8000", required=False)117 parser.add_argument("--enable-statistics", nargs='?', const=True, default=False, help="enable tracking of the button press to the local DB", required=False)118 parser.add_argument("-v", "--verbose", nargs='?', const=True, default=False, help="increase trace verbosity to the INFO level", required=False)119 parser.add_argument("-d", "--debug", nargs='?', const=True, default=False, help="increase trace verbosity to the DEBUG level", required=False)120 parser.add_argument("--empower-card", nargs='?', const=True, default=False, help="increase the current on the card for the terminals with tighter card reader", required=False)121 return parser.parse_args()122#------------------------------------------------------------------------------------------------------------------------#123def initialize_mux(key, mux : DeviceBase, configuration):124 if(False is mux.device_lookup()):125 return False;126 if(False is mux.initialize_device(join(__path, configuration.Layout))):127 return False;128 return True;129#---------------------------------------------------------------------------------------------------------------#130def initialize_robot(key, robot : PinRobot, configuration):131 """Initializes the robot, and perfoms home"""132 try:133 if(False is robot.initialize_device(join(__path, configuration.Layout))):134 robot.log_warning("Initialization of robot failed, skip...");135 return False136 if(False is robot.initialize_connection(configuration.IP, int(configuration.Port))):137 robot.log_warning("robot not reachable, skip...");...

Full Screen

Full Screen

MUXSeries.py

Source:MUXSeries.py Github

copy

Full Screen

1import re2import sys,time3from ctypes import *4from Elveflow64 import MUX_Destructor,MUX_Initialization,MUX_Set_all_valves,MUX_Get_Trig,MUX_Set_Trig,MUX_Set_indiv_valve,MUX_Wire_Set_all_valves5"""6python wrapper for Multiplexer to control Valves connected by wires, 7supported max 16 channel, 8for valve 6712type90 is Low (0V) -> valve open101 is High(5V) -> valve close 11"""12class Multiplexer(object):13 """Elveflow Multiplexer for valve control14 provide A connected instrument name(by NI MAX tool) and initialize before further usage15 Args:16 Name: The name of the instrument by NI MAX tool17 """18 19 def __init__(self,name=None):20 super(Multiplexer, self).__init__()21 self.MuxName = name.encode('ascii')22 self.Mux_ID=c_int32()23 24 def initialize_MUX(self):25 """initialize the Multiplexer26 returns the ID number of the Multiplexer27 28 Args:29 Name: name of the Multiplexer from NI MAX tool30 returns:31 tuple: error,Mux_ID32 """33 error=MUX_Initialization(self.MuxName,byref(self.Mux_ID))34 # error=0 if initialization succeeded with Mux_ID>0 ,else return error,Mux_ID=-135 return error, self.Mux_ID.value36 37 def Mux_set_Trigger(self,trigger:int):38 """set trigger 39 return error=0 if set trigger succeeded40 41 Args:42 trigger (int): 0 is 0V,1 is 5V43 Returns:44 tuple: error,trigger45 """46 mux_trig=c_int32(trigger)47 error=MUX_Set_Trig(self.Instr_ID,mux_trig)48 return error,trigger 49 50 def Mux_get_Trigger(self):51 """get trigger52 0 is 0V,1 is 5V53 54 Returns:55 tuple: error,trigger56 """57 trigger=c_int32()58 error=MUX_Get_Trig(self.Mux_ID,byref(trigger))59 return error,trigger.value60 def MuxWire_setAll_valves(self,valves_array:list=[0]*16):61 """set all Wired valves 0-1662 specific for MUX Wire instrument, supported maxmal 16 channel63 length of valves_array should be exactly 16 with int=(0 or 1)64 error is 0 if succeed65 66 Args:67 valves_array (list): list of 16 int (0 or 1) for all 0-15 channels68 Returns:69 tuple:error,valve_array70 """71 valve_state=(c_int32*16)(0)72 error=-173 if valves_array:74 if len(valves_array)==16:75 for index,val in enumerate(valves_array):76 valve_state[index] = c_int32(val)77 error=MUX_Wire_Set_all_valves(self.Mux_ID,valve_state,16)78 return error,valves_array79 def set_all_valves(self,valves_array:list=[0]*16):80 """set all valves81 specific for MUX flow switch instrument,82 open or closed, 16 channels supported83 84 Args:85 valves_array (list): list of 16 int (0 or 1) for all 0-15 channels86 Returns:87 tuple:error,valve_array[list]88 """89 valve_state=(c_int32*16)(0)90 error=-191 if valves_array:92 if len(valves_array)==16:93 for index,val in enumerate(valves_array):94 valve_state[index] = c_int32(val)95 error=MUX_Set_all_valves(self.Mux_ID,valve_state,16)96 return error,valves_array97 def set_indiv_valve(self,valve_in:int,valve_out:int,state:int):98 """set the state of one value99 specific for MUX cross chip only ,100 0 is closed, 1 is open101 Args:102 valve_channel (int): channel number for this value103 state (int): 0 is close, 1 is open104 """105 error=MUX_Set_indiv_valve(self.Mux_ID,c_int32(valve_in),c_int32(valve_out),c_int32(state))106 return error107 108 def close_Mux(self):109 """close the communication to the multiplexer110 Return 0 if successful111 """112 error=MUX_Destructor(self.Instr_ID)113 return error114if __name__=="__main__":115 # bulid one multiplexer with name from NI MAX tool116 Mux_valve=Multiplexer(name='Dev2')117 error_init,Mux_ID=Mux_valve.initialize_MUX()118 print(f'Fluidic valve controller initialized with error: {error_init} and ID: {Mux_ID}')119 error_trig,trigger=Mux_valve.Mux_get_Trigger()120 print(f'error_trig: {error_init} and trigger: {trigger}')121 valve_state_off=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]122 valve_state_on=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]123 time.sleep(0.5)124 # for valves use MuxWire_setAll_valves125 error_set,valve_list=Mux_valve.MuxWire_setAll_valves(valve_state_off)126 print(f'set all valves with error: {error_set}, valve_list: {valve_list}')127 # close communication128 error_close=Mux_valve.close_Mux()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful