Esempio n. 1
0
 def OnRspQrySettlementInfo(self, pSettlementInfo, pRspInfo, nRequestID,
                            bIsLast):
     try:
         print myutils.decode(pSettlementInfo.Content)
     except:
         if pSettlementInfo == None:
             pass
         else:
             print pSettlementInfo.Content
Esempio n. 2
0
    def OnRtnOrder(self, pOrder):
        # 报单提交(可提交,但是有错)后返回
        self.order_status_dict[(pOrder.InstrumentID,
                                pOrder.LimitPrice)] = pOrder.OrderStatus

        self.logger.info('-------------------------------------')
        self.logger.info('合约代码: %s', pOrder.InstrumentID)
        self.logger.info('价格: %s', pOrder.LimitPrice)
        self.logger.info('买卖方向: %s', pOrder.Direction)
        self.logger.info('数量: %s', pOrder.VolumeTotalOriginal)
        self.logger.info('报单提交状态: %s', pOrder.OrderSubmitStatus)
        """
        OSS_InsertSubmitted = '0' #已经提交
        OSS_CancelSubmitted = '1' #撤单已经提交
        OSS_ModifySubmitted = '2' #修改已经提交
        OSS_Accepted = '3' #已经接受
        OSS_InsertRejected = '4' #报单已经被拒绝
        OSS_CancelRejected = '5' #撤单已经被拒绝
        """
        self.logger.info('报单状态: %s', pOrder.OrderStatus)
        """
        OST_AllTraded = '0' #全部成交
        OST_PartTradedQueueing = '1' #部分成交还在队列中
        OST_PartTradedNotQueueing = '2' #部分成交不在队列中
        OST_NoTradeQueueing = '3' #未成交还在队列中
        OST_NoTradeNotQueueing = '4' #未成交不在队列中
        OST_Canceled = '5' #撤单
        """
        self.logger.info('报单日期: %s', pOrder.InsertDate)
        self.logger.info('委托时间: %s', pOrder.InsertTime)
        self.logger.info('状态信息: %s', myutils.decode(pOrder.StatusMsg))
        self.logger.info('报单价格条件: %s', pOrder.OrderPriceType)
Esempio n. 3
0
    def getTestDirs(self):
        while True:
            packet = self.sclient.getFirstPacket(self.subscriptions['watchDog'])
            if packet.isEmpty():
                break
            if "pong" in packet.data.lower():
                continue
            data = packet.data
            Time, coms, typ, msg = decode(data)[:4]
            tb = 'TB' + coms[0][2:]
            # tb = int(tb)
            self.currentTestDirs[tb] = msg
            currentTempLog = self.currentTestTempLogger.get(tb, None)
            if currentTempLog:
                name = 'TempLog_%s' % self.status
                fileName = '%s.log' % name
                current_dir = self.currentTestDirs[tb]
                currentTempLog.close_logfiles()
                currentTempLog.set_logfile(current_dir, fileName)
                currentTempLog.set_logfile(self.currentTestDirs[tb], fileName)

            currentHumLog = self.currentTestHumLogger.get(tb, None)
            if currentHumLog:
                #print 'CREATE HUMLOG'
                name = 'HumLog_%s' % self.status
                fileName = '%s.log' % name
                current_dir = self.currentTestDirs[tb]
                currentHumLog.close_logfiles()
                currentHumLog.set_logfile(current_dir, fileName)
                currentHumLog.set_logfile(self.currentTestDirs[tb], fileName)
Esempio n. 4
0
def mainLoop():

    sleep(0.5)
    counter = 0 
    lastMeasurementSend = time.time()
    isDry = False
    while client.anzahl_threads > 0 and End == False and client.isClosed == False: 
        isDry = check_if_dry(isDry)
        

        packet = client.getFirstPacket(aboName)

        now = time.time()
        if now - lastMeasurementSend > 5:
            sendMeasurements()
            lastMeasurementSend = now
        
        if packet.isEmpty():
            sleep(.5)
            continue
        counter +=1

        #Logger << 'got Packet: %s'%packet.Print()
        data = packet.data
        timeStamp,coms,typ,msg,command = decode(data)
        # 'T:',timeStamp, 'Comand:',command
        #Logger << '%s: %s, %s, %s'%(timeStamp,len(coms),typ,msg)
        #dataOut = '%s\n'%packet.Print()
        if len(coms)>0:
            analysePacket(coms,typ,msg)
        pass   
    client.send(aboName,':prog:stat! exit\n')    
    Logger << 'exiting...'
    jumo.stop_controlling()
    client.closeConnection()
