def start():

    logging.info("Starting...")

    global screens
    global curScreen
    global prevScreen

    screens["mainMenu"].setOptions(mainMenuOptions)
    screens["power"].setOptions(powerOptions)
    screens["print"].setOptions(printerFuntions)
    screens["printer"].setOptions(printerOptions)
    screens["outlet"].setOptions(outletOptions)

    logging.debug("Clearing LCD")
    Lcd.clear()

    logging.debug("Initing Hardware")
    Hardware.init()

    logging.debug("Starting checkPrinter thread")
    thread.start_new_thread(checkPrinter, ())

    logging.info("Started")

    while (True):
        Hardware.update()
        if not curScreen == prevScreen:
            screens[curScreen].init()
            logging.info("Changing Screen to {}".format(curScreen))
            prevScreen = curScreen

        screens[curScreen].update()
        screens[curScreen].draw()
        curScreen = screens[curScreen].nextScreen()
Пример #2
0
def readBridgeIglooReg(bus):
    h.openChannel(slot,bus)
    bus.write(0x00,[0x06])
    bus.write(h.getCardAddress(slot),[0x22])
    bus.read(h.getCardAddress(slot),4)
    read1 = bus.sendBatch()[-1]
    print 'BRIDGE IGLOO REG Read: '+str(read1)
Пример #3
0
 def wating_queue_msg_thread(self):
     print("wating_queue_msg start ...")
     try:
         while True:
             queue_msg = Constant.msg_queue.get()
             if queue_msg is not None:
                 print(str(queue_msg))
                 key = list(queue_msg.keys())[0]
                 if key == "on_connected":  # MQTT已连接
                     connected_data = queue_msg["on_connected"]
                     # print("mqtt connected with code :" + connected_data.get("connected_code"))
                     if connected_data is not None and connected_data.get(
                             "connected_code") == "0":
                         if self.aep is None:
                             print("开启AEP业务....")
                             self.aep = AEP()
                 elif key == "on_message":  # 收到MQTT消息
                     if self.aep is not None:
                         self.aep.on_message(queue_msg["on_message"])
                     else:
                         print("self.aep is None can not deal message")
                 elif key == "play_next":  # 播放下一首
                     self.aep.play_next()
                 elif key == "aep_heart":
                     # print(">>>>>>>>>>>>>>>>>>>>>>>>>> aep_heart")
                     time.sleep(0.3)
                     if "volume_on" == queue_msg["aep_heart"]:
                         Hardware.switch_voice(True)
                     else:
                         Hardware.switch_voice(False)
                     if self.aep is not None:
                         self.aep.change_heart()
     except Exception as e:
         print("wating_queue_msg Exception:" + str(e))
         self.wating_queue_msg_thread()
Пример #4
0
 def diag_response(self):
     rtc_dt_utc = Hardware.get_datetime()
     rtc_dt_local = Hardware.fmt_datetime_local(rtc_dt_utc)
     rtc_dt_utc = Hardware.fmt_datetime(rtc_dt_utc)
     hw_state_desc = (
             Hardware.STATE.__doc__,
             ((state.name, state.value) for state in Hardware.STATE),
         )
     state_name = Hardware.get_state_name()
     next_state_time = Hardware.fmt_datetime(state_name[1])
     state_name = state_name[0]
     data = {
         "alarms": Hardware.get_alarm_strings(),
         "current_time_utc": rtc_dt_utc,
         "current_time_local": rtc_dt_local,
         # "hw_state": hw_state_desc,
         "hw_temp": Hardware.get_temperature_fahrenheit(),
         "state_name": state_name,
         "next_state_time": next_state_time,
         "timezone": Hardware.get_timezone_name(),
         "uerror": Hardware.get_unrecoverable_error_str(),
         "uptime": Hardware.proc_uptime_str(),
         "version": Hardware.versions_tuple
     }
     return self.data_response(data)
def start():
    
    logging.info("Starting...")

    global screens
    global curScreen
    global prevScreen
    
    screens["mainMenu"].setOptions(mainMenuOptions)
    screens["power"].setOptions(powerOptions)
    screens["print"].setOptions(printerFuntions)
    screens["printer"].setOptions(printerOptions)
    screens["outlet"].setOptions(outletOptions)

    logging.debug("Clearing LCD")
    Lcd.clear()

    logging.debug("Initing Hardware")
    Hardware.init()
    
    logging.debug("Starting checkPrinter thread")
    thread.start_new_thread(checkPrinter, ())
    
    logging.info("Started")

    while(True):
        Hardware.update()
        if not curScreen == prevScreen:
            screens[curScreen].init()
            logging.info("Changing Screen to {}".format(curScreen))
            prevScreen = curScreen
        
        screens[curScreen].update()
        screens[curScreen].draw()
        curScreen = screens[curScreen].nextScreen()
Пример #6
0
def runSelect(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])

    m = fpgaMajVer(bus,i.igloo["fpgaMajVer"]["register"],'iglooClass.txt', 1)
    print m.run()
    m = fpgaMinVer(bus,i.igloo["fpgaMinVer"]["register"],'iglooClass.txt', 1)
    print m.run()
Пример #7
0
def runSelect(bus):
    h.openChannel(slot, bus)
    bus.write(h.getCardAddress(slot), [0x11, 0x03, 0, 0, 0])

    m = fpgaMajVer(bus, i.igloo["fpgaMajVer"]["register"], 'iglooClass.txt', 1)
    print m.run()
    m = fpgaMinVer(bus, i.igloo["fpgaMinVer"]["register"], 'iglooClass.txt', 1)
    print m.run()
