Esempio n. 1
0
 def init_maq20(self):
     """
     Initializes the MAQ20 system. Because this example is designed to work with the Demo suitcase, it expects 
     to see a JTC, VDN, VO, and DIOL modules.
     After initializing MAQ20, this function starts a timer that is connected to tick()
     :return: no return
     """
     self.status_line.setText("Connecting, please wait.")
     self.connection_switch.setValue(0)
     try:
         self.maq20 = MAQ20(ip_address=self.ip_address_line.displayText(),
                            port=self.port_spinbox.value())
         self.jtc = self.maq20.find("JTC")
         self.vdn = self.maq20.find("VDN")
         dio = self.maq20.find("DIOL")
         self.vo = self.maq20.find("VO")
         self.diol = diol.DIOL(dio)
         self._timer = QTimer()
         self._timer.timeout.connect(self.tick)
         self._timer.start(50)
         self.status_line.setText("Connected to {}".format(
             self.ip_address_line.displayText()))
         self.connection_switch.setValue(1)
     except Exception as e:
         print(e)
         self.status_line.setText("No Connection")
Esempio n. 2
0
    def connectW(self):
        if self.connectedW:
            return

        try:
            self.systemW = None
            self.systemW = MAQ20(ip_address=self.ip, port=self.port)
            self.connectedW = True
            logger.info("Connected to MAQ20 W server at: {}:{}".format(
                self.ip, self.port))
        except Exception as ex:
            logger.error('Error connecting to W MAQ20. {}'.format(str(ex)))
Esempio n. 3
0
    def __init__(self,tester,channels_dict):
        with open(path.join(path.dirname(path.realpath(__file__)),"ip_config.json"),'r') as f:
            configs = json.loads(f.read())
            plutoGateway_ip= configs["plutoGateway_ip"]
            plutoGateway_port=configs["plutoGateway_port"]
            testBox_ip=configs["testBox_ip"]
            testBox_port=configs["testBox_port"]

        #print("plutoGateway:",plutoGateway_ip,plutoGateway_port)
        #print("testBox:",testBox_ip,testBox_port)

        self.system = MAQ20(ip_address=testBox_ip, port=testBox_port)
        self.dict = None


        self.dict = channels_dict

        self.plc = Object()
        self.plc.channels=[]

        self.cam = Object()
        self.cam.channels = []

        self.tester=tester

        for ch in self.dict.keys():
            #print(ch)
            try:
                pass
                exec("self.plc."+ch+" = TestBoxChannel(self,'plc','"+ch+"')")
                exec("self.plc.channels.append(self.plc." + ch + ")")
            except Exception as e:
                pass

            try:
                pass
                exec("self.cam." + ch + " = TestBoxChannel(self,'cam','" +ch + "')")
                exec("self.cam.channels.append(self.cam." + ch + ")")
            except Exception as e:
                print(e)
                pass
"""
Shows how to use a module that has special functions that other modules normally don't have.

This example uses the IVI (not released) to access its burst mode parameters and functions.
"""
from maq20 import MAQ20
from maq20.modules.diol import DIOL

system0 = MAQ20(ip_address="192.168.128.100", port=502)
module_name = 'DIOL'
diol = system0.find(module_name)

if diol is not None:  # Check if module was found.
    diol = DIOL(maq20_module=diol)
else:
    raise TypeError("Module not found.")

diol.write_special_function_5_frequency_generator(
    timer=0, frequency=500)  # frequency generator 500 Hz

print(diol.read_special_function_information(
    timer=0))  # read back the special function settings using timer 0
Esempio n. 5
0
from maq20 import MAQ20

maq20 = MAQ20()
module_1 = maq20[1]  # same as maq20.get_module(1)
module_2 = maq20[2]  # same as maq20.get_module(2)

print('System level:')
print('maq20.read_registers(2000, 10) : {}'.format(
    maq20.read_registers(2000, 10)))
print('maq20.read_registers(4000, 10) : {}'.format(
    maq20.read_registers(4000, 10)))

print('\nModule level:')
# Show that the result is different.
print('module_1.read_registers(0, 10) : {}'.format(
    module_1.read_registers(0,
                            10)))  # this is equivalent to address 2000 to 2010
print('module_2.read_registers(0, 10) : {}'.format(
    module_2.read_registers(0,
                            10)))  # this is equivalent to address 4000 to 4010