Esempio n. 5
0
 def checkFinalHeating(self):
     self.sclient.clearPackets(self.subscription)
     self.sclient.send(self.subscription, ":PROG:STAT?\n")
     time.sleep(1.)
     bGotAnswer = False
     counter = 0
     while not bGotAnswer:
         if counter % 10 == 0 and counter != 0:
             self.sclient.send(self.subscription, ":PROG:STAT?\n")
         packet = self.sclient.getFirstPacket(self.subscription)
         if not packet.isEmpty() and not "pong" in packet.data.lower():
             data = packet.data
             Time, coms, typ, msg = decode(data)[:4]
             if len(coms) > 1:
                 if "prog" in coms[0].lower():
                     if "stat" in coms[1].lower() and typ == 'a':
                         bGotAnswer = True
                         if 'waiting' in msg.lower():
                             self.log << "%s: CoolingBox is heated up." % self.agente_name
                             self.pending = False
                         elif not 'heating' in msg.lower():
                             self.final_test_cleanup()
         else:
             if packet.isEmpty():
                 counter += 1
             time.sleep(1.0)
     return False
Esempio n. 6
0
def mainLoop():

    sleep(0.5)
    counter = 0
    lastMeasurementSend = time.time()
    isDry = False
    while client.anzahl_threads > 0 and End == False and client.isClosed == False:
        isDry = check_if_dry(isDry)

        packet = client.getFirstPacket(aboName)

        now = time.time()
        if now - lastMeasurementSend > 5:
            sendMeasurements()
            lastMeasurementSend = now

        if packet.isEmpty():
            sleep(.5)
            continue
        counter += 1

        #Logger << 'got Packet: %s'%packet.Print()
        data = packet.data
        timeStamp, coms, typ, msg, command = decode(data)
        # 'T:',timeStamp, 'Comand:',command
        #Logger << '%s: %s, %s, %s'%(timeStamp,len(coms),typ,msg)
        #dataOut = '%s\n'%packet.Print()
        if len(coms) > 0:
            analysePacket(coms, typ, msg)
        pass
    client.send(aboName, ':prog:stat! exit\n')
    Logger << 'exiting...'
    jumo.stop_controlling()
    client.closeConnection()
Esempio n. 7
0
    def check_cycleRunning(self):
        self.sclient.clearPackets(self.subscription)
        self.sclient.send(self.subscription,":PROG:STAT?\n")
        time.sleep(1.)
        bGotAnswer = False
        counter = 0
        while not bGotAnswer:
            if counter %10 == 9:
                self.sclient.send(self.subscription,":PROG:STAT?\n")

            packet = self.sclient.getFirstPacket(self.subscription)
            if not packet.isEmpty() and not "pong" in packet.data.lower():
                data = packet.data
                Time,coms,typ,msg = decode(data)[:4]
                if len(coms)>1:
                    if "prog" in coms[0].lower():
                        if  coms[1].lower().startswith("cycle") and typ == 'a' and 'finished' in msg.lower():
                            self.pending = False
                            self.log << "%s: Cycle has been finished" % self.agente_name
                            bGotAnswer = True
                        elif "stat" in coms[1].lower() and typ == 'a':
                            bGotAnswer = True
                            if "cycle_restart" in msg.lower():
                                message = msg.split(' ')
                                if len(message)==2:
                                    if is_number(message[1]):
                                            self.log <<"%s: %s more Cycles to finish" % (self.agente_name,int(message[1])+1)
                                else:
                                    self.log <<"%s: couldn't extract cycles out of msg '%s'" % (self.agente_name, msg)
            else:
                if packet.isEmpty():
                    counter+=1
                time.sleep(1.)
        return not self.pending