Пример #8
0
def readOutInputSpy(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])
    m = cntrRegDisplay(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
    m = cntrRegChange(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run('WrEn_InputSpy', '1')

    m = inputSpy(bus,i.igloo["inputSpy"]["register"], 512)
    print m.run()
Пример #9
0
class Game:
    def __init__(self):
        settings.init()

        self.gameMode = None
        self.gameModeSelect = GameModeSelect()
        self.Hardware = Hardware()
        self.running = False
        self.startButtonPressed = False
        self.leftFlipperButtonPressed = False
        self.rightFlipperButtonPressed = False
        # This loop runs always and has 2 states game selection state and a game running state.
        while (True):
            triggeredRelayElements = []
            # If running is true than the programm enters the game state.
            if (self.running):
                activeSensorElements = self.Hardware.checkSensorElements()
                triggeredRelayElements = self.gameMode.checkRules(
                    activeSensorElements)
                self.Hardware.activateRelayElements(triggeredRelayElements)

                if (self.gameMode.gameStatus == False):
                    self.running = False
                    self.gameModeSelect = GameModeSelect()
            else:
                triggeredRelayElements = self.Hardware.checkSensorElements()
                if settings.startButton in triggeredRelayElements:  # startbutton W.I.P
                    if (self.startButtonPressed == False):
                        self.startButtonPressed = True
                        if (self.gameModeSelect.nextStep()):

                            selectedGame = self.gameModeSelect.getSelectedGameMode(
                            )
                            self.gameMode = GameMode(settings.generalGameRules,
                                                     selectedGame[0],
                                                     selectedGame[1])
                            self.running = True
                else:
                    self.startButtonPressed = False

                if settings.leftFlipperButton in triggeredRelayElements:

                    if (self.leftFlipperButtonPressed == False):
                        self.gameModeSelect.decrementField()
                        self.leftFlipperButtonPressed = True
                else:
                    self.leftFlipperButtonPressed = False

                if settings.rightFlipperButton in triggeredRelayElements:

                    if (self.rightFlipperButtonPressed == False):
                        self.gameModeSelect.incrementField()
                        self.rightFlipperButtonPressed = True
                else:
                    self.rightFlipperButtonPressed = False
Пример #10
0
def runAll(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])

    m = fpgaMajVer(bus,i.igloo["fpgaMajVer"]["register"], 1)
    print m.run()
    m = fpgaMinVer(bus,i.igloo["fpgaMinVer"]["register"], 1)
    print m.run()
    m = ones(bus,i.igloo["ones"]["register"], 1)
    print m.run()
    m = zeroes(bus,i.igloo["zeroes"]["register"], 1)
    print m.run()
    m = fpgaTopOrBottom(bus,i.igloo["fpgaTopOrBottom"]["register"], 1)
    print m.run()
    m = uniqueID(bus,i.igloo["uniqueID"]["register"], 1)
    print m.run()
    m = statusReg(bus,i.igloo["statusReg"]["register"], 1)
    print m.run()
    m = cntrRegDisplay(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
    m = cntrRegChange(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run('all', '')
    m = clk_count(bus,i.igloo["clk_count"]["register"], 1)
    print m.run()
    m = rst_QIE_count(bus,i.igloo["rst_QIE_count"]["register"], 1)
    print m.run()
    m = wte_count(bus,i.igloo["wte_count"]["register"], 1)
    print m.run()
    m = capIDErr_count(bus,i.igloo["capIDErr_count"]["register"], 1)
    print m.run()
    m = fifo_data(bus,i.igloo["fifo_data"]["register"], 1)
    print m.run()
    m = inputSpy(bus,i.igloo["inputSpy"]["register"], 1)
    print m.run()
    m = spy96Bits(bus,i.igloo["spy96Bits"]["register"], 1)
    print m.run()
    m = qie_ck_ph(bus,i.igloo["qie_ck_ph"]["register"], 1)
    print m.run()
    m = link_test_mode(bus,i.igloo["link_test_mode"]["register"], 1)
    print m.run()
    m = link_test_pattern(bus,i.igloo["link_test_pattern"]["register"], 1)
    print m.run()
    m = dataToSERDES(bus,i.igloo["dataToSERDES"]["register"], 1)
    print m.run()
    m = addrToSERDES(bus,i.igloo["addrToSERDES"]["register"], 1)
    print m.run()
    m = ctrlToSERDES(bus,i.igloo["ctrlToSERDES"]["register"], 1)
    print m.run()
    m = dataFromSERDES(bus,i.igloo["dataFromSERDES"]["register"], 1)
    print m.run()
    m = statFromSERDES(bus,i.igloo["statFromSERDES"]["register"], 1)
    print m.run()
    m = scratchReg(bus,i.igloo["scratchReg"]["register"], 1)
    print m.run()
Пример #11
0
    def update_some_info(self):
        try:
            while Constant.MQTT_CLIENT is None or not Constant.MQTT_CLIENT.is_connected(
            ):
                time.sleep(10)
            Hardware.get_iccid()
            if "1" == Constant.G4EN and "" == Constant.iccid:
                time.sleep(60)
                Hardware.get_iccid()
                if "" == Constant.iccid:
                    time.sleep(60)
                    Hardware.get_iccid()
            print("上报iccid: " + time.strftime("%Y-%m-%d %H:%M:%S"))
            pack_data = dict(action="info_report",
                             device_id=Constant.SN,
                             firmware_version="ct2.1",
                             hardware_version="v1.2",
                             iccid=Constant.iccid)
            self.update_pack_data(pack_data)
        except Exception as e:
            print(str(e))

        if "1" != Constant.G4EN:
            print("非4G设备不上报基站信息")
            return
        """{ 
                "action": " signal_report", 
                "device_id": "设备id", 
                "rsrp": rsrp值, 
                "pci": pci值, 
                "ecl": ecl值, 
                "cell_id": cell_id值, 
                }"""
        try:
            Hardware.get_rsrp_pci_cellid_rssi()
            while "" == Constant.rsrp or "" == Constant.pci or "" == Constant.cell_id:
                time.sleep(60)
                Hardware.get_rsrp_pci_cellid_rssi()
            print("上报基站信息: " + time.strftime("%Y-%m-%d %H:%M:%S"))
            pack_data = dict(action="signal_report",
                             device_id=Constant.SN,
                             rsrp=Constant.rsrp,
                             pci=Constant.pci,
                             ecl=Constant.ecl,
                             cell_id=Constant.cell_id)
            self.update_pack_data(pack_data)
        except Exception as e:
            print(str(e))
Пример #12
0
 def getID(self):
     Hardware.openChannel(self.slot, self.bus)
     # Reset entire board by writing 0x6 to 0x0.
     self.bus.write(0x00,[0x06])
     # Note that the i2c_select has register address 0x11
     # Value : 4 = 0x04 selects 0x50
     # Note that the SSN expects 32 bits (4 bytes) for writing (send 0x4, 0, 0, 0)
     self.bus.write(Hardware.getCardAddress(self.slot),[0x11,0x04,0,0,0])
     # Send 0x0 to 0x50 in order to set pointer for reading ID
     # This removes the permutation problem!
     self.bus.write(0x50,[0x00])
     self.bus.read(0x50,8)
     raw = self.bus.sendBatch()[-1]
     # Checksum
     check = Check(raw,0)
     if check.result != 0:
         print 'checksum error'
     return raw
Пример #13
0
def detectasom1s():
    vezes = 0
    for x in range(100):
        time.sleep(.01)
        vezes += Hardware.sensor()
    if vezes > 0:
        return 'Som Detectado'

    else:
        return 'Nada Detectado'
Пример #14
0
 def getID(self):
     Hardware.openChannel(self.slot, self.bus)
     # Reset entire board by writing 0x6 to 0x0.
     self.bus.write(0x00, [0x06])
     # Note that the i2c_select has register address 0x11
     # Value : 4 = 0x04 selects 0x50
     # Note that the SSN expects 32 bits (4 bytes) for writing (send 0x4, 0, 0, 0)
     self.bus.write(Hardware.getCardAddress(self.slot),
                    [0x11, 0x04, 0, 0, 0])
     # Send 0x0 to 0x50 in order to set pointer for reading ID
     # This removes the permutation problem!
     self.bus.write(0x50, [0x00])
     self.bus.read(0x50, 8)
     raw = self.bus.sendBatch()[-1]
     # Checksum
     check = Check(raw, 0)
     if check.result != 0:
         print 'checksum error'
     return raw
Пример #15
0
	def QIE_mapping(self):
		# Records the uHTR slot, link, and channel of each QIE in master_dict
		failures=[]
		for j, qslot in enumerate(self.qcards):
			if self.V: print 'mapping qslot '+str(qslot)
			dc=hw.getDChains(qslot, self.bus)
			hw.SetQInjMode(0, qslot, self.bus)
			dc.read()
			
			for mapchip in [0,6]:
				try_map = True
				while try_map:

					for num in xrange(12):
						dc[num].PedestalDAC(-9)
						if num==mapchip:
							dc[num].PedestalDAC(31)
					dc.write()
					dc.read()
					info=self.get_mapping_histo()

					if info is not None:
						uhtr_slot=info[0]
						link=info[1]
						for i in xrange(6):
							if mapchip in range(6): self.add_QIE(qslot, i, uhtr_slot, link, 5-i)
							else: self.add_QIE(qslot, 6+i, uhtr_slot, link, 5-i)
						try_map = False

					elif mapchip == 5 or mapchip == 11:
						if j not in failures:
							print 'mapping qcard {0} failed really hard'.format(qslot)
							failures.append(j)
						try_map = False						

					else: mapchip += 1

			for chip in xrange(12):
				dc[chip].PedestalDAC(6)
				dc.write()
				dc.read()

		if len(failures) > 0:
			failures.reverse() 
			for failure in failures:
				a = self.qcards[failure]
				self.qcards.pop(failure)
				print "qcard {0} successfully popped from self.qcards".format(a)


		if self.V:
			for qslot in self.qcards:
				for chip in xrange(12):
					info=self.get_QIE_map(qslot, chip)
					print 'Q_slot: {4}, Qie: {3}, uhtr_slot: {0}, link: {1}, channel: {2}'.format(info[0], info[1], info[2], chip, qslot)
Пример #16
0
def setTimingThresholdDAC(slots, threshold_val, bus):

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].TimingThresholdDAC(threshold_val) # change threshold

        dcs.write() # write the changes for both daisy chains
Пример #17
0
def processData(eInfo, mInfo, sInfo, testMode, verbose, opt=None):
    if mInfo:
        try:
            resIdx = ResourceIndex()
            Hardware.getHardwareInfo(resIdx, mInfo.machineFile)

            writeList = resIdx.PTdF()
            f = open(mInfo.machinePTdF, 'w')
            for w in writeList:
                f.write(w)
            f.close()
            print "PTDF machine data generation complete."
        except PTexception, a:
            raise
            if testMode:
                print a
                raise PTexception(a)
            else:
                print a.value
                return -1
Пример #18
0
def setTimingThresholdDAC(slots, threshold_val, bus):

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].TimingThresholdDAC(threshold_val) # change threshold

        dcs.write() # write the changes for both daisy chains
Пример #19
0
 def waite_write_sn_mac(self):
     Hardware.wait_sn_mac_info()
     while True:
         value = input()
         if "serialwrite" in value:
             value = value.replace("serialwrite", "").replace(
                 " ", "").replace("\"", "").replace("'", "")
             if value is not None:
                 FileUtil.set_conf(Constant.SERIAL_MAC_PATH, "sn_mac", "SN",
                                   value)
                 print("\n===SN OK !\n")
         elif "writemac" in value:
             value = value.replace("writemac", "").replace(" ", "").replace(
                 "\"", "").replace("'", "")
             if value is not None:
                 FileUtil.set_conf(Constant.SERIAL_MAC_PATH, "sn_mac",
                                   "MAC", value)
                 print("\n===MAC OK\n")
         elif "reboot" in value:
             os.system("reboot")
Пример #20
0
def processData(eInfo, mInfo, sInfo, testMode, verbose, opt = None):
    if mInfo:
       try:
         resIdx = ResourceIndex()
         Hardware.getHardwareInfo(resIdx, mInfo.machineFile)

         writeList = resIdx.PTdF()
         f = open(mInfo.machinePTdF,'w')
         for w in writeList:
            f.write(w)
         f.close()
         print "PTDF machine data generation complete."
       except PTexception, a:
           raise
           if testMode:
              print a
              raise PTexception(a)
           else:
              print a.value
              return -1
Пример #21
0
def setFixRangeModeOff(slots, bus):
    #fixed range mode = 1, autorange mode = 0

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].FixRange(0) # turn fixed range OFF

        dcs.write() # write the changes for both daisy chains
