コード例 #1
0
ファイル: aggregator.py プロジェクト: monkpit/pyfocas
def main():
    """
    The main method of the program. Runs a Collector forever.
    """

    """ Setup logging """
    logging.basicConfig(level=logging.DEBUG)
    logging.info("Starting Collector")

    """ Setup MongoDB logging client """
    client = pymongo.MongoClient("mongodb://srvhoursapp25.nov.com:27017/")
    db = client['test']
    collection = db['focas']

    def reporter(machine):
        return mongo_reporter(collection, machine)

    """ Instantiate Fanuc30iDriver """
    driver30i = Fanuc30iDriver("./lib/Fwlib32.dll",
                               extradlls=["./lib/fwlibe1.dll"])

    """ List of Machine objects to initialize the Collector with """
    machines = [Machine(driver=driver30i, ip=THREE_SIXTEEN, name="316"),
                Machine(driver=driver30i, ip=THREE_TWENTY, name="320"),
                #Machine(driver=driver30i, ip=THREE_TWENTY_TWO, name="322"),
                #Machine(driver=driver30i, ip=THREE_TWENTY_SIX, name="326"),
                #Machine(driver=driver30i, ip=FOUR_SIXTEEN, name="416"),
                #Machine(driver=driver30i, ip=FOUR_EIGHTEEN, name="418"),
                Machine(driver=driver30i, ip=FOUR_TWENTY_ONE, name="421"),
                #Machine(driver=driver30i, ip=THREE_EIGHTY_SEVEN, name="387"),
                Machine(driver=driver30i, ip=THREE_NINETY_SEVEN, name="397"),
                Machine(driver=driver30i, ip=THREE_NINETY_SIX, name="396"),
                Machine(driver=driver30i, ip=THREE_NINETY_THREE, name="393"), ]
    """ Create the Collector """
    collector = Collector(reporter=reporter, machines=machines)

    while True:
        """ Run the collector until the process is interrupted """
        collector.collect()
        time.sleep(.5)
コード例 #2
0
ファイル: testIntegration.py プロジェクト: monkpit/pyfocas
 def test_machine_integration(self):
     """
     Test that the machine responds to our queries with
     the appropriate info included in its response.
     """
     driver = Fanuc30iDriver("./lib/Fwlib32.dll",
                             extradlls=["./lib/fwlibe1.dll"])
     machineList = [Machine(driver=driver, ip=TEST_MACHINE_IP)]
     collector = Collector(reporter, machineList)
     data = collector.collect()
     try:
         data[0]["timestamp"]
         data[0]["blockNumber"]
         data[0]["activeTool"]
         data[0]["programName"]
         data[0]["oNumber"]
         data[0]["loads"]["S"]
         data[0]["loads"]["X"]
         data[0]["alarm"]
     except KeyError as e:
         self.fail("One or more of the data items were not collected: %s"
                   % e)
コード例 #3
0
ファイル: aggregator.py プロジェクト: Liuqing-Zhang/pyfocas
def main():
    """
    The main method of the program. Runs a Collector forever.
    """
    """ Setup logging """
    logging.basicConfig(level=logging.DEBUG)
    logging.info("Starting Collector")
    """ Setup MongoDB logging client """
    client = pymongo.MongoClient("mongodb://srvhoursapp25.nov.com:27017/")
    db = client['test']
    collection = db['focas']

    def reporter(machine):
        return mongo_reporter(collection, machine)

    """ Instantiate Fanuc30iDriver """
    driver30i = Fanuc30iDriver("./lib/Fwlib32.dll",
                               extradlls=["./lib/fwlibe1.dll"])
    """ List of Machine objects to initialize the Collector with """
    machines = [
        Machine(driver=driver30i, ip=THREE_SIXTEEN, name="316"),
        Machine(driver=driver30i, ip=THREE_TWENTY, name="320"),
        #Machine(driver=driver30i, ip=THREE_TWENTY_TWO, name="322"),
        #Machine(driver=driver30i, ip=THREE_TWENTY_SIX, name="326"),
        #Machine(driver=driver30i, ip=FOUR_SIXTEEN, name="416"),
        #Machine(driver=driver30i, ip=FOUR_EIGHTEEN, name="418"),
        Machine(driver=driver30i, ip=FOUR_TWENTY_ONE, name="421"),
        #Machine(driver=driver30i, ip=THREE_EIGHTY_SEVEN, name="387"),
        Machine(driver=driver30i, ip=THREE_NINETY_SEVEN, name="397"),
        Machine(driver=driver30i, ip=THREE_NINETY_SIX, name="396"),
        Machine(driver=driver30i, ip=THREE_NINETY_THREE, name="393"),
    ]
    """ Create the Collector """
    collector = Collector(reporter=reporter, machines=machines)

    while True:
        """ Run the collector until the process is interrupted """
        collector.collect()
        time.sleep(.5)
コード例 #4
0
 def test_machine_integration(self):
     """
     Test that the machine responds to our queries with
     the appropriate info included in its response.
     """
     driver = Fanuc30iDriver("./lib/Fwlib32.dll",
                             extradlls=["./lib/fwlibe1.dll"])
     machineList = [Machine(driver=driver, ip=TEST_MACHINE_IP)]
     collector = Collector(reporter, machineList)
     data = collector.collect()
     try:
         data[0]["timestamp"]
         data[0]["blockNumber"]
         data[0]["activeTool"]
         data[0]["programName"]
         data[0]["oNumber"]
         data[0]["loads"]["S"]
         data[0]["loads"]["X"]
         data[0]["alarm"]
     except KeyError as e:
         self.fail("One or more of the data items were not collected: %s" %
                   e)
コード例 #5
0
 def setup_class(cls):
     driver = ExampleDriver("./lib/Fwlib32.dll",
                            extradlls=["./lib/fwlibe1.dll"])
     machines = [Machine(driver=driver, ip="127.0.0.1")]
     cls.collector = Collector(reporter=reporterFunction, machines=machines)