Esempio n. 8
0
 def checkStabalized(self):
     self.sclient.clearPackets(self.subscription)
     self.sclient.clearPackets(self.subscription)
     self.sclient.send(self.subscription,":PROG:STAT?\n")
     time.sleep(1.0)
     bGotAnswer = False
     while not bGotAnswer:
         packet = self.sclient.getFirstPacket(self.subscription)
         if not packet.isEmpty() and not "pong" in packet.data.lower():
             data = packet.data
             Time,coms,typ,msg = decode(data)[:4]
             timeNow = time.time()
             Time = int(Time)
             if timeNow - Time > 5:
                 self.log< "%s: packet to old: received at: %s\tnow: %s" %(self.agente_name, Time, timeNow)
                 continue
             if len(coms)>1:
                 if "prog" in coms[0].lower():
                     if "stat" in coms[1].lower() and typ == 'a':
                         bGotAnswer = True
                         if msg.lower().strip().startswith('stable'):
                             self.log << "%s: Temperature stable at %s" % (self.agente_name, Time)
                             self.pending = False
                         elif 'waiting' in msg.lower():
                             self.stabalizeTemperature(self.Temperature)
                         else:
                             try:
                                 if counter%10 ==0:
                                     self.log << "CoolingBox is in status %s"%msg.lower()
                                 counter+=1
                             except:
                                 pass
         else:
             time.sleep(1.0)
Esempio n. 9
0
 def checkFinalHeating(self):
     self.sclient.clearPackets(self.subscription)
     self.sclient.send(self.subscription,":PROG:STAT?\n")
     time.sleep(1.)
     bGotAnswer = False
     counter  = 0 
     while not bGotAnswer:
         if counter % 10 == 0 and counter != 0:
             self.sclient.send(self.subscription,":PROG:STAT?\n")
         packet = self.sclient.getFirstPacket(self.subscription)
         if not packet.isEmpty() and not "pong" in packet.data.lower():
             data = packet.data
             Time,coms,typ,msg = decode(data)[:4]
             if len(coms)>1:
                 if "prog" in coms[0].lower():
                     if "stat" in coms[1].lower() and typ == 'a':
                         bGotAnswer = True
                         if 'waiting' in msg.lower():
                             self.log << "%s: CoolingBox is heated up." % self.agente_name
                             self.pending = False
                         elif not 'heating' in msg.lower():
                             self.final_test_cleanup()
         else:
             if packet.isEmpty():
                 counter += 1
             time.sleep(1.0)
     return False
Esempio n. 10
0
 def OnRspSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID,
                        bIsLast):
     if pRspInfo.ErrorID == 0:
         self.logger.info("行情订阅成功!合约号:%s", pSpecificInstrument.InstrumentID)
     else:
         self.logger.info("行情订阅失败...")
         self.logger.info("错误代码: %s, 错误信息 %s:", pRspInfo.ErrorID,
                          myutils.decode(pRspInfo.ErrorMsg))
Esempio n. 11
0
 def checkIVCurveFinished(self,data):
     Time,coms,typ,msg = decode(data)[:4]
     if len(coms) > 1:
         if 'PROG' in coms[0].upper() and 'IV' in coms[1].upper() and typ == 'a' and ('FINISHED' in msg.upper()):
             self.log << '\t--> IV-Curve FINISHED'
             self.ivDone = True
         else:
             pass
     return self.ivDone
Esempio n. 12
0
 def checkLeakageCurrentFinished(self,data):
     Time,coms,typ,msg = decode(data)[:4]
     if len(coms) > 1:
         if 'PROG' in coms[0].upper() and 'LEAKAGECURRENT' in coms[1].upper() and typ == 'a' and ('FINISHED' in msg.upper()):
             self.log << '\t--> leakageCurrent measurement FINISHED'
             self.leakageCurrentTestDone = True
         else:
             pass
     return self.leakageCurrentTestDone
Esempio n. 13
0
 def checkIVCurveFinished(self, data):
     Time, coms, typ, msg = decode(data)[:4]
     if len(coms) > 1:
         if 'PROG' in coms[0].upper() and 'IV' in coms[1].upper(
         ) and typ == 'a' and ('FINISHED' in msg.upper()):
             self.log << '\t--> IV-Curve FINISHED'
             self.ivDone = True
         else:
             pass
     return self.ivDone
