예제 #1
0
def createChain():
    # This retrives the name of all of the ini files that are listed in the database.
    iniName = queryColumn('devices', "ini", 'sqlite:///../database/database/rh.db')

    for index in range(0,len(iniName)):
        portDic = None  #a dictionary of port objects
        deviceDic = None #a dictionary of device objects
        
        #ADD A CHECK TO SEE IF FILE EXISTS
        
        #parses the ini file section, BACPYPES, to return a dictionary of controller properties
        deviceDic = iniParser("iniFiles/" + str(iniName[index]))
        #adds the request IP to the dictionary (this is the device IP - 1)
        deviceDic['requestip'] = CompIPToRequestIP(deviceDic['address'])
        #parses the PORTS section of the ini file to return a dictionary of port properties
        portDic = parsePorts("iniFiles/" + str(iniName[index]))

        #for each item in the ports dictionary, create a port object of that name and return it to a dictionary with the port number as the dictionary key
        for port in portDic:
            portDic[port] = instantiatePortClass(portDic[port], portNumber(port))
        
        if index == 0:
            deviceList = Device(deviceDic, portDic)
            counter = deviceList
        elif index ==1 :
            temp = Device(deviceDic, portDic)
            deviceList.addDevice(temp)
            counter = counter.getNext()                     
        else:
            temp = Device(deviceDic, portDic)
            counter.addDevice(temp)
            counter = counter.getNext()

    return deviceList
def createChain():
    iniName = queryColumn(Devices, "ini")
    for x in range(0,len(iniName)):
        value = iniParser("iniFiles/" + str(iniName[x]))
        value.append(CompIPToRequestIP(value[1]))
        if x == 0:
            deviceList = Device(value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7],value[8],value[9])
            counter = deviceList
        elif x ==1 :
            temp = Device(value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7],value[8],value[9])
            deviceList.addDevice(temp)
            counter = counter.getNext()
        else:
            temp = Device(value[0],value[1],value[2],value[3],value[4],value[5],value[6],value[7],value[8],value[9])
            counter.addDevice(temp)
            counter = counter.getNext()
            
    return deviceList
def createChain():
    # This retrieves the name of all of the ini files that are listed in the database.
    iniName = queryColumn('devices', 'ini', 'sqlite:///../database/database/rh.db')
        
    for index in range(0,len(iniName)):
        portDic = None  #a dictionary of port objects
        deviceDic = None #a dictionary of device objects
        
        #ADD A CHECK TO SEE IF FILE EXISTS
        
        #parses the ini file section, BACPYPES, to return a dictionary of controller properties
        deviceDic = iniParser("iniFiles/" + str(iniName[index]))
        #adds the request IP to the dictionary (this is the device IP - 1)
        deviceDic['requestip'] = CompIPToRequestIP(deviceDic['address'])
        #parses the PORTS section of the ini file to return a dictionary of port properties
        portDic = parsePorts("iniFiles/" + str(iniName[index]))

        #for each item in the ports dictionary, create a port object of that name and return it to a dictionary with the port number as the dictionary key
        for port in portDic:
            portDic[port] = instantiatePortClass(portDic[port], portNumber(port))
        
        #This if statement links the device objects into the linked list. 
        if index == 0:
            deviceList = Device(deviceDic, portDic)
            counter = deviceList
        #I do not think the elif statement is necessary but I did not want to remove it or change the code before the presentation.
        elif index ==1 :
            temp = Device(deviceDic, portDic)
            deviceList.addDevice(temp)
            counter = counter.getNext()                     
        else:
            temp = Device(deviceDic, portDic)
            counter.addDevice(temp)
            counter = counter.getNext()

    return deviceList
예제 #4
0
    [7,    10.0,  17.0,  11540, 0.5880,  0.5920, "CoaxCam.Zoom7"],
    [8,    12.0,  25.0,   7560, 0.4460,  0.4480, "CoaxCam.Zoom8"],
    [9,    15.0,  37.0,   3580, 0.3410,  0.3460, "CoaxCam.Zoom9"],
    [10,   16.0,  42.0,      0, 0.2700,  0.2690, "CoaxCam.Zoom10"]
    ]


# config 
for c in configs.keys():
    print "HMSET config.%s HEAD '%s' PUB '%s' RE '%s' PG '%s' AUTOSCINT '%s'" % \
        (c.lower(), configs[c]["head"], configs[c]["pub"], configs[c]["re"], configs[c]["pg"], configs[c]["autoscint"])


# motor stuff
if hard_ini:
    hi = iniParser.iniParser( hard_ini)
    hi.read()

for m in motor_dict.keys():
    print "HSETNX %s.%s.name VALUE '%s'" % (head, m, m)         #  These values are not part of any defaults
    print "PUBLISH mk_pgpmac_redis %s.%s.name"  % (head, m)     #
    print "HSETNX %s.%s.name DBRTYPE 0"  % (head, m)            #
    print "HSETNX %s.%s.position VALUE ''" % (head, m)          #
    print "PUBLISH mk_pgpmac_redis %s.%s.position" % (head, m)  #
    print "HSETNX %s.%s.position DBRTYPE 6" % (head, m)         #


    if hard_ini != None and motor_dict[m].has_key("hard_ini"):
        motor_dict[m]["motor_num"] = hi.get(motor_dict[m]["hard_ini"], "motornumber")
        motor_dict[m]["coord_num"] = hi.get(motor_dict[m]["hard_ini"], "coordinatesystem")
    [5, 8.0, 10.0, 19500, 1.0140, 1.0110, "CoaxCam.Zoom5"],
    [6, 9.0, 12.0, 15520, 0.7710, 0.7760, "CoaxCam.Zoom6"],
    [7, 10.0, 17.0, 11540, 0.5880, 0.5920, "CoaxCam.Zoom7"],
    [8, 12.0, 25.0, 7560, 0.4460, 0.4480, "CoaxCam.Zoom8"],
    [9, 15.0, 37.0, 3580, 0.3410, 0.3460, "CoaxCam.Zoom9"],
    [10, 16.0, 42.0, 0, 0.2700, 0.2690, "CoaxCam.Zoom10"]
]