Пример #22
0
def setGsel(slots, gsel_val, bus):
    # valid gsel_val: 0,1,2,4,8,16,18,20,24
    # corresponds to 3.1, 4.65, 6.2, 9.3, 12.4, 15.5, 18.6, 21.7, 24.8 fC/LSB gain
    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].Gsel(gsel_val) # change gain

        dcs.write() # write the changes for both daisy chains
Пример #23
0
	def __init__(self, md_pins):
		# mp.Process.__init__(self)
		# logging.basicConfig(level=logging.INFO)
		# self.logger = logging.getLogger('robot')
		if len(md_pins) != 8:
			raise Exception('Wrong number of pins for motor driver!')

		self.md = md.MotorDriver(*md_pins)
		self.digital_ir = DigitalIR([1, 2, 3, 4])
		self.analog_ir = AnalogIR()
		self.imu = IMU()
		self.ahrs = AHRS(True)
Пример #24
0
def setFixRangeModeOff(slots, bus):
    #fixed range mode = 1, autorange mode = 0

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].FixRange(0) # turn fixed range OFF

        dcs.write() # write the changes for both daisy chains
Пример #25
0
def setGsel(slots, gsel_val, bus):
    # valid gsel_val: 0,1,2,4,8,16,18,20,24
    # corresponds to 3.1, 4.65, 6.2, 9.3, 12.4, 15.5, 18.6, 21.7, 24.8 fC/LSB gain
    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].Gsel(gsel_val) # change gain

        dcs.write() # write the changes for both daisy chains