Esempio n. 14
0
 def checkLeakageCurrentFinished(self, data):
     Time, coms, typ, msg = decode(data)[:4]
     if len(coms) > 1:
         if 'PROG' in coms[0].upper() and 'LEAKAGECURRENT' in coms[1].upper(
         ) and typ == 'a' and ('FINISHED' in msg.upper()):
             self.log << '\t--> leakageCurrent measurement FINISHED'
             self.leakageCurrentTestDone = True
         else:
             pass
     return self.leakageCurrentTestDone
Esempio n. 15
0
    def read_humidity(self):
        while True:
            packet = self.sclient.getFirstPacket(self.subscriptions['hum'])
            if packet.isEmpty():
                break
            if "pong" in packet.data.lower():
                continue
            data = packet.data
            Time, coms, typ, msg = decode(data)[:4]

            if len(msg) >= 1:
                msg = "%s\t %s" % (Time, msg[0])
                self.humidity_log << msg
                for i in self.currentTestHumLogger:
                    if self.currentTestHumLogger[i]:
                        self.currentTestHumLogger[i] << msg
        return True
Esempio n. 16
0
 def check_testboard(self, data):
     if "pong" in data.lower():
         return False
     Time, coms, typ, msg = decode(data)[:4]
     if not typ == 'a':
         return False
     if not len(coms) == 2:
         return False
     if not coms[0].lower().startswith('stat'):
         return False
     if not coms[1].lower().startswith('tb'):
         return False
     TB_str = coms[1][2:]
     tb_no = int(TB_str)
     msg = msg.split(':')
     if len(msg) == 2:
         testName = msg[0].lower()
         testTemp = 17
         test_no = -1
         status = msg[1].lower()
         if testName == 'test':
             self.log << "%s: got standard stats for TB %d: %s" % (
                 self.agente_name, tb_no, msg)
             return True
         else:
             testName = testName.split("_")
             if len(testName) == 3:
                 test_no = testName[0]
                 testTemp = testName[2]
                 testName = testName[1]
             elif len(testName) > 3:
                 test_no = testName[0]
                 testTemp = testName[-1]
                 testName = '_'.join(testName[1:-1])
             else:
                 self.log.warning("%s: Couln't convert testName: %s, '%s'" %
                                  (self.agente_name, testName, data))
         if test_no == -1:
             self.log.warning(
                 "Couln't read valid test_no for TB_No %d: '%s'" %
                 (tb_no, msg))
             return
         self.update_test_overview(tb_no, test_no, status, testName)
     pass
Esempio n. 17
0
def analysePacket(packet):
    time, coms, typ, msg, cmd = decode(packet.data)
    coms = [x.lower() for x in coms]
    try:
        TBno = int(coms[1][2:])
    except:
        TBno = -1
        pass
    if (len(coms) >= 2):
        if coms[0].startswith('prog') and coms[1].startswith('tb'):
            analyseProg_TB(coms, msg, typ, TBno)
            return
        elif coms[0].startswith('prog') and coms[1].startswith('exit'):
            exitProg()
            return
        elif coms[0].startswith('stat') and coms[1].startswith(
                'tb') and typ == 'q':
            sendStatsTB(TBno)
            return
    Logger << 'unknown command: %s, %s' % (coms, msg)
Esempio n. 18
0
    def check_cycleRunning(self):
        self.sclient.clearPackets(self.subscription)
        self.sclient.send(self.subscription, ":PROG:STAT?\n")
        time.sleep(1.)
        bGotAnswer = False
        counter = 0
        while not bGotAnswer:
            if counter % 10 == 9:
                self.sclient.send(self.subscription, ":PROG:STAT?\n")

            packet = self.sclient.getFirstPacket(self.subscription)
            if not packet.isEmpty() and not "pong" in packet.data.lower():
                data = packet.data
                Time, coms, typ, msg = decode(data)[:4]
                if len(coms) > 1:
                    if "prog" in coms[0].lower():
                        if coms[1].lower().startswith(
                                "cycle"
                        ) and typ == 'a' and 'finished' in msg.lower():
                            self.pending = False
                            self.log << "%s: Cycle has been finished" % self.agente_name
                            bGotAnswer = True
                        elif "stat" in coms[1].lower() and typ == 'a':
                            bGotAnswer = True
                            if "cycle_restart" in msg.lower():
                                message = msg.split(' ')
                                if len(message) == 2:
                                    if is_number(message[1]):
                                        self.log << "%s: %s more Cycles to finish" % (
                                            self.agente_name,
                                            int(message[1]) + 1)
                                else:
                                    self.log << "%s: couldn't extract cycles out of msg '%s'" % (
                                        self.agente_name, msg)
            else:
                if packet.isEmpty():
                    counter += 1
                time.sleep(1.)
        return not self.pending
