Best Python code snippet using play_selenium_python
mgc3.py
Source:mgc3.py  
1"""mgc32============34.. autoclass:: MGC35   :members:6   :private-members:78This class implements the MGC3 from the Institut Néel - VERSION 2.4910"""1112from ipaddress import ip_address1314from fluidlab.interfaces import PhysicalInterfaceType15from fluidlab.instruments.drivers import Driver16from fluidlab.instruments.features import (17    QueryCommand,18    WriteCommand,19    FloatValue,20    StringValue,21)2223__all__ = ["MGC3"]242526def out_port(ip):27    """28    Out port is 12000 + last number of ip address29    """30    ip = ip_address(ip)31    return 12000 + (int(ip) & 0xFF)323334class MGC3(Driver):35    default_physical_interface = PhysicalInterfaceType.Ethernet36    default_inter_params = {37        "out_port": out_port,38        "in_port": 12000,39        "ethernet_protocol": "udp",40    }414243features = [44    # Identification Query45    QueryCommand("query_identification", "Identification Query", "*IDN?"),46    # # # # # # # # # # # #47    # Read-only commands  #48    # # # # # # # # # # # #49    FloatValue(50        "temperature", doc="MGC3 internal temperature", command_get="MGC3GET 0"51    ),52    # PID0 commands53    FloatValue(54        "pid0_meas",55        doc="MGC3 PID_0 last measurement - in Kelvin",56        command_get="MGC3GET 3",57    ),58    FloatValue(59        "pid0_s", doc="MGC3 PID_0 last watt measurement", command_get="MGC3GET 9"60    ),61    FloatValue("pid0_status", doc="MGC3 PID_0 Status", command_get="MGC3GET 10"),62    # PID1 commands63    FloatValue(64        "pid1_meas",65        doc="MGC3 PID_1 last measurement - in Kelvin",66        command_get="MGC3GET 15",67    ),68    FloatValue(69        "pid1_s", doc="MGC3 PID_1 last watt measurement", command_get="MGC3GET 21"70    ),71    FloatValue("pid1_status", doc="MGC3 PID_1 Status", command_get="MGC3GET 22"),72    # PID2 commands73    FloatValue(74        "pid2_meas",75        doc="MGC3 PID_1 last measurement - in Kelvin",76        command_get="MGC3GET 27",77    ),78    FloatValue(79        "pid2_s", doc="MGC3 PID_1 last watt measurement", command_get="MGC3GET 33"80    ),81    FloatValue("pid2_status", doc="MGC3 PID_1 Status", command_get="MGC3GET 34"),82    # Misc commands83    FloatValue("i0_status", doc="MGC3 CH_0 Status", command_get="MGC3GET 38"),84    FloatValue("i1_status", doc="MGC3 CH_1 Status", command_get="MGC3GET 40"),85    FloatValue("i2_status", doc="MGC3 CH_2 Status", command_get="MGC3GET 42"),86    FloatValue(87        "user_voltage", doc="MGC3 Current user voltage", command_get="MGC3GET 43"88    ),89    # # # # # # # # # #90    #  R+W commands   #91    # # # # # # # # # #92    # PID0 commands93    FloatValue(94        "pid0_onoff",95        doc="MGC3 PID 0, on (1) - off (0)",96        command_get="MGC3GET 1",97        command_set="MGC3SET 1",98        pause_instrument=0.5,99    ),100    FloatValue(101        "pid0_setpoint",102        doc="MGC3 PID 0, set wanted temperature (Kelvin)",103        command_get="MGC3GET 2",104        command_set="MGC3SET 2",105        pause_instrument=0.5,106    ),107    FloatValue(108        "pid0_prop",109        doc="MGC3 PID 0, proportional term",110        command_get="MGC3GET 4",111        command_set="MGC3SET 4",112        pause_instrument=0.5,113    ),114    FloatValue(115        "pid0_integral",116        doc="MGC3 PID 0, integral term",117        command_get="MGC3GET 5",118        command_set="MGC3SET 5",119        pause_instrument=0.5,120    ),121    FloatValue(122        "pid0_deriv",123        doc="MGC3 PID 0, derivative term",124        command_get="MGC3GET 6",125        command_set="MGC3SET 6",126        pause_instrument=0.5,127    ),128    FloatValue(129        "pid0_maxpow",130        doc="MGC3 PID 0, maximum power (W)",131        command_get="MGC3GET 7",132        command_set="MGC3SET 7",133        pause_instrument=0.5,134    ),135    FloatValue(136        "pid0_res",137        doc="MGC3 PID 0, Heat resistance value (Ohm)",138        command_get="MGC3GET 8",139        command_set="MGC3SET 8",140        pause_instrument=0.5,141    ),142    StringValue(143        "pid0_name",144        doc="MGC3 PID 0, measurement model name",145        command_get="MGC3GET 11",146        command_set="MGC3SET 11",147        pause_instrument=1,148        check_instrument_value=False,149    ),150    FloatValue(151        "pid0_channel",152        doc="MGC3 PID 0, measurement channel",153        command_get="MGC3GET 12",154        command_set="MGC3SET 12",155        pause_instrument=0.5,156    ),157    # PID1 commands158    FloatValue(159        "pid1_onoff",160        doc="MGC3 PID 1, on (1) - off (0)",161        command_get="MGC3GET 13",162        command_set="MGC3SET 13",163        pause_instrument=0.5,164    ),165    FloatValue(166        "pid1_setpoint",167        doc="MGC3 PID 1, set wanted temperature (Kelvin)",168        command_get="MGC3GET 14",169        command_set="MGC3SET 14",170        pause_instrument=0.5,171    ),172    FloatValue(173        "pid1_prop",174        doc="MGC3 PID 1, proportional term",175        command_get="MGC3GET 16",176        command_set="MGC3SET 16",177        pause_instrument=0.5,178    ),179    FloatValue(180        "pid1_integral",181        doc="MGC3 PID 1, integral term",182        command_get="MGC3GET 17",183        command_set="MGC3SET 17",184        pause_instrument=0.5,185    ),186    FloatValue(187        "pid1_deriv",188        doc="MGC3 PID 1, derivative term",189        command_get="MGC3GET 18",190        command_set="MGC3SET 18",191        pause_instrument=0.5,192    ),193    FloatValue(194        "pid1_maxpow",195        doc="MGC3 PID 1, maximum power (W)",196        command_get="MGC3GET 19",197        command_set="MGC3SET 19",198        pause_instrument=0.5,199    ),200    FloatValue(201        "pid1_res",202        doc="MGC3 PID 1, Heat resistance value (Ohm)",203        command_get="MGC3GET 20",204        command_set="MGC3SET 20",205        pause_instrument=0.5,206    ),207    StringValue(208        "pid1_name",209        doc="MGC3 PID 1, measurement model name",210        command_get="MGC3GET 23",211        command_set="MGC3SET 23",212        pause_instrument=2,213    ),214    FloatValue(215        "pid1_channel",216        doc="MGC3 PID 1, measurement channel",217        command_get="MGC3GET 24",218        command_set="MGC3SET 24",219        pause_instrument=0.5,220    ),221    # PID2 commands222    FloatValue(223        "pid2_onoff",224        doc="MGC3 PID 2, on (1) - off (0)",225        command_get="MGC3GET 25",226        command_set="MGC3SET 25",227        pause_instrument=0.5,228    ),229    FloatValue(230        "pid2_setpoint",231        doc="MGC3 PID 2, set wanted temperature (Kelvin)",232        command_get="MGC3GET 26",233        command_set="MGC3SET 26",234        pause_instrument=0.5,235    ),236    FloatValue(237        "pid2_prop",238        doc="MGC3 PID 2, proportional term",239        command_get="MGC3GET 28",240        command_set="MGC3SET 28",241        pause_instrument=0.5,242    ),243    FloatValue(244        "pid2_integral",245        doc="MGC3 PID 2, integral term",246        command_get="MGC3GET 29",247        command_set="MGC3SET 29",248        pause_instrument=0.5,249    ),250    FloatValue(251        "pid2_deriv",252        doc="MGC3 PID 2, derivative term",253        command_get="MGC3GET 30",254        command_set="MGC3SET 30",255        pause_instrument=0.5,256    ),257    FloatValue(258        "pid2_maxpow",259        doc="MGC3 PID 2, maximum power (W)",260        command_get="MGC3GET 31",261        command_set="MGC3SET 31",262        pause_instrument=0.5,263    ),264    FloatValue(265        "pid2_res",266        doc="MGC3 PID 2, Heat resistance value (Ohm)",267        command_get="MGC3GET 32",268        command_set="MGC3SET 32",269        pause_instrument=0.5,270    ),271    StringValue(272        "pid2_name",273        doc="MGC3 PID 2, measurement model name",274        command_get="MGC3GET 35",275        command_set="MGC3SET 35",276        pause_instrument=2,277    ),278    FloatValue(279        "pid2_channel",280        doc="MGC3 PID 2, measurement channel",281        command_get="MGC3GET 36",282        command_set="MGC3SET 36",283        pause_instrument=0.5,284    ),285    # I commands286    FloatValue(287        "ch0_i",288        doc="MGC3 CH0 change or get current",289        command_get="MGC3GET 37",290        command_set="MGC3SET 37",291        pause_instrument=0.5,292    ),293    FloatValue(294        "ch1_i",295        doc="MGC3 CH1 change or get current",296        command_get="MGC3GET 39",297        command_set="MGC3SET 39",298        pause_instrument=0.5,299    ),300    FloatValue(301        "ch2_i",302        doc="MGC3 CH2 change or get current",303        command_get="MGC3GET 41",304        command_set="MGC3SET 41",305        pause_instrument=0.5,306    ),307    # TTL commands308    FloatValue(309        "ttl_o1",310        doc="MGC3 TTL output 1",311        command_get="MGC3GET 44",312        command_set="MGC3SET 44",313        pause_instrument=0.5,314    ),315    FloatValue(316        "ttl_o2",317        doc="MGC3 TTL output 2",318        command_get="MGC3GET 45",319        command_set="MGC3SET 45",320        pause_instrument=0.5,321    ),322]323
...mmr3.py
Source:mmr3.py  
1"""mmr32============34.. autoclass:: MMR35   :members:6   :private-members:78This class implements the MMR3 from the Institut Néel - VERSION 2.4910"""1112from ipaddress import ip_address1314from fluidlab.interfaces import PhysicalInterfaceType15from fluidlab.instruments.drivers import Driver16from fluidlab.instruments.features import (17    QueryCommand,18    WriteCommand,19    FloatValue,20    StringValue,21)2223__all__ = ["MMR3"]242526def out_port(ip):27    """28    Out port is 12000 + last number of ip address29    """30    ip = ip_address(ip)31    return 12000 + (int(ip) & 0xFF)323334class MMR3(Driver):35    default_physical_interface = PhysicalInterfaceType.Ethernet36    default_inter_params = {37        "out_port": out_port,38        "in_port": 12000,39        "ethernet_protocol": "udp",40    }414243features = [44    # Identification Query45    QueryCommand("query_identification", "Identification Query", "*IDN?"),46    # # # # # # # # # # # #47    # Read-only commands  #48    # # # # # # # # # # # #49    FloatValue(50        "temperature", doc="MMR3 internal temperature", command_get="MMR3GET 2"51    ),52    # CH1 commands53    FloatValue(54        "r1_meas", doc="MMR3 R1 measurement result", command_get="MMR3GET 3"55    ),56    FloatValue(57        "r1_range", doc="MMR3 R1 range computation", command_get="MMR3GET 4"58    ),59    FloatValue(60        "r1_convert", doc="MMR3 R1 converted value", command_get="MMR3GET 5"61    ),62    FloatValue(63        "r1_status", doc="MMR3 R1 measurement status", command_get="MMR3GET 6"64    ),65    FloatValue(66        "r1_offset", doc="MMR3 R1 offset measurement", command_get="MMR3GET 13"67    ),68    # CH2 commands69    FloatValue(70        "r2_meas", doc="MMR3 R2 measurement result", command_get="MMR3GET 14"71    ),72    FloatValue(73        "r2_range", doc="MMR3 R2 range computation", command_get="MMR3GET 15"74    ),75    FloatValue(76        "r2_convert", doc="MMR3 R2 converted value", command_get="MMR3GET 16"77    ),78    FloatValue(79        "r2_status", doc="MMR3 R2 measurement status", command_get="MMR3GET 17"80    ),81    FloatValue(82        "r2_offset", doc="MMR3 R2 offset measurement", command_get="MMR3GET 24"83    ),84    # CH3 commands85    FloatValue(86        "r3_meas", doc="MMR3 R3 measurement result", command_get="MMR3GET 25"87    ),88    FloatValue(89        "r3_range", doc="MMR3 R3 range computation", command_get="MMR3GET 26"90    ),91    FloatValue(92        "r3_convert", doc="MMR3 MMR3 R3 converted value", command_get="MMR3GET 27"93    ),94    FloatValue(95        "r3_status", doc="MMR3 R3 measurement status", command_get="MMR3GET 28"96    ),97    FloatValue(98        "r3_offset", doc="MMR3 R3 offset measurement", command_get="MMR3GET 35"99    ),100    # # # # # # # # # #101    #  R+W commands   #102    # # # # # # # # # #103    FloatValue(104        "periode",105        doc="MMR3 Modulation period",106        command_get="MMR3GET 0",107        command_set="MMR3SET 0",108        pause_instrument=0.5,109    ),110    FloatValue(111        "dtadc",112        doc="MMR3 ADC delay",113        command_get="MMR3GET 1",114        command_set="MMR3SET 1",115        pause_instrument=0.5,116    ),117    # CH1 commands118    FloatValue(119        "r1_average",120        doc="MMR3 R1 Amount of points in each measurement",121        command_get="MMR3GET 7",122        command_set="MMR3SET 7",123        pause_instrument=0.5,124    ),125    FloatValue(126        "r1_rangemode",127        doc="MMR3 R1 change mode",128        command_get="MMR3GET 8",129        command_set="MMR3SET 8",130        pause_instrument=0.5,131    ),132    FloatValue(133        "r1_rangemode_i",134        doc="MMR3 R1 change mode auto/manual",135        command_get="MMR3GET 9",136        command_set="MMR3SET 9",137        pause_instrument=0.5,138    ),139    FloatValue(140        "r1_range_i",141        doc="MMR3 R1 change flux range",142        command_get="MMR3GET 10",143        command_set="MMR3SET 10",144        pause_instrument=1,145    ),146    FloatValue(147        "r1_range_u",148        doc="MMR3 R1 change voltage range",149        command_get="MMR3GET 11",150        command_set="MMR3SET 11",151        pause_instrument=0.5,152    ),153    FloatValue(154        "r1_i",155        doc="MMR3 R1 change polarization",156        command_get="MMR3GET 12",157        command_set="MMR3SET 12",158        pause_instrument=1,159    ),160    # CH2 commands161    FloatValue(162        "r2_average",163        doc="MMR3 R2 Amount of points in each measurement",164        command_get="MMR3GET 18",165        command_set="MMR3SET 18",166        pause_instrument=0.5,167    ),168    FloatValue(169        "r2_rangemode",170        doc="MMR3 R2 change mode",171        command_get="MMR3GET 19",172        command_set="MMR3SET 19",173        pause_instrument=0.5,174    ),175    FloatValue(176        "r2_rangemode_i",177        doc="MMR3 R2 change mode auto/manual",178        command_get="MMR3GET 20",179        command_set="MMR3SET 20",180        pause_instrument=0.5,181    ),182    FloatValue(183        "r2_range_i",184        doc="MMR3 R2 change flux range",185        command_get="MMR3GET 21",186        command_set="MMR3SET 21",187        pause_instrument=0.5,188    ),189    FloatValue(190        "r2_range_u",191        doc="MMR3 R2 change voltage range",192        command_get="MMR3GET 22",193        command_set="MMR3SET 22",194        pause_instrument=0.5,195    ),196    FloatValue(197        "r2_i",198        doc="MMR3 R2 change polarization",199        command_get="MMR3GET 23",200        command_set="MMR3SET 23",201        pause_instrument=0.5,202    ),203    # CH3 commands204    FloatValue(205        "r3_average",206        doc="MMR3 R3 Amount of points in each measurement",207        command_get="MMR3GET 29",208        command_set="MMR3SET 29",209        pause_instrument=0.5,210    ),211    FloatValue(212        "r3_rangemode",213        doc="MMR3 R3 change mode",214        command_get="MMR3GET 30",215        command_set="MMR3SET 30",216        pause_instrument=0.5,217    ),218    FloatValue(219        "r3_rangemode_i",220        doc="MMR3 R3 change mode auto/manual",221        command_get="MMR3GET 31",222        command_set="MMR3SET 31",223        pause_instrument=0.5,224    ),225    FloatValue(226        "r3_range_i",227        doc="MMR3 R3 change flux range",228        command_get="MMR3GET 32",229        command_set="MMR3SET 32",230        pause_instrument=0.5,231    ),232    FloatValue(233        "r3_range_u",234        doc="MMR3 R3 change voltage range",235        command_get="MMR3GET 33",236        command_set="MMR3SET 33",237        pause_instrument=0.5,238    ),239    FloatValue(240        "r3_i",241        doc="MMR3 R3 change polarization",242        command_get="MMR3GET 34",243        command_set="MMR3SET 34",244        pause_instrument=0.5,245    ),246]247
...bose_battery.py
Source:bose_battery.py  
...9    def read() -> Packet:10        packet = conn.read()11        print("<--", packet)12        return packet13    def command_get(packet: Packet):14        write(packet)15        read()16    def command_start(packet: Packet):17        write(packet)18        processing_packet = Packet(packet.function_block, packet.function, Operator.PROCESSING)19        result_packet = Packet(packet.function_block, packet.function, Operator.RESULT)20        assert read() == processing_packet21        while read() != result_packet:22            pass23    command_get(Packet(FunctionBlock.PRODUCT_INFO, ProductInfoFunction.BMAP_VERSION, Operator.GET))24    # command_get(Packet(FunctionBlock.PRODUCT_INFO, ProductInfoFunction.PRODUCT_ID_VARIANT, Operator.GET))25    # command_get(Packet(FunctionBlock.PRODUCT_INFO, ProductInfoFunction.SERIAL_NUMBER, Operator.GET))26    # command_get(Packet(FunctionBlock.PRODUCT_INFO, ProductInfoFunction.FIRMWARE_VERSION, Operator.GET))27    command_get(Packet(FunctionBlock.STATUS, StatusFunction.BATTERY_LEVEL, Operator.GET))28    # command_get(Packet(FunctionBlock.AUDIO_MANAGEMENT, AudioManagementFunction.STATUS, Operator.GET))29    # command_get(Packet(FunctionBlock.AUDIO_MANAGEMENT, AudioManagementFunction.VOLUME, Operator.GET))30    command_start(Packet(FunctionBlock.AUDIO_MANAGEMENT, AudioManagementFunction.NOW_PLAYING, Operator.START))31    while read():...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
