示例#1
0
 def ISNewSwitch(self, dev, name, states, names, n):
     if (dev != self.name):
         return False
     self.logger.info("ISNewSwitch " + dev + " property " + name)
     # Always fetch data from C++ world
     svp = self.getSwitch(name)
     if not svp:
         return False
     cstates = PyIndiDriver.new_ISStateArray(n)
     for i in range(len(states)):
         self.logger.info('  ' + names[i] + ' = ' + str(states[i]))
         PyIndiDriver.ISStateArray_setitem(cstates, i, states[i])
     if name == 'ON_TIME_FACTOR':
         svp.s = PyIndi.IPS_OK
         PyIndiDriver.IUUpdateSwitch(svp, cstates, names, n)
         # Update client display
         PyIndiDriver.IDSetSwitch(svp, None)
         #saveConfig();
         if svp[0].s == PyIndi.ISS_ON:
             PyIndiDriver.IDLog("CCDSim:: Time Factor 1\n")
             self.timefactor = 1.0
         if svp[1].s == PyIndi.ISS_ON:
             PyIndiDriver.IDLog("CCDSim:: Time Factor 0.1\n")
             self.timefactor = 0.1
         if svp[2].s == PyIndi.ISS_ON:
             PyIndiDriver.IDLog("CCDSim:: Time Factor 0.01\n")
             self.timefactor = 0.01
         return True
     if super(CCDSimulator, self).ISNewSwitch(dev, name, cstates, names, n):
         return True
     return False
示例#2
0
 def ISNewBLOB (self, dev, name, sizes, blobsizes, blobs, formats, names, n):
     self.logger.info("ISNewBLOB " + dev + " property " + name)
     if (dev != self.name):
         return False
     bvp=self.getBLOB(name)
     if not bvp:
         return False
     if not self.isConnected():
         bvp.s=PyIndi.IPS_ALERT
         PyIndiDriver.IDSetNumber(bvp, "Cannot change property while device is disconnected.")
         return False
     if (bvp.name == "BLOB Test"):
         csizes=PyIndiDriver.new_intArray(n)
         for i in range(len(sizes)):
             PyIndiDriver.intArray_setitem(csizes, i, sizes[i])
             #PyIndiDriver.IDLog('BLOB '+str(i)+' Content:\n##################################\n'+blobs[i]+'\n##################################\n')
         cblobsizes=PyIndiDriver.new_intArray(n)
         for i in range(len(blobsizes)):
             PyIndiDriver.intArray_setitem(cblobsizes, i, blobsizes[i])
         
         PyIndiDriver.IUUpdateBLOB(bvp, csizes, cblobsizes, blobs, formats, names, n);
         bp = PyIndiDriver.IUFindBLOB(bvp, names[0])
         if (not bp):
             return False
         PyIndiDriver.IDLog('Received BLOB with name '+bp.name+', format '+getattr(bp,'format')+', and size '+str(bp.size)+', and bloblen '+str(bp.bloblen)+'\n')
         #PyIndiDriver.IDLog('BLOB Content:\n##################################\n'+str(bp.getblobdata())+'\n##################################\n')
         bp.size=0
         bvp.s = PyIndi.IPS_OK
         PyIndiDriver.IDSetBLOB(bvp, None)
     return True
示例#3
0
def logProperties(d):
    # print a list of all device properties
    lp = d.getProperties()
    for p in lp:
        PyIndiDriver.IDLog('Property ' + p.getName() + ' - ' + p.getLabel() +
                           '\n')
        if p.getType() == PyIndi.INDI_TEXT:
            tpy = p.getText()
            for t in tpy:
                PyIndiDriver.IDLog("       " + t.name + "(" + t.label + ")= " +
                                   t.text + '\n')
        elif p.getType() == PyIndi.INDI_NUMBER:
            tpy = p.getNumber()
            for t in tpy:
                PyIndiDriver.IDLog("       " + t.name + "(" + t.label + ")= " +
                                   str(t.value) + '\n')
        elif p.getType() == PyIndi.INDI_SWITCH:
            tpy = p.getSwitch()
            for t in tpy:
                PyIndiDriver.IDLog("       " + t.name + "(" + t.label + ")= " +
                                   strISState(t.s) + '\n')
        elif p.getType() == PyIndi.INDI_LIGHT:
            tpy = p.getLight()
            for t in tpy:
                PyIndiDriver.IDLog("       " + t.name + "(" + t.label + ")= " +
                                   strIPState(t.s) + '\n')
        elif p.getType() == PyIndi.INDI_BLOB:
            tpy = p.getBLOB()
            for t in tpy:
                PyIndiDriver.IDLog("       " + t.name + "(" + t.label +
                                   ")= <blob " + str(t.size) + " bytes>" +
                                   '\n')
示例#4
0
 def initProperties(self):
     self.logger.info("initProperties "+self.getDefaultName())
     super(IndiDriver, self).initProperties()
     #self.logger.info("initProperties loading skeleton")
     self.skelFileName = "tutorial_four_sk.xml"
     self.skel = os.getenv("INDISKEL")
     if self.skel:
         self.buildSkeleton(self.skel)
     else:
         try:
             os.stat(self.skelFileName)
             self.buildSkeleton(self.skelFileName)
         except OSError as e:
             PyIndiDriver.IDLog("No skeleton file was specified. Set environment variable INDISKEL to the skeleton path and try again.\n");
     # Optional: Add aux controls for configuration, debug & simulation that get added in the Options tab
     # of the driver.
     self.addAuxControls()
     # Let's print a list of all device properties
     lp=self.getProperties()
     for p in lp:
         PyIndiDriver.IDLog('Property '+p.getName()+' - ' + p.getLabel() + '\n')
         if p.getType()==PyIndi.INDI_TEXT:
             tpy=p.getText()
             for t in tpy:
                 PyIndiDriver.IDLog("       "+t.name+"("+t.label+")= "+t.text + '\n')
         elif p.getType()==PyIndi.INDI_NUMBER:
             tpy=p.getNumber()
             for t in tpy:
                 PyIndiDriver.IDLog("       "+t.name+"("+t.label+")= "+str(t.value) + '\n')
         elif p.getType()==PyIndi.INDI_SWITCH:
             tpy=p.getSwitch()
             for t in tpy:
                 PyIndiDriver.IDLog("       "+t.name+"("+t.label+")= "+strISState(t.s) + '\n')
         elif p.getType()==PyIndi.INDI_LIGHT:
             tpy=p.getLight()
             for t in tpy:
                 PyIndiDriver.IDLog("       "+t.name+"("+t.label+")= "+strIPState(t.s) + '\n')
         elif p.getType()==PyIndi.INDI_BLOB:
             tpy=p.getBLOB()
             for t in tpy:
                 PyIndiDriver.IDLog("       "+t.name+"("+t.label+")= <blob "+str(t.size)+" bytes>" + '\n')
     return True
示例#5
0
def ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, n):
    PyIndiDriver.IDLog("Main ISNewBLOB\n")
    indidriver.ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, n)