Esempio n. 19
0
def analysePacket(packet):
    time,coms,typ,msg,cmd = decode(packet.data)
    coms = [x.lower() for x in coms]
    try:
        TBno=int(coms[1][2:])
    except:
        TBno = -1
        pass
    if len(coms) >= 2:
        if coms[0].startswith('prog') and coms[1].startswith('tb'):
            analyseProg_TB(coms,msg,typ,TBno)
            return
        elif coms[0].startswith('exit'): 
            exitProg()
            return
        elif coms[0].startswith('stat') and coms[1].startswith('tb') and typ == 'q': 
            sendStatsTB(TBno) 
            return
    elif len(coms) > 0:
        if coms[0].startswith('exit'):
            exitProg()
            return
    Logger << 'unknown command: %s, %s'%(coms, msg) 
Esempio n. 20
0
 def checkStabalized(self):
     self.sclient.clearPackets(self.subscription)
     self.sclient.clearPackets(self.subscription)
     self.sclient.send(self.subscription, ":PROG:STAT?\n")
     time.sleep(1.0)
     bGotAnswer = False
     while not bGotAnswer:
         packet = self.sclient.getFirstPacket(self.subscription)
         if not packet.isEmpty() and not "pong" in packet.data.lower():
             data = packet.data
             Time, coms, typ, msg = decode(data)[:4]
             timeNow = time.time()
             Time = int(Time)
             if timeNow - Time > 5:
                 self.log < "%s: packet to old: received at: %s\tnow: %s" % (
                     self.agente_name, Time, timeNow)
                 continue
             if len(coms) > 1:
                 if "prog" in coms[0].lower():
                     if "stat" in coms[1].lower() and typ == 'a':
                         bGotAnswer = True
                         if msg.lower().strip().startswith('stable'):
                             self.log << "%s: Temperature stable at %s" % (
                                 self.agente_name, Time)
                             self.pending = False
                         elif 'waiting' in msg.lower():
                             self.stabalizeTemperature(self.Temperature)
                         else:
                             try:
                                 if counter % 10 == 0:
                                     self.log << "CoolingBox is in status %s" % msg.lower(
                                     )
                                 counter += 1
                             except:
                                 pass
         else:
             time.sleep(1.0)