Пример #26
0
def setPedestalDAC(slots, pedestal_val, bus):
    #pedestal = magnitude * 2 fC
    #takes magnitudes -31 to 31

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].PedestalDAC(pedestal_val) # change pedestal

        dcs.write() # write the changes for both daisy chains
Пример #27
0
def setCapID0pedestal(slots, pedestal_val, bus):
    #pedestal = magnitude * ~1.9 fC
    #takes magnitudes -12 to 12

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].CapID0pedestal(pedestal_val) # change pedestal

        dcs.write() # write the changes for both daisy chains
Пример #28
0
def setCapID0pedestal(slots, pedestal_val, bus):
    #pedestal = magnitude * ~1.9 fC
    #takes magnitudes -12 to 12

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].CapID0pedestal(pedestal_val) # change pedestal

        dcs.write() # write the changes for both daisy chains
Пример #29
0
def setPedestalDAC(slots, pedestal_val, bus):
    #pedestal = magnitude * 2 fC
    #takes magnitudes -31 to 31

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot,bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].PedestalDAC(pedestal_val) # change pedestal

        dcs.write() # write the changes for both daisy chains
Пример #30
0
def printDaisyChain(slots, bus):
    for i_slot in slots: # all desired slots
        ''' makes instance of daisy chain class for each card '''
        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card

        dcs.read() # get real values for 2 daisy chains

        print '\n\n>>>>>>>>>>>> SLOT %d <<<<<<<<<<<<<' %i_slot

        for chip in xrange(12):
            print '\n######## CHIP %d ########' %chip
            print dcs[chip]

        print '############################'
Пример #31
0
def printDaisyChain(slots, bus):
    for i_slot in slots: # all desired slots
        ''' makes instance of daisy chain class for each card '''
        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card

        dcs.read() # get real values for 2 daisy chains

        print '\n\n>>>>>>>>>>>> SLOT %d <<<<<<<<<<<<<' %i_slot

        for chip in xrange(12):
            print '\n######## CHIP %d ########' %chip
            print dcs[chip]

        print '############################'
Пример #32
0
def FirstTimeSetup():
    global cycle

    Log.ConsoleDebug(
        LogType, '---------------- NEW INSTANCE OF PIPLANTER ----------------')

    MySQL_Commands = {
        1: 'CREATE DATABASE IF NOT EXISTS PiPlanter_DB',
        2:
        "GRANT ALL ON `PiPlanter_DB`.* TO 'piplanter'@'localhost' IDENTIFIED BY 'password'",
        3: 'USE PiPlanter_DB'
    }
    for i in MySQL_Commands.itervalues():
        Log.ConsoleDebug(LogType, 'MYSQL COMMAND: ' + i)
        cursor.execute(i)

    MySQLTableSetup(False, 'Daily', True)
    VisualLocationSetup(True, 'dontcare')
    cycle = 0

    Hardware.WriteLEDs(0, 0, 0)
    Hardware.WriteLEDs(255, 0, 255)
    Log.ConsoleDebug(LogType, 'Setup Complete')