maq20 = MAQ20(ip_address=original_ip, port=502)

maq20.write_register(50,new_ip[0])
maq20.write_register(51,new_ip[1])
maq20.write_register(52,new_ip[2])
maq20.write_register(53,new_ip[3])
print(maq20.read_registers(50,4))

maq20.write_register(70,1)





Esempio n. 7
0
    'Flowmeter_main_hot': 'null',
    'Flowmeter_main_cold': 'null',
    'Flowmeter_shed1_hot': 'null',
    'Flowmeter_shed1_cold': 'null',
    'T_shed3_hot': 'null',
    'T_shed3_cold': 'null',
    'T_shed2_hot': 'null',
    'T_shed2_cold': 'null',
    'T_main_hot': 'null',
    'T_main_cold': 'null',
    'T_shed1_hot': 'null',
    'T_shed1_cold': 'null'
}
status_check = {'Exhaust_fan': 'null'}
if demo != 1:
    maq20 = MAQ20(ip_address=ip, port=502)  # Set communication with MAQ20
    #initialize values from MAQ20
    mod1_AI_MVDN = (maq20[1].read_data(
        0, number_of_channels=maq20[1].get_number_of_channels()))
    mod2_AI_TTC = (maq20[2].read_data(
        0, number_of_channels=maq20[2].get_number_of_channels()))
    mod3_AO_VO = maq20[3].read_data(
        0, number_of_channels=maq20[2].get_number_of_channels())
    mod4_DI_DIV20 = (maq20[4].read_data_counts(
        0, number_of_channels=maq20[4].get_number_of_channels()))
    mod5_DI_DIOL = (maq20[5].read_data_counts(
        0, number_of_channels=maq20[5].get_number_of_channels()))
    mod6_DI_DIOL = (maq20[6].read_data_counts(
        0, number_of_channels=maq20[6].get_number_of_channels()))
    mod7_DI_DIOL = (maq20[7].read_data_counts(
        0, number_of_channels=maq20[7].get_number_of_channels()))
Esempio n. 8
0
    def __init__(self, settings):
        self.settings = settings
        self.channel_map_inputs = self.settings['channel_map_inputs']
        self.channel_map_outputs = self.settings['channel_map_outputs']
        self.channel_configs = self.settings['channel_configs']
        self.daq = MAQ20(ip_address=self.settings['host'],
                         port=self.settings['port'])
        self.module_names = [
            'mod1_AI_MVDN', 'mod2_AI_TTC', 'mod3_AO_VO', 'mod4_DI_DIV20',
            'mod5_DIO_DIOL', 'mod6_DIO_DIOL', 'mod7_DIO_DIOL', 'mod8_DIO_DIOL'
        ]
        self.mod1_AI_MVDN = self.daq[1]
        self.mod2_AI_TTC = self.daq[2]
        self.mod3_AO_VO = self.daq[3]
        self.mod4_DI_DIV20 = self.daq[4]
        self.mod5_DIO_DIOL = self.daq[5]
        self.mod6_DIO_DIOL = self.daq[6]
        self.mod7_DIO_DIOL = self.daq[7]
        self.mod8_DIO_DIOL = self.daq[8]
        self.module_instances = [
            self.mod1_AI_MVDN, self.mod2_AI_TTC, self.mod3_AO_VO,
            self.mod4_DI_DIV20, self.mod5_DIO_DIOL, self.mod6_DIO_DIOL,
            self.mod7_DIO_DIOL, self.mod8_DIO_DIOL
        ]
        self.modules = dict(zip(self.module_names, self.module_instances))

        #-----Initialize Special Functions on DIOL modules----
        self.modules_special = []
        for channel in self.channel_configs:
            if channel in self.channel_map_inputs:  #check if input
                x = len(self.channel_map_inputs[channel]
                        ) - self.channel_map_inputs[channel].find('[')
                if self.channel_configs[
                        channel] == "counter":  #case for counter with debounce
                    module = str(self.channel_map_inputs[channel])[:-x]
                    if str(self.channel_map_inputs[channel]
                           )[-2] == '0':  #case for timer 0 on input 0
                        timer = 0
                    elif str(self.channel_map_inputs[channel]
                             )[-2] == '2':  #case for time 1 on input 2
                        timer = 1
                    else:
                        print(
                            "Channel name error, channel cannot be used in special function"
                        )
                    if module in self.modules_special:  #check if module already instantiated as DIOL
                        eval(
                            'self.' + module
                        ).write_special_function_2_pulse_frequency_counter_with_debounce(
                            timer=timer, internal_trigger=1)
                    else:
                        self.modules_special.append(module)
                        exec('self.' + module + "=" +
                             "DIOL(maq20_module=self." + module + ")")
                        eval(
                            'self.' + module
                        ).write_special_function_2_pulse_frequency_counter_with_debounce(
                            timer=timer, internal_trigger=1)
                else:
                    pass
            else:
                x = len(self.channel_map_outputs[channel]
                        ) - self.channel_map_outputs[channel].find('[')
                if self.channel_configs[
                        channel] == "frequency_generator":  #case for frequency generator
                    module = str(self.channel_map_outputs[channel])[:-x]
                    if str(self.channel_map_outputs[channel]
                           )[-2] == '0':  #case for timer 0 on input 0
                        timer = 0
                    elif str(self.channel_map_outputs[channel]
                             )[-2] == '2':  #case for time 1 on input 2
                        timer = 1
                    else:
                        print(
                            "Channel name error, channel cannot be used in special function"
                        )
                    if module in self.modules_special:
                        eval('self.' + module
                             ).write_special_function_5_frequency_generator(
                                 timer=timer, frequency=0)
                    else:
                        self.modules_special.append(module)
                        exec('self.' + module + "=" +
                             "DIOL(maq20_module=self." + module + ")")
                        eval('self.' + module
                             ).write_special_function_5_frequency_generator(
                                 timer=timer, frequency=0)
                else:
                    pass