Esempio n. 21
0
    def check_finished(self):
        if not self.active or not self.pending:
            return True
        sleep(1)
        for Testboard in self.Testboards:
            if Testboard.busy:
                self.sclient.send(self.subscription,":STAT:TB%d?\n"%Testboard.slot)
                sleep(1)
        sleep(1)
        while True:
            packet = self.sclient.getFirstPacket(self.subscription) 
            if packet.isEmpty() or not self.pending:
                break
            if "pong" in packet.data.lower():
            	continue
            data = packet.data
            Time,coms,typ,msg = decode(data)[:4]
            if type(msg)== str:
                msg = msg.lower()
            if len(coms) >= 2:
                if 'busy' in msg:
                    continue
                msg = msg.split(':')
                if coms[0].lower().find('stat')==0 and coms[1].lower().find('tb')==0 and typ == 'a':
                    com = coms[1][2:] 
                    try:
                        TBslot = int(com)
                    except:
                        self.log << "%s: Couldn't convert command to TBslot %s"%(self.agente_name,com)
                        continue
                    if len(msg)>1:
                        #Finished
                        if msg[1].startswith('finished'):
                            try:
                                index=[Testboard.slot==TBslot for Testboard in self.Testboards].index(True)
                                if self.Testboards[index].busy!=False:
                                    self.Testboards[index].busy=False
                                    self.Testboards[index].failedPowercycles = 0
                                    TBsbusy = [TB.busy for TB in self.Testboards]
                                    TBsindex= [TB.slot for TB in self.Testboards]
                            except:
                                self.log.warning("%s: Couldn't find TB with slot %s, %s"%(self.agente_name,TBslot,[TB.slot for TB in self.Testboards]))
                                #raise
                        #FAILED
                        elif msg[1].startswith('failed'):
                            try:
                                index=[Testboard.slot==TBslot for Testboard in self.Testboards].index(True)
                            except:
                                self.log.warning("%s: Couldn't find TB with slot %s, %s"%(self.agente_name,TBslot,[TB.slot for TB in self.Testboards]))
                                index =-1
                                #raise
                            if self.currenttest == 'powercycle':
                                if index !=-1:
                                    sleep(3)
                                    TBsbusy = [TB.busy for TB in self.Testboards]
                                    TBsindex= [TB.slot for TB in self.Testboards]
                                    self.log<<"%s:  self.Testboards[%s] could not be opened: %s: %s-%s" % (self.agente_name,index, self.pending, TBsindex,TBsbusy)
                                    self.Testboards[index].failedPowercycles += 1
                                    
                                    if self.Testboards[index].failedPowercycles < 3:
                                        self.log<<"%s:  self.Testboards[%s] restart Powecycle: %s: %s-%s" % (self.agente_name,index, self.pending, TBsindex,TBsbusy)
                                        self._execute_testboard(self.Testboards[index])
                                    else:
                                        self.log.warning('Could not open Testboard at %s.'%Testboard.slot)
                                else:
                                    self.log.warning('index is out of range: %s'%index)

                            elif self.Testboards[index].busy==True:
                                self.log<<""
                                self.Testboards[index].busy=False
                                TBsbusy = [TB.busy for TB in self.Testboards]
                                TBsindex= [TB.slot for TB in self.Testboards]
                                self.log<<"%s:  self.Testboards[%s] failed- the following boards are busy: %s: %s-%s" % (self.agente_name,index, self.pending, TBsindex,TBsbusy)
                        elif msg[1].startswith('unknown'):
                            TBsbusy = [TB.busy for TB in self.Testboards]
                            TBsindex= [TB.slot for TB in self.Testboards]
                            try:
                                index=[Testboard.slot==TBslot for Testboard in self.Testboards].index(True)
                            except:
                                self.log<<"%s: Couldn't find TB with slot %s, %s"%(self.agente_name,TBslot,[TB.slot for TB in self.Testboards])
                                index =-1
                            if self.Testboards[index].busy==True:
                                self.Testboards[index].busy=False
                                self.log<<""
                                self.log <<"%s: Status of TB in slot %s is unknown"%(self.agente_name,TBslot)

            self.pending = any([Testboard.busy for Testboard in self.Testboards])
        self.pending = any([Testboard.busy for Testboard in self.Testboards])
        #self.log<<[Testboard.busy for Testboard in self.Testboards]
        return not self.pending
Esempio n. 22
0
 def OnRspOrderInsert(self, pInputOrder, pRspInfo, nRequestID, bIsLast):
     # 报单报错(无法提交)后返回
     self.logger.info("报单错误!无法提交")
     self.logger.info("报错内容: %s", myutils.decode(pRspInfo.ErrorMsg))
Esempio n. 23
0
############################################################################
#RECEIVE COMMANDS:

sleep(0.5)
counter = 0 
while client.anzahl_threads > 0 and End == False and client.isClosed == False: 
    
    packet = client.getFirstPacket(aboName)
    
    counter +=1
    if packet.isEmpty():
        sleep(.5)
    else:
        #Logger << 'got Packet: %s'%packet.Print()
        data = packet.data
        timeStamp,coms,typ,msg,command = decode(data)
        # 'T:',timeStamp, 'Comand:',command
        #Logger << '%s: %s, %s, %s'%(timeStamp,len(coms),typ,msg)
        dataOut = '%s\n'%packet.Print()
        if command.find(':DOSWEEP')!=-1:
            sweep()
        elif coms[0]=='K':
            cmd = data[2:]
            Logger << 'send command to keithley: '
            Logger << cmd
            keithley.write(cmd)
        elif len(coms)>0:
            analysePacket(coms,typ,msg)
        else:
            keithley.write(command)
            client.send(aboName,dataOut)