Пример #33
0
def runSelect(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])

    m = fpgaMajVer(bus,i.igloo["fpgaMajVer"]["register"], 1)
    print m.run()
    m = fpgaMinVer(bus,i.igloo["fpgaMinVer"]["register"], 1)
    print m.run()
    m = ones(bus,i.igloo["ones"]["register"], 1)
    print m.run()
    m = zeroes(bus,i.igloo["zeroes"]["register"], 1)
    print m.run()
    m = fpgaTopOrBottom(bus,i.igloo["fpgaTopOrBottom"]["register"], 1)
    print m.run()
    m = uniqueID(bus,i.igloo["uniqueID"]["register"], 1)
    print m.run()
    m = statusReg(bus,i.igloo["statusReg"]["register"], 1)
    print m.run()
    m = cntrRegDisplay(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
    m = clk_count(bus,i.igloo["clk_count"]["register"], 1)
    print m.run()
    m = rst_QIE_count(bus,i.igloo["rst_QIE_count"]["register"], 1)
    print m.run()
    m = wte_count(bus,i.igloo["wte_count"]["register"], 1)
    print m.run()
    m = capIDErr_count(bus,i.igloo["capIDErr_count"]["register"], 1)
    print m.run()
    # m = inputSpy(bus,i.igloo["inputSpy"]["register"], 1)
    # print m.run()
    # m = inputSpy_512Reads(bus,i.igloo["inputSpy"]["register"], 1)
    # print m.run()
    m = CI_Mode_On(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
    m = CI_Mode_Off(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
Пример #34
0
	def shunt_scan(self):
		peak_results = {}
		default_peaks = [] #holds the CI values for 3.1 fC/LSB setting for chips
		ratio_pf = [0,0] #pass/fail for ratio within 10% of nominal
		default_peaks_AVG = 0
		#GSel table gain values (in fC/LSB)
		# gain_settings = [3.1, 4.65, 6.2, 9.3, 12.4, 15.5, 18.6, 21.7, 24.8]
		# gain_settings = [0,1,2,4,8,16,18,20,24]
		gain_settings = [0]
		#ratio between default 3.1fC/LSB and itself/other GSel gains
		nominalGainRatios = [1.0, .67, .5, .33, .25, .2, .17, .14, 0.02]
		for setting in gain_settings:
			print "\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
			print "&&&&&&&&&&&&&&&&&&&& S E T. = %d &&&&&&&&&&&&&&&&&&&&&&&&" %setting
			print "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"

			for qslot in self.qcards:
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				hw.SetQInjMode(1, qslot, self.bus) #turn on CI mode (igloo function)
				i.displayCI(self.bus, qslot)
				for chip in xrange(12):
					dc[chip].PedestalDAC(31)
					dc[chip].ChargeInjectDAC(8640) #set max CI value
					dc[chip].Gsel(setting) #increase shunt/decrease gain
				dc.write()
				dc.read()

			histo_results=self.get_histo_results(self.crate, self.uhtr_slots, signalOn=True)

			for uhtr_slot, uhtr_slot_results in histo_results.iteritems():
				for chip, chip_results in uhtr_slot_results.iteritems():
					key="({0}, {1}, {2})".format(uhtr_slot, chip_results["link"], chip_results["channel"])
					if setting == 0: peak_results[key] = []
					peak_results[key].append(chip_results["signalBinMax"])
					if setting == 0 and chip_results['signalBinMax'] != 1:
						default_peaks.append(chip_results['signalBinMax'])

			print "\n\nPeak Results: ", peak_results,'\n\n\n\n\n'
			print "\n\n\n##########################################"
			print "##########################################\n"
			print "Default peaks: ", default_peaks

		total = 0
		for val in default_peaks:
			default_peaks_AVG += val
			total += 1
		default_peaks_AVG /= total
Пример #35
0
def aLoop():
    Log.ConsoleDebug(LogType, "Starting aLoop")
    global cycle
    SampleAllSensors(10, 'MySQL')
    Log.ConsoleDebug(LogType, SampleAllSensors(10, 'Console'))

    imagetext = SampleAllSensors(
        10,
        'Image Overlay') + ' ' + datetime.now().strftime("%I:%M:%S%p %m/%d/%Y")
    image = Hardware.CaptureImage(VisualLocation['CurrentImageDirectory'],
                                  cycle, False, imagetext)

    time.sleep(5)
    tweet = SampleAllSensors(
        10, 'Twitter') + " http://www.esologic.com/piplanter" + " #PiPlanter"

    DataToWeb.TryTweet(True, image, tweet)

    cycle = cycle + 1
    Log.ConsoleDebug(LogType, 'aLoop Complete')
Пример #36
0
def setChargeInjectDAC(slots, charge_val, bus):
        # charge_val is decimal in fC:
        # 90   : (0,0,0),
        # 180  : (0,0,1),
        # 360  : (0,1,0),
        # 720  : (0,1,1),
        # 1440 : (1,0,0),
        # 2880 : (1,0,1),
        # 5760 : (1,1,0),
        # 8640 : (1,1,1)

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].ChargeInjectDAC(charge_val)

        dcs.write() # write the changes for both daisy chains
Пример #37
0
def setChargeInjectDAC(slots, charge_val, bus):
        # charge_val is decimal in fC:
        # 90   : (0,0,0),
        # 180  : (0,0,1),
        # 360  : (0,1,0),
        # 720  : (0,1,1),
        # 1440 : (1,0,0),
        # 2880 : (1,0,1),
        # 5760 : (1,1,0),
        # 8640 : (1,1,1)

    for i_slot in slots: # all desired slots

        dcs = h.getDChains(i_slot, bus) # the 2 daisy chains from one QIE card
        dcs.read()

        for chip in xrange(12): # all 12 chips
            dcs[chip].ChargeInjectDAC(charge_val)

        dcs.write() # write the changes for both daisy chains
Пример #38
0
	def ped_test(self):
		ped_results = {}
		ped_settings = list(i-31 for i in xrange(63))
		ped_results={}
		ped_results["settings"]=ped_settings
		for setting in ped_settings:
			for qslot in self.qcards:
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				for chip in xrange(12):
					dc[chip].PedestalDAC(setting)
				dc.write()
				dc.read()
			histo_results=self.get_histo_results(self.crate, self.uhtr_slots)
			for uhtr_slot, uhtr_slot_results in histo_results.iteritems():
				for chip, chip_results in uhtr_slot_results.iteritems():
					key="({0}, {1}, {2})".format(uhtr_slot, chip_results["link"], chip_results["channel"])
					ped_results[key].append(chip_results["PedBinMax"])

		for qslot in self.qcards:
			for chip in xrange(12):
				ped_key=str(self.get_QIE_map(qslot, chip))
				chip_arr=ped_results[ped_key]
Пример #39
0
	def charge_inject_test(self):
		ci_results = {} #ci=chargeinjection
		ci_settings = [90, 180, 360, 720, 1440, 2880, 5760, 8640] #in fC
		ci_results={}
		ci_results["settings"]=ci_settings
		for setting in ci_settings:
			for qslot in self.qcards:
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				for chip in xrange(12):
					dc[chip].ChargeInjectDAC(setting)
				dc.write()
				dc.read()
			histo_results=self.get_histo_results(self.crate, self.uhtr_slots)
			for uhtr_slot, uhtr_slot_results in histo_results.iteritems():
				for chip, chip_results in uhtr_slot_results.iteritems():
					key="({0}, {1}, {2})".format(uhtr_slot, chip_results["link"], chip_results["channel"])
					ci_results[key].append(chip_results["signalBinMax"])

		for qslot in self.qcards:
			for chip in xrange(12):
				ci_key=str(self.get_QIE_map(qslot, chip))
				chip_arr=ci_results[ci_key]
Пример #40
0
	def QIE_mapping(self):
		# Records the uHTR slot, link, and channel of each QIE in master_dict
		failures=[]
		for qslot in self.qcards:
			if self.V: print 'mapping qslot '+str(qslot)
			dc=hw.getDChains(qslot, self.bus)
			hw.SetQInjMode(0, qslot, self.bus)
			dc.read()
			for chip in [0,6]:
				for num in xrange(12):
					dc[num].PedestalDAC(-9)
					if num==chip:
						dc[num].PedestalDAC(31)
				dc.write()
				dc.read()
				info=self.get_mapping_histo()
				if info is not None:
					uhtr_slot=info[0]
					link=info[1]
					for i in xrange(6):
						self.add_QIE(qslot, chip+i, uhtr_slot, link, 5-i)
				else:
					print 'mapping qcard {0} failed'.format(qslot)
					failures.append(qslot)
			for chip in xrange(12):
				dc[chip].PedestalDAC(6)
				dc.write()
				dc.read()
		
#		for failure in failures:
#			self.qcards.remove(failure)

		if self.V:
			for qslot in self.qcards:
				for chip in xrange(12):
					info=self.get_QIE_map(qslot, chip)
					print 'Q_slot: {4}, Qie: {3}, uhtr_slot: {0}, link: {1}, channel: {2}'.format(info[0], info[1], info[2], chip, qslot)
Пример #41
0
	def QIE_mapping(self):
		# Records the uHTR slot, link, and channel of each QIE in master_dict
		for qslot in self.qcards:
			dc=hw.getDChains(qslot, self.bus)
			hw.SetQInjMode(0, qslot, self.bus)
			dc.read()
			for chip in [0,6]:
				for num in xrange(12):
					dc[num].PedestalDAC(-9)
					if num==chip:
						dc[num].PedestalDAC(31)
				dc.write()
				dc.read()
				info=self.get_mapping_histo()
				if info is not None:
					uhtr_slot=info[0]
					link=info[1]
					for i in xrange(6):
						self.add_QIE(qslot, chip+i, uhtr_slot, link, 5-i)
				else: print "mapping failed"
			for num in xrange(12):
				dc[num].PedestalDAC(-9)
				dc.write()
				dc.read()
Пример #42
0
	def shunt_test(self):
		peak_results = {}
		default_peaks = [] #holds the CI values for 3.1 fC/LSB setting for chips
		grand_ratio_pf = [0,0] #check for troubleshooting
		default_peaks_avg = 0
		adc = hw.ADCConverter()
		
		setting_list = [3.1, 4.65, 6.2, 9.3, 12.4, 15.5, 18.6, 21.7, 24.8, 27.9, 31, 34.1, 35.65] # fC/LSB gains in GSel table
		gain_settings = [0, 1, 2, 4, 8, 16, 18, 20, 24, 26, 28, 30, 31]
		
		#ratio between default 3.1fC/LSB and itself/other GSel gains
		nominalGainRatios = [1.0, 0.667, 0.5, 0.333, 0.25, 0.2, 0.167, 0.143, 0.125, 0.111, 0.1, 0.091, 0.087]

		histo_ratios=[]
		for x in xrange(len(gain_settings)):
			histo_ratios.append(x)
			histo_ratios[x] = []
		
		for i, setting in enumerate(gain_settings):
			if self.V: print 'testing shunt setting ratio '+str(nominalGainRatios[i])
			for qslot in self.qcards:
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				hw.SetQInjMode(1, qslot, self.bus)    #turn on CI mode (igloo function)
				for chip in xrange(12):
					dc[chip].PedestalDAC(6)
					dc[chip].ChargeInjectDAC(8640)    #set max CI value
					dc[chip].Gsel(setting)    #increase shunt/decrease gain
				dc.write()
				dc.read()

			histo_results=self.get_histo_results(self.crate, self.uhtr_slots, signalOn=True, out_dir="shunt_histos_{0}".format(setting))

			for uhtr_slot, uhtr_slot_results in histo_results.iteritems():
				for chip, chip_results in uhtr_slot_results.iteritems():
					key="{0}_{1}_{2}".format(uhtr_slot, chip_results["link"], chip_results["channel"])
					if setting == 0: peak_results[key] = []
					if 'signalBinMax_1' in chip_results:
						totalSignal = adc.linearize(chip_results['signalBinMax_1'])
						if 'signalBinMax_2' in chip_results:	# get 2nd peak if needed
							totalSignal += adc.linearize(chip_results['signalBinMax_2'])
						peak_results[key].append(totalSignal)
						if setting == 0:
							default_peaks.append(totalSignal)

		# reset Gsel to zero
		for qslot in self.qcards:
			dc=hw.getDChains(qslot, self.bus)
			dc.read()
			for chip in xrange(12):
				dc[chip].Gsel(0) #set Gsel back to default
			dc.write()
			dc.read()

		# calculate average default CI peak of default shunt
		default_peaks_avg = sum(default_peaks)/len(default_peaks)

	       	#analyze results and make graphs
		cwd = os.getcwd()
		if not os.path.exists("shunt_plots"):	
       			os.makedirs("shunt_plots")
	       	os.chdir(cwd  + "/shunt_plots")

		for qslot in self.qcards:
		
			cwd2=os.getcwd()
			if not os.path.exists(str(qslot)):
				os.makedirs(str(qslot))
			os.chdir(cwd2  + "/" + str(qslot))
		
			for chip in xrange(12):
				chip_map=self.get_QIE_map(qslot, chip)
				peak_key = "{0}_{1}_{2}".format(chip_map[0], chip_map[1], chip_map[2])
				chip_arr=peak_results[peak_key]
				ratio_arr = []    #used for making graphs
				
				for setting in xrange(len(peak_results[peak_key])):
					ratio = float(chip_arr[setting]) / default_peaks_avg     #ratio between shunt-adjusted peak & default peak
					ratio_arr.append(ratio)
					histo_ratios[setting].append(ratio)
					setting_result = False
					if (ratio < nominalGainRatios[setting]*1.15 and ratio > nominalGainRatios[setting]*0.85):     #within 15% of nominal
						setting_result = True
						grand_ratio_pf[0]+=1
					else:
						grand_ratio_pf[1]+=1

					self.update_QIE_results(qslot, chip, "shunt", setting_result)

					if self.V: print 'qslot: {0}, chip: {1}, setting: {2}, ratio: {3}, pass: {4}'.format(qslot, chip, setting, ratio, setting_result)
		
				slope = self.graph_results("shunt", nominalGainRatios, ratio_arr, "{0}_{1}".format(qslot, chip))
			os.chdir(cwd2)
		os.chdir(cwd)

		if self.V: print 'Total Pass/Fail for Shunt Test:  ({0}, {1})'.format(grand_ratio_pf[0], grand_ratio_pf[1])
		
		#make histogram of all results for each setting
		cwd = os.getcwd()
		os.chdir(cwd + "/histo_statistics")
		
		for i, setting in enumerate(setting_list):
			self.make_histo("shunt", histo_ratios[i], nominalGainRatios[i]*0.85, nominalGainRatios[i]*1.15, setting)	
		os.chdir(cwd)
Пример #43
0
def turnOnCI(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])
    m = CI_Mode_On(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
Пример #44
0
	def phase_test(self):
		#Valid (GOOD!!!) settings for phase
		phase_settings = range(0,11) + range(36,50) + range(64,75) + range(104,115)
		phase_results={}
		phase_results["settings"]=phase_settings
		for setting in phase_settings:
			if self.V: print 'testing phase setting '+str(setting)
			for qslot in self.qcards:
				hw.SetQInjMode(1, qslot, self.bus)
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				for chip in xrange(12):
					dc[chip].PhaseDelay(setting)
					dc[chip].ChargeInjectDAC(8640)
					dc[chip].TimingThresholdDAC(80)
				dc.write()
				dc.read()
			tdc_results=self.get_tdc_results(self.crate, self.uhtr_slots)
			for uhtr_slot, uhtr_slot_results in tdc_results.iteritems():
				for link, links in uhtr_slot_results.iteritems():
					for channel, chip_results in links.iteritems():
						sigTDC = 0
						key="{0}_{1}_{2}".format(uhtr_slot, link, channel)
						if key not in phase_results: phase_results[key]=[]
						for k in range(len(chip_results)):
							if chip_results[k] < 63:
								phase_results[key].append(chip_results[k])
								sigTDC = 1
								break
						if sigTDC == 0:
							phase_results[key].append(63)

		#Reset phases and internal charge injection to default
		for qslot in self.qcards:
			dc=hw.getDChains(qslot, self.bus)
			hw.SetQInjMode(0, qslot, self.bus)
			dc.read()
			for chip in xrange(12):
				dc[chip].PhaseDelay(0)
			dc.write()
			dc.read()


		#analyze results and make graphs
		cwd=os.getcwd()
		if not os.path.exists("phase_plots"):	
			os.makedirs("phase_plots")
		os.chdir(cwd  + "/phase_plots")
		
		for qslot in self.qcards:
			cwd2=os.getcwd()
			if not os.path.exists(str(qslot)):
				os.makedirs(str(qslot))
			os.chdir(cwd2  + "/" + str(qslot))

			for chip in xrange(12):

				chip_map=self.get_QIE_map(qslot, chip)
				phase_key = "{0}_{1}_{2}".format(chip_map[0], chip_map[1], chip_map[2])
				chip_arr = phase_results[phase_key]
				
				#slopeTest = False
				#results = False
				slope = self.graph_results("phase", phase_settings, chip_arr, "{0}_{1}".format(qslot, chip))

				#if slope <= 3 and slope >= 2: slopeTest=True
				# Fill master_dict with phase test results
				#if slopeTest == True: results=True
				#self.update_QIE_results(qslot, chip, "phase", results)

				if self.V: print 'qslot: {0}, chip: {1}, slope: {2}'.format(qslot, chip, slope)
			os.chdir(cwd2)
		os.chdir(cwd)
Пример #45
0
def displayCI(bus,slot):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])
    m = CI_Mode_Display(bus,i.igloo["cntrReg"]["register"], 1)
    m.run()