Esempio n. 9
0
"""
Example showing how to write data to a module using list notation.
"""
from maq20 import MAQ20

maq20 = MAQ20(
)  # Initialize system with default parameters ip_address='192.168.128.100', port=520
output_module = maq20.find(
    "VO")  # get a reference to the output module by finding by name.

if output_module is None:  # check if the module was found.
    raise TypeError('Module not found')

initial_state = output_module[:]  # Read the current state of the channels.
print('Initial state = output_module[:]\n{}'.format(
    initial_state))  # print its current state

print('\nWriting to all channels at once:')
"""
The following command construct a list by using the built-in len() function and then using a for loop
to write a list that looks like:
[3.3, 3.3, 3.3, ..., 3.3]
"""
output_module[:] = [3.3 for _ in range(len(output_module))]
print('output_module[:] = [3.3 for _ in range(len(output_module))]\n{}'.format(
    output_module[:]))  # print the state again.

print('\nWrite to one channel:')
output_module[0] = 1.2
print('output_module[0] = 1.2\n{}'.format(
    output_module[:]))  # print the state again.
Esempio n. 10
0
"""
Shows how to setup an output module for writing data to it and shows how to write data.
"""
from maq20 import MAQ20

maq20 = MAQ20(ip_address="192.168.128.100", port=502)  # Initialize
vo = maq20.find("VO")  # get a reference to the module by name

if vo is None:  # check if module was found
    raise TypeError("Module was not found")

initial_value = vo.read_channel_data(3)  # Read initial value
print('Initial output value: {}'.format(initial_value))

vo.write_channel_data(channel=3, data=3.3)  # write using write_data()
print('Output value after writing: {}'.format(vo.read_channel_data(3)))

vo.write_channel_data(channel=3,
                      data=initial_value)  # write back initial value.
Esempio n. 11
0
from maq20 import MAQ20

system = MAQ20(ip_address="192.168.1.101", port=502)

#print (system.find("S0124418-04"))

print(system)

m = system.find("VO")
m = system.find("S0124418-04")
m = system.find("S0115278-06")

#m=system.find("S0120611-14")

#print (m)

#print(m.write_channel_data(1,True))

#print(m.write_channel_data(0,4.5))
#print(m.read_channel_data(0))

#m2 = system.find("S0115278-06")
#print(m2.read_channel_data(0))
Esempio n. 12
0
from maq20 import MAQ20

ip = "192.168.1.171"
#ip = "192.168.1.153"
#ip = "192.168.1.155"
#ip = "192.168.1.157"
#ip = "192.168.1.159"

maq20 = MAQ20(ip_address=ip, port=502)
print(maq20)