55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
#!/usr/bin/python3
|
|
#-*-coding: UTF-8 -*-
|
|
|
|
import Ice
|
|
import IcePy
|
|
import signal,sys
|
|
import MessageICE_ice
|
|
import time
|
|
import logging as d
|
|
from StorageDB import StorageDB
|
|
from log.LogUtil import LogUtil
|
|
|
|
class PdbICEI(MessageICE_ice._M_baosight.MessageICE):
|
|
def __init__(self):
|
|
self.store=StorageDB()
|
|
|
|
def SendDataShort(self, eventNo, seq, length, context=None):
|
|
d.info("eventNo:"+str(eventNo))
|
|
d.info("seq:"+str(seq))
|
|
self.store.dispatch(eventNo,seq)
|
|
|
|
def SendDataLong(self, eventNo, seq, length, context=None):
|
|
d.info("eventNo:"+str(eventNo))
|
|
|
|
def TimeNotify(self, eventNo, seq, length, context=None):
|
|
d.info("eventNo:"+str(eventNo))
|
|
self.store.dispatch(eventNo,seq)
|
|
|
|
|
|
|
|
with Ice.initialize(sys.argv) as communicator:
|
|
#
|
|
# Install a signal handler to shutdown the communicator on Ctrl-C
|
|
#
|
|
signal.signal(signal.SIGINT, lambda signum, frame: communicator.shutdown())
|
|
|
|
#
|
|
# The communicator initialization removes all Ice-related arguments from argv
|
|
#
|
|
if len(sys.argv) > 1:
|
|
print(sys.argv[0] + ": too many arguments")
|
|
sys.exit(1)
|
|
|
|
properties = communicator.getProperties()
|
|
object_name = "baosight/" + properties.getProperty("Ice.ProgramName")
|
|
LogUtil.init(properties.getProperty("Ice.ProgramName"))
|
|
d.info("--start--")
|
|
d.info(object_name)
|
|
|
|
adapter = communicator.createObjectAdapter("DefaultAdapter")
|
|
adapter.add(PdbICEI(), Ice.stringToIdentity(object_name))
|
|
d.info("object name:" + object_name)
|
|
adapter.activate()
|
|
communicator.waitForShutdown()
|