How to use set_device method in robotframework-ioslibrary

Best Python code snippet using robotframework-ioslibrary_python

energy_meter_device.py

Source:energy_meter_device.py Github

copy

Full Screen

...62 __name='energy_meter_usblink'63 def open(self):64 print self.__name+"::open()"65 self.serial_device=serial.Serial(self.serial_device_path, 57600, timeout=1) #create and open device as a Serial object66 def set_device(self,key):67 print self.__name+"::set_device(key)"68 self.serial_device.write(key);69 line = self.serial_device.readline()70 def information(self,log):71 print self.__name+"::information(log)"72 print '\nshow serial information:\n'73 log.log('serial path: '+self.serial_device_path)74 ##Plink version75#todo or not: use self.set_device("*VER")76 self.serial_device.write("*VER");77 line = self.serial_device.readline()78 #print("*VER=|"+line+"|")79 log.log('device USB-Plink '+line)80 ##power head name81#todo or not: use self.set_device("*NAM")82 self.serial_device.write("*NAM");83 line=self.serial_device.readline()84 #print("*NAM=|"+line+"|")85 self.device_head=line86 log.log('with head '+self.device_head)87 def value(self):88 print self.__name+"::value()"89 #ask and get data90 self.set_device("*CVU")91 ##line = "123.456"92 line = self.serial_device.readline()93 #print("*CVU=|"+line+"|\n")94 if (self.frequency>0):95 val=float(line)*1000/self.frequency #mJ96 else:97 val=float(line)*1000 #mW98 return val99 def set_zero(self):100 print self.__name+"::set_zero()"101 self.set_device("*SOU");102 line = self.serial_device.readline()103 line = self.serial_device.readline()104 line = self.serial_device.readline()105 def set_wavelength(self,value):106 print self.__name+"::set_wavelength(value)"107 strValue='{:05d}'.format(value)108 print "set "+strValue+" nm."109#todo or not: use self.set_device("*PWC"+strValue)110 self.serial_device.write("*PWC"+strValue);111 line = self.serial_device.readline()112 #print("*PWC"+strValue+"=|"+line+"|")113 line=line.replace('\n','').replace('\r','')114 if(line!="ACK"):115 print("Warning: no acknowledgement received (e.g. ACK!="+line+").?")116 def get_wavelength(self):117 print self.__name+"::get_wavelength()"118 #many information119#todo: use self.set_device("*F01")120 self.set_device("*F01")121 line = self.serial_device.readline()122# print("*F01=|"+line+"|")123 device_info=line.split("\t")124 125# for i in range(0,len(device_info)-1,2):126# print('device_info['+str(i)+']('+device_info[i]+')='+device_info[i+1])+' ['+str(i+1)+']'127 128# print('dev.'+device_info[4]+'='+device_info[5])129 device_wavelength=int(device_info[5])130# print "get "+str(device_wavelength)+" nm."131 return device_wavelength;132 def get_wavelength_str(self):133 print self.__name+"::get_wavelength_str()"134 #many information135 self.set_device("*F01");136 line = ser.readline()137 device_info=line.split("\t")138 #single one139 device_wavelength=device_info[4]+'='+device_info[5]+" nm"140 return device_wavelength;141 def get_anticipation(self):142 print self.__name+"::get_anticipation()"143 #many information144#todo: use self.set_device("*F02")145 self.serial_device.write("*F02");146 line = self.serial_device.readline()147 line = self.serial_device.readline()148 device_info=line.split("\t")149 device_anticipation=int(device_info[25])150 return device_anticipation;151 def set_anticipation_ON(self):152 print self.__name+"::set_anticipation_ON()"153 self.set_device("*ANT")154 def set_anticipation_OFF(self):155 print self.__name+"::set_anticipation_OFF()"156 self.set_device("*ANF")...

Full Screen

Full Screen

user_device.py

Source:user_device.py Github

copy

Full Screen