Пример #46
0
                        "Hardware_Requirement_Action.png"
                     ]
LAPTOP_PRICE_FILE   = "hardware_price.txt"
LAPTOP_PRICE_GRAPH  = "Laptop_Price.png"

#
# Wenn Sie Die einzelne Aufgaben starten möchten, setzen Sie bitte in config.ini für jeden Block
# true fürs Starten und false anders.
# Erster Block ist GAME_HARDWARE, zweiter ist GAME_IMPACT, dritter ist STATISTICS uns vierter Block ist SALES
#

# ---------------------- Minimum Requierment und Hardware price von each Gerne in each year
if "true" in conf.get("GAME_HARDWARE"):

    # Spiel Anforderungen auf Rank und Spiel Name und Jahr Mappen
    games_requirement = sc.textFile("steam_hardware.txt").map(lambda line: h.SteamReqiertment(line)).map(lambda game: ([game.Genre,game.Year],h.RequiermentList(game.Requierment))).persist()
    # Hardware auf Leistung und Price Mappen
    laptop_prices = sc.textFile("laptops.csv").map(lambda line: h.laptop(line)).map(lambda hardware: (hardware.PRICE,func.get_Rank([hardware.CPU,hardware.RAM,hardware.GPU])))
    laptop_prices = laptop_prices

    # Konkatinieren mit einem Dict oder eine Hashtabelle
    PRICES = {}
    for a, b in laptop_prices.collect():
        PRICES.setdefault(str(b), []).append(a)

    # Übertragung der von Rank und Price in der Liste der Spiele
    games_requirement = games_requirement.map(lambda game: (game[0],[func._AVG(PRICES.get(func.get_Rank([game[1].CPU, game[1].RAM,game[1].GPU]))),[h.CPU(game[1].CPU).name, h.RAM(game[1].RAM).name,h.GPU(game[1].GPU).name]])).persist()
    games_requirement = games_requirement.map(lambda x: (x[0][0], x[0][1], x[1][0]))

    # Ausgabe der Hardwareprice - Rank list in Textfile.
    func.print_Hardware(HARDWARE_PRICE_FILE,games_requirement.collect())