# config
for c in configs.keys():
    print "HMSET config.%s HEAD '%s' PUB '%s' RE '%s' PG '%s' AUTOSCINT '%s'" % \
        (c.lower(), configs[c]["head"], configs[c]["pub"], configs[c]["re"], configs[c]["pg"], configs[c]["autoscint"])

# motor stuff
if hard_ini:
    hi = iniParser.iniParser(hard_ini)
    hi.read()

for m in motor_dict.keys():
    print "HSETNX %s.%s.name VALUE '%s'" % (
        head, m, m)  #  These values are not part of any defaults
    print "PUBLISH mk_pgpmac_redis %s.%s.name" % (head, m)  #
    print "HSETNX %s.%s.name DBRTYPE 0" % (head, m)  #
    print "HSETNX %s.%s.position VALUE ''" % (head, m)  #
    print "PUBLISH mk_pgpmac_redis %s.%s.position" % (head, m)  #
    print "HSETNX %s.%s.position DBRTYPE 6" % (head, m)  #

    if hard_ini != None and motor_dict[m].has_key("hard_ini"):
        motor_dict[m]["motor_num"] = hi.get(motor_dict[m]["hard_ini"],
                                            "motornumber")
        motor_dict[m]["coord_num"] = hi.get(motor_dict[m]["hard_ini"],
def createChain():
    iniName = queryColumn('Devices', "ini")
    for index in range(0,len(iniName)):
        portDic = None
        deviceDic = None
     #   print "\n" +iniName[index]
     #   print portDic
        deviceDic = iniParser("iniFiles/" + str(iniName[index]))
        deviceDic['requestip'] = CompIPToRequestIP(deviceDic['address'])
        portDic = parsePorts("iniFiles/" + str(iniName[index]))  #Still reads [Ports] information even if nothing is in file, not sure how to fix
     #   print portDic

        for port in portDic:
            portDic[port] = instantiatePortClass(portDic[port], portNumber(port))

        if index == 0:
            deviceList = Device(deviceDic, portDic)
#            deviceList = Device(dictionary['objectname'],dictionary['address'],
#            dictionary['objectidentifier'],dictionary['maxapdulengthaccepted'],
#            dictionary['segmentationsupported'],dictionary['vendoridentifier'],
#            dictionary['foreignport'],dictionary['foreignbbmd'],
#            dictionary['foreignttl'],dictionary['requestip'])
            counter = deviceList
        elif index ==1 :
            temp = Device(deviceDic, portDic)
#            temp = Device(dictionary['objectname'],dictionary['address'],
#            dictionary['objectidentifier'],dictionary['maxapdulengthaccepted'],
#            dictionary['segmentationsupported'],dictionary['vendoridentifier'],
#            dictionary['foreignport'],dictionary['foreignbbmd'],
#            dictionary['foreignttl'],dictionary['requestip'])
            deviceList.addDevice(temp)
            counter = counter.getNext()
#           
        else:
            temp = Device(deviceDic, portDic)
#            temp = Device(dictionary['objectname'],dictionary['address'],
#            dictionary['objectidentifier'],dictionary['maxapdulengthaccepted'],
#            dictionary['segmentationsupported'],dictionary['vendoridentifier'],
#            dictionary['foreignport'],dictionary['foreignbbmd'],
#            dictionary['foreignttl'],dictionary['requestip'])
            counter.addDevice(temp)
            counter = counter.getNext()



        # value = iniParser("iniFiles/" + str(iniName[x]))
        # value['requestAddress'] = str(CompIPToRequestIP(value[1]))
        # if x == 0:
        #     deviceList = Device(value['objectName'],value['address'],
        #     value['objectIdentifier'],value['maxApduLengthAccepted'],
        #     value['segmentationSupported'],value['vendorIdentifier'],
        #     value['foreignPort'],value['foreignBBMD'],
        #     value['foreignTTL'],value['requestAddress'])
        #     counter = deviceList
        # elif x ==1 :
        #     temp = Device(value['objectName'],value['address'],
        #     value['objectIdentifier'],value['maxApduLengthAccepted'],
        #     value['segmentationSupported'],value['vendorIdentifier'],
        #     value['foreignPort'],value['foreignBBMD'],
        #     value['foreignTTL'],value['requestAddress'])
        #     deviceList.addDevice(temp)
        #     counter = counter.getNext()
        # else:
        #     temp = Device(value['objectName'],value['address'],
        #     value['objectIdentifier'],value['maxApduLengthAccepted'],
        #     value['segmentationSupported'],value['vendorIdentifier'],
        #     value['foreignPort'],value['foreignBBMD'],
        #     value['foreignTTL'],value['requestAddress'])

    return deviceList