...18class BaseBoard:19 def __init__(self):20 self.device = None21 def info(self):22 return self.set_device(WMI.Win32_BaseBoard()[0])23 def set_device(self, data):24 self.device = data25 return data26 def model(self):27 return self.device.Product28 def manufacturer(self):29 return self.device.Manufacturer30class Chipset:31 def __init__(self):32 self.device = None33 def processor_info(self):34 return WMI.Win32_Processor()[0]35 def processor_name(self):36 processor = self.processor_info()37 if processor.Manufacturer == 'AuthenticAMD':38 caption = 'AMD_Chipset_Drivers'39 elif processor.Manufacturer == 'GenuineIntel':40 caption = 'Intel(R) Chipset Device Software'41 return caption42 def info(self):43 processor = self.processor_name()44 return self.set_device(WMI.Win32_Product(caption=processor)[0])45 def set_device(self, data):46 self.device = data47 return data48 def name(self):49 return self.device.Name.replace('_', ' ')50 def version(self):51 return self.device.Version52class BIOS:53 def __init__(self):54 self.device = None55 def info(self):56 data = WMI.Win32_BIOS()[0]57 return self.set_device(data)58 def set_device(self, data):59 self.device = data60 return data61 def name(self):62 return 'BIOS'63 def version(self):64 return self.device.SMBIOSBIOSVersion65 def release_date(self):66 return format_date(self.device.ReleaseDate)67class BoardLAN:68 # Detects all network LAN adapters in user's system69 def lan_adapters(self):70 wql = "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID LIKE 'Ethernet%' and PNPDeviceID LIKE 'PCI%'"71 return WMI.query(wql) 72class LAN:73 def __init__(self):74 self.device = None75 def info(self):76 data = WMI.Win32_PnpSignedDriver(deviceclass='NET', devicename=self.device.ProductName)[0]77 return self.set_device(data)78 def set_device(self, data):79 self.device = data80 return data81 def name(self):82 return self.device.DeviceName83 def version(self):84 return self.device.DriverVersion85 86 def release_date(self):87 return format_date(self.device.DriverDate)88class Audio:89 def __init__(self):90 self.device = None91 def board_audio(self):92 return WMI.Win32_SoundDevice()[0]93 def info(self):94 sound_device = self.board_audio()95 data = WMI.Win32_PnpSignedDriver(deviceclass='MEDIA', devicename=sound_device.Name)[0]96 return self.set_device(data)97 def set_device(self, data):98 self.device = data99 return data100 def name(self):101 return self.device.DeviceName102 def version(self):103 return self.device.DriverVersion104 def release_date(self):105 return format_date(self.device.DriverDate)106class VGA:107 def __init__(self):108 self.device = None109 def info(self):110 for vga in WMI.Win32_VideoController(adapterdactype='Internal'):111 return self.set_device(vga)112 def set_device(self, data):113 self.device = data114 return data115 def name(self):116 return self.device.Name117 def version(self):118 if self.device:119 return self.device.DriverVersion120 return None121 def release_date(self):122 if self.device:123 return format_date(self.device.DriverDate)124 return None125class WiFi:126 def __init__(self):127 self.device = None128 def board_wifi(self):129 for wifi in WMI.Win32_NetworkAdapter(netconnectionid='Wi-Fi'):130 return wifi131 def info(self):132 board_wifi = self.board_wifi()133 if board_wifi:134 for wifi in WMI.Win32_PnpSignedDriver(deviceclass='NET', devicename=board_wifi.ProductName):135 return self.set_device(wifi)136 return None137 def set_device(self, data):138 self.device = data139 return data140 def name(self):141 return self.device.DeviceName142 def version(self):143 if self.wifi:144 return self.device.DriverVersion145 return None146 def release_date(self):147 if self.device:148 return format_date(self.device.DriverDate)149class Bluetooth:150 def __init__(self):151 self.device = None152 def info(self):153 for bluetooth in WMI.Win32_PnpSignedDriver(deviceclass='BLUETOOTH'):154 return self.set_device(bluetooth)155 return None156 def set_device(self, data):157 self.device = data158 return data159 def name(self):160 return self.device.DeviceName161 def version(self):162 if self.device:163 return self.device.DriverVersion164 return None165 def release_date(self):166 if self.device:167 return format_date(self.device.DriverDate)168 return None169def find_driver_class(driver):170 driver_class = {...

Full Screen

Full Screen

test_multi_gpu.py

Source:test_multi_gpu.py Github

copy

Full Screen