Пример #47
0
 def init_terminal_conf(self):
     if not FileUtil.exists(Constant.SERIAL_MAC_PATH):
         print("未找到sn配置文件")
         self.waite_write_sn_mac()
     else:
         try:
             sn = FileUtil.get_conf(Constant.SERIAL_MAC_PATH, "sn_mac",
                                    "SN")
             if sn is None:
                 print("有配置文件但是没有SN值")
                 self.waite_write_sn_mac()
             else:
                 Constant.SN = sn
             mac = FileUtil.get_conf(Constant.SERIAL_MAC_PATH, "sn_mac",
                                     "MAC")
             if mac is None:
                 print("有配置文件但是没有MAC值")
                 self.waite_write_sn_mac()
             else:
                 Constant.MAC = mac
         except Exception as e:
             print("配置文件异常" + str(e))
             self.waite_write_sn_mac()
     if FileUtil.exists(Constant.CONF_FILE_PATH):
         conf_json = FileUtil.read_json_data(Constant.CONF_FILE_PATH)
         # print(conf_json)
         mqttep = conf_json.get("mqttep")
         if "//" in mqttep and ":" in mqttep:
             Constant.IP = conf_json.get("ip")
             Constant.IPMASK = conf_json.get("ipmask")
             Constant.GATEWAY = conf_json.get("gateway")
             Constant.DNS1 = conf_json.get("dns1")
             Constant.DNS2 = conf_json.get("dns2")
             print(
                 str(Constant.IP) + "  " + str(Constant.IPMASK) + "  " +
                 str(Constant.GATEWAY) + " " + str(Constant.DNS1) + "  " +
                 str(Constant.DNS2))
             Constant.G4EN = conf_json.get("g4en")
             Constant.MQTT_HOST = mqttep.split("//")[1].split(":")[0]
             Constant.MQTT_PORT = int(mqttep.split("//")[1].split(":")[1])
             Constant.PWD = conf_json.get("mqttpass")
             Constant.DES_KEY = conf_json.get("despass")
             Constant.USELESS_SN = Constant.SN
             Constant.SN = conf_json.get("productid") + Constant.SN[-6:]
             # Constant.USELESS_SN = conf_json.get("sn")
             print(
                 str(Constant.MQTT_HOST) + " " + str(Constant.MQTT_PORT) +
                 " " + " " + str(Constant.SN))
             self.init_hardware()
             wating_queue_msg = threading.Thread(
                 target=self.wating_queue_msg_thread,
                 name='wating_queue_msg_thread')
             wating_queue_msg.start()
             Mqtt()
             self.start_service()
     else:
         Hardware.wait_conf_info()
         print("未发现配置文件,请先配置平台信息")
         cmd = "ifconfig lo up & ifconfig eth0 " + str(
             Constant.IP) + " netmask " + str(Constant.IPMASK)
         print(cmd)
         os.system(cmd)
         self.start_server_thread()