Esempio n. 24
0
 def OnRspError(self, info, RequestId, IsLast):
     self.logger.error(myutils.decode(info.ErrorMsg))
     self.isErrorRspInfo(info)
Esempio n. 25
0
## @addtogroup lowVoltageClient
## @details
## The core of the lowVoltageClient is the message query loop where it
## waits for new commands. When no commands are received the state
## of the devices is checked. Commands that arrive are executed
## sequentially. Whenever a problem occurs, an ERROR message is sent
## back. Otherwise, no messages are sent, except when the FINISHED
## query arrives, at which FINISHED is sent back.

log << "Waiting for commands ..."
while client.anzahl_threads > 0 and client.isClosed == False:
	packet = client.getFirstPacket(abo)
	if not packet.isEmpty():
		log << "Received packet from " + abo + ": " + packet.data
		timeStamp, commands, type, message, command = myutils.decode(packet.data)
		if len(commands) == 2 and commands[0].upper() == "SET":
			if commands[1].upper() == "OUTPUT":
				state = message
				log << "Setting output to " + state.upper() + "."
				device.set_output(state.upper())
				state_output = state.upper()
		if len(commands) == 2 and commands[0].upper() == "EXEC":
			if commands[1].upper() == "POWERCYCLE":
				log << "Power cycling ..."
				device.power_cycle()
				# Sleep afterwards, to let the electronics start up
				time.sleep(2)
				state_output = device.get_output()
			if commands[1].upper() == "TOGGLE":
				log << "Toggling output ..."
Esempio n. 26
0
## @addtogroup xrayClient
# @details
# The core of the xrayClient is the message query loop where it
# waits for new commands. When no commands are received the state
# of the devices is checked. Commands that arrive are executed
# sequentially. Whenever a problem occurs, an ERROR message is sent
# back. Otherwise, no messages are sent, except when the FINISHED
# query arrives, at which FINISHED is sent back.

log << "Waiting for commands ..."
while client.anzahl_threads > 0 and client.isClosed == False:
    packet = client.getFirstPacket(abo)
    if not packet.isEmpty():
        log << "Received packet from " + abo + ": " + packet.data
        timeStamp, commands, type, message, command = myutils.decode(
            packet.data)
        if len(commands) == 2 and commands[0].upper() == "SET":
            if commands[1].upper() == "TARGET":
                target = message
                if target in targets:
                    log << "Moving to target " + target + " ..."
                    motor_stage.move_absolute(targets[target])
                    log << "Current target is now " + target + "."
                    shutter = 1  # FIXME: Use config value
                elif target.lower() == "none" or target == "":
                    shutter = 3  # FIXME: Use config value
                else:
                    error = "Invalid target selected."
                    log.warning(error)
            elif commands[1].upper() == "VOLTAGE":
                kV = int(message)
Esempio n. 27
0
counter = 0
while client.anzahl_threads > 0 and (not End) and not client.isClosed:

    packet = client.getFirstPacket(aboName)
    if counter % 10 == 0:
        if not doingSweep:
            readCurrentIV()

    if packet.isEmpty():
        sleep(.5)
        counter += 1
        continue

    #Logger << 'got Packet: %s'%packet.Print()
    data = packet.data
    timeStamp, coms, typ, msg, command = decode(data)
    # 'T:',timeStamp, 'Comand:',command
    #Logger << '%s: %s, %s, %s'%(timeStamp,len(coms),typ,msg)
    dataOut = '%s\n' % packet.Print()
    if command.find(':DOSWEEP') != -1:
        sweep()
    if len(coms) > 0:
        analysePacket(coms, typ, msg)
    else:
        keithley.write(command)
        client.send(aboName, dataOut)
    #string retVal = keithley.setOutput(ON)

    pass

client.send(aboName, ':prog:stat! exit\n')