...8 if torch.cuda.device_count() < 2:9 self.fail(10 "Test is not relevant for this platform since number of available CUDA devices is less than 2"11 )12 torchtrt.set_device(0)13 self.target_gpu = 114 self.input = torch.randn((1, 3, 224, 224)).to("cuda:1")15 self.model = self.model.to("cuda:1")16 self.traced_model = torch.jit.trace(self.model, [self.input])17 self.scripted_model = torch.jit.script(self.model)18 def test_compile_traced(self):19 torchtrt.set_device(0)20 compile_spec = {21 "inputs": [torchtrt.Input(self.input.shape)],22 "device": {23 "device_type": torchtrt.DeviceType.GPU,24 "gpu_id": self.target_gpu,25 "dla_core": 0,26 "allow_gpu_fallback": False,27 "disable_tf32": False,28 },29 }30 trt_mod = torchtrt.ts.compile(self.traced_model, **compile_spec)31 torchtrt.set_device(self.target_gpu)32 same = (trt_mod(self.input) - self.traced_model(self.input)).abs().max()33 torchtrt.set_device(0)34 self.assertTrue(same < 2e-3)35 def test_compile_script(self):36 torchtrt.set_device(0)37 compile_spec = {38 "inputs": [torchtrt.Input(self.input.shape)],39 "device": {40 "device_type": torchtrt.DeviceType.GPU,41 "gpu_id": self.target_gpu,42 "dla_core": 0,43 "allow_gpu_fallback": False,44 "disable_tf32": False,45 },46 }47 trt_mod = torchtrt.ts.compile(self.scripted_model, **compile_spec)48 torchtrt.set_device(self.target_gpu)49 same = (trt_mod(self.input) - self.scripted_model(self.input)).abs().max()50 torchtrt.set_device(0)51 self.assertTrue(same < 2e-3)52class TestMultiGpuSerializeDeserializeSwitching(ModelTestCase):53 def setUp(self):54 if torch.cuda.device_count() < 2:55 self.fail(56 "Test is not relevant for this platform since number of available CUDA devices is less than 2"57 )58 self.target_gpu = 059 torchtrt.set_device(0)60 self.input = torch.randn((1, 3, 224, 224)).to("cuda:0")61 self.model = self.model.to("cuda:0")62 self.traced_model = torch.jit.trace(self.model, [self.input])63 self.scripted_model = torch.jit.script(self.model)64 def test_compile_traced(self):65 torchtrt.set_device(0)66 compile_spec = {67 "inputs": [torchtrt.Input(self.input.shape)],68 "device": {69 "device_type": torchtrt.DeviceType.GPU,70 "gpu_id": self.target_gpu,71 "dla_core": 0,72 "allow_gpu_fallback": False,73 "disable_tf32": False,74 },75 }76 trt_mod = torchtrt.ts.compile(self.traced_model, **compile_spec)77 # Changing the device ID deliberately. It should still run on correct device ID by context switching78 torchtrt.set_device(1)79 same = (trt_mod(self.input) - self.traced_model(self.input)).abs().max()80 self.assertTrue(same < 2e-3)81 def test_compile_script(self):82 torchtrt.set_device(0)83 compile_spec = {84 "inputs": [torchtrt.Input(self.input.shape)],85 "device": {86 "device_type": torchtrt.DeviceType.GPU,87 "gpu_id": self.target_gpu,88 "dla_core": 0,89 "allow_gpu_fallback": False,90 "disable_tf32": False,91 },92 }93 trt_mod = torchtrt.ts.compile(self.scripted_model, **compile_spec)94 # Changing the device ID deliberately. It should still run on correct device ID by context switching95 torchtrt.set_device(1)96 same = (trt_mod(self.input) - self.scripted_model(self.input)).abs().max()97 self.assertTrue(same < 2e-3)98def test_suite():99 suite = unittest.TestSuite()100 suite.addTest(101 TestMultiGpuSwitching.parametrize(102 TestMultiGpuSwitching, model=models.resnet18(pretrained=True)103 )104 )105 suite.addTest(106 TestMultiGpuSerializeDeserializeSwitching.parametrize(107 TestMultiGpuSwitching, model=models.resnet18(pretrained=True)108 )109 )...

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 robotframework-ioslibrary 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