Пример #48
0
	def ped_test(self):
		ped_settings = list(i-31 for i in xrange(63))
		ped_results={}
		ped_results["settings"]=ped_settings
		histo_slopes = [] #stores slopes for overall histogram
		for setting in ped_settings:
			if self.V: print 'testing pedestal setting '+str(setting)
			for qslot in self.qcards:
				dc=hw.getDChains(qslot, self.bus)
				dc.read()
				for chip in xrange(12):
					dc[chip].PedestalDAC(setting)
				dc.write()
				dc.read()
			histo_results=self.get_histo_results(self.crate, self.uhtr_slots)
			for uhtr_slot, uhtr_slot_results in histo_results.iteritems():
	                        for chip, chip_results in uhtr_slot_results.iteritems():
					key="{0}_{1}_{2}".format(uhtr_slot, chip_results["link"], chip_results["channel"])
					if setting == -31: ped_results[key]=[]
					ped_results[key].append(chip_results["pedBinMax"])

		#reset pedastals to default
		for qslot in self.qcards:
			dc=hw.getDChains(qslot, self.bus)
			dc.read()
			for chip in xrange(12):
				dc[chip].PedestalDAC(6)
			dc.write()
			dc.read()

		#analyze results and make graphs
		cwd=os.getcwd()
		if not os.path.exists("ped_plots"):
			os.makedirs("ped_plots")
		os.chdir(cwd  + "/ped_plots")
		
		for qslot in self.qcards:

			cwd2=os.getcwd()
		       	if not os.path.exists(str(qslot)):
	       			os.makedirs(str(qslot))
       			os.chdir(cwd2  + "/" + str(qslot))

			for chip in xrange(12):

				chip_map=self.get_QIE_map(qslot, chip)
				ped_key = "{0}_{1}_{2}".format(chip_map[0], chip_map[1], chip_map[2])
				chip_arr = ped_results[ped_key]
				print "Chip Array is: "+str(chip_arr) #DEBUG
				
				#check if settings -31 to -3 are flat and -2 to 31 are linear
				flat_test = True
				slope_test = False
				test_pass = False
				for num in xrange(28):
					if chip_arr[num] != 1: flat_test=False
				slope = self.graph_results("ped", ped_settings, chip_arr, "{0}_{1}".format(qslot, chip))
				if slope <= 2.4 and slope >=2.15: slope_test = True
				if self.V: print 'qslot: {0}, chip: {1}, slope: {2}, pass flat test: {3}, pass slope test: {4}'.format(qslot, chip, slope, flat_test, slope_test)
				
				# update master_dict with test results
				if flat_test and slope_test: test_pass=True
				self.update_QIE_results(qslot, chip, "ped", test_pass)

				#update slopes for final histogram
				histo_slopes.append(slope)
				
	       		os.chdir(cwd2)
		os.chdir(cwd)

		#make histogram of all slope results
		os.chdir(cwd + "/histo_statistics")	
		self.make_histo("ped", histo_slopes, 0, 5)
		os.chdir(cwd)
Пример #49
0
 def init_hardware(self):
     print("初始化硬件")
     Hardware.init(self)
Пример #50
0
import Hardware

import time
import sys

SECONDS_TO_WATER = 30
RELAY = Hardware.Relay(12, False)


def water_plant(relay=RELAY, seconds=SECONDS_TO_WATER):
    relay.on()
    print("Plant is being watered!")
    time.sleep(seconds)
    relay.off()


if __name__ == "__main__":
    water_plant()
Пример #51
0
def cntrRegShowAll(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])
    m = cntrRegDisplay(bus,i.igloo["cntrReg"]["register"], 1)
    print m.run()
Пример #52
0
from client import webBus
import Hardware as h
import iglooClass as i
# from TestSoftware.uHTR import uHTR

qcard_slots = [2, 5]

b = webBus("pi5", 0)
# uhtr = uHTR(6,qcard_slots,b)

#-------------------------------------
for slot in qcard_slots:
    print '__________________________________________________'
    print '____________________Slot %d_______________________' % slot
    print '__________________________________________________'
    myDC = h.getDChains(slot, b)

    # i.turnOnCI()
    d
    myDC.read()
    print myDC[0]

    print '__________________________________________________'
    print '__________________________________________________'
    print '__________________________________________________'

    # for num in xrange(12):
    #     for chip in xrange(12):
    #         myDC[chip].ChargeInjectDAC(8640)
    #         myDC[chip].PedestalDAC(-9)
    #         # myDC[chip].CapID0pedestal(0)
Пример #53
0
def processInputSpy(bus):
    h.openChannel(slot,bus)
    bus.write(h.getCardAddress(slot),[0x11,0x03,0,0,0])
    m = inputSpy_512Reads(bus,i.igloo["inputSpy"]["register"], 1)
    print m.run()
Пример #54
0
def writeBridgeIglooReg(bus):
    h.openChannel(slot,bus)
    bus.write(0x00,[0x06])
    bus.write(h.getCardAddress(slot),[0x22,0xe7,0x07,0,0])
    write2 = bus.sendBatch()[0]
    print 'BRIDGE IGLOO REG Write: '+str(write2)
Пример #55
0
#!/usr/bin/env python

# PerfTrack Version 1.0     September 1, 2005
# See PTLICENSE for distribution information. 

import Hardware,os,sys
from PassFail import PassFail 
from PTexception import PTexception

dataDir = "badMachineFiles"
files = os.listdir(dataDir)
files.sort()
pf = PassFail()
for f in files:
   print "processing:" + f
   try: 
      if Hardware.main(["", "--in_file", dataDir + "/" + f, "--out_file", "/dev/null"]) == 0:
         pf.failed("Bad Machine Data for %s did not fail" % f)
      else:
         pf.passed("Bad Machine Data Caught")
   except PTexception, a:
      pf.passed("Intentional FAIL: %s" % a.value)

pf.test_info()

sys.exit(pf.failed_count > 0)