本文整理汇总了Python中fysom.Fysom.select方法的典型用法代码示例。如果您正苦于以下问题:Python Fysom.select方法的具体用法?Python Fysom.select怎么用?Python Fysom.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fysom.Fysom
的用法示例。
在下文中一共展示了Fysom.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gemHandler
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import select [as 别名]
class gemHandler(secsHandler):
"""Baseclass for creating Host/Equipment models. This layer contains GEM functionality. Inherit from this class and override required functions.
:param address: IP address of remote host
:type address: string
:param port: TCP port of remote host
:type port: integer
:param active: Is the connection active (*True*) or passive (*False*)
:type active: boolean
:param session_id: session / device ID to use for connection
:type session_id: integer
:param name: Name of the underlying configuration
:type name: string
:param event_handler: object for event handling
:type event_handler: :class:`secsgem.common.EventHandler`
:param custom_connection_handler: object for connection handling (ie multi server)
:type custom_connection_handler: :class:`secsgem.hsmsConnections.HsmsMultiPassiveServer`
"""
ceids = secsHandler.ceids
"""Dictionary of available collection events, CEID is the key
:param name: Name of the data value
:type name: string
:param CEID: Collection event the data value is used for
:type CEID: integer
"""
dvs = secsHandler.dvs
"""Dictionary of available data values, DVID is the key
:param name: Name of the collection event
:type name: string
:param dv: Data values available for collection event
:type dv: list of integers
"""
alarms = secsHandler.alarms
"""Dictionary of available alarms, ALID is the key
:param alarmText: Description of the alarm
:type alarmText: string
:param ceidOn: Collection event for activated alarm
:type ceidOn: integer
:param ceidOff: Collection event for deactivated alarm
:type ceidOff: integer
"""
rcmds = secsHandler.rcmds
"""Dictionary of available remote commands, command is the key
:param params: description of the parameters
:type params: list of dictionary
:param CEID: Collection events the remote command uses
:type CEID: list of integers
"""
def __init__(self, address, port, active, session_id, name, event_handler=None, custom_connection_handler=None):
secsHandler.__init__(self, address, port, active, session_id, name, event_handler, custom_connection_handler)
self.logger = logging.getLogger(self.__module__ + "." + self.__class__.__name__)
# not going to HOST_INITIATED_CONNECT because fysom doesn't support two states. but there is a transistion to get out of EQUIPMENT_INITIATED_CONNECT when the HOST_INITIATED_CONNECT happens
self.communicationState = Fysom({
'initial': 'DISABLED', # 1
'events': [
{'name': 'enable', 'src': 'DISABLED', 'dst': 'ENABLED'}, # 2
{'name': 'disable', 'src': ['ENABLED', 'NOT_COMMUNICATING', 'COMMUNICATING', 'EQUIPMENT_INITIATED_CONNECT', 'WAIT_DELAY', 'WAIT_CRA', "HOST_INITIATED_CONNECT", "WAIT_CR_FROM_HOST"], 'dst': 'DISABLED'}, # 3
{'name': 'select', 'src': 'NOT_COMMUNICATING', 'dst': 'EQUIPMENT_INITIATED_CONNECT'}, # 5
{'name': 'communicationreqfail', 'src': 'WAIT_CRA', 'dst': 'WAIT_DELAY'}, # 6
{'name': 'delayexpired', 'src': 'WAIT_DELAY', 'dst': 'WAIT_CRA'}, # 7
{'name': 'messagereceived', 'src': 'WAIT_DELAY', 'dst': 'WAIT_CRA'}, # 8
{'name': 's1f14received', 'src': 'WAIT_CRA', 'dst': 'COMMUNICATING'}, # 9
{'name': 'communicationfail', 'src': 'COMMUNICATING', 'dst': 'NOT_COMMUNICATING'}, # 14
{'name': 's1f13received', 'src': ['WAIT_CR_FROM_HOST', 'WAIT_DELAY', 'WAIT_CRA'], 'dst': 'COMMUNICATING'}, # 15 (WAIT_CR_FROM_HOST is running in background - AND state - so if s1f13 is received we go all communicating)
],
'callbacks': {
'onWAIT_CRA': self._onStateWaitCRA,
'onWAIT_DELAY': self._onStateWaitDelay,
'onleaveWAIT_CRA': self._onStateLeaveWaitCRA,
'onleaveWAIT_DELAY': self._onStateLeaveWaitDelay,
'onCOMMUNICATING': self._onStateCommunicating,
# 'onselect': self.onStateSelect,
},
'autoforward': [
{'src': 'ENABLED', 'dst': 'NOT_COMMUNICATING'}, # 4
{'src': 'EQUIPMENT_INITIATED_CONNECT', 'dst': 'WAIT_CRA'}, # 5
{'src': 'HOST_INITIATED_CONNECT', 'dst': 'WAIT_CR_FROM_HOST'}, # 10
]
})
self.waitCRATimer = None
self.commDelayTimer = None
self.commDelayTimeout = 10
self.reportIDCounter = 1000
self.reportSubscriptions = {}
self.registerCallback(1, 1, self.S1F1Handler)
#.........这里部分代码省略.........
示例2: hsmsHandler
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import select [as 别名]
class hsmsHandler(EventProducer):
"""Baseclass for creating Host/Equipment models. This layer contains the HSMS functionality. Inherit from this class and override required functions.
:param address: IP address of remote host
:type address: string
:param port: TCP port of remote host
:type port: integer
:param active: Is the connection active (*True*) or passive (*False*)
:type active: boolean
:param session_id: session / device ID to use for connection
:type session_id: integer
:param name: Name of the underlying configuration
:type name: string
:param event_handler: object for event handling
:type event_handler: :class:`secsgem.common.EventHandler`
:param custom_connection_handler: object for connection handling (ie multi server)
:type custom_connection_handler: :class:`secsgem.hsmsConnections.HsmsMultiPassiveServer`
**Example**::
import secsgem
def S1F1Handler(connection, packet):
print "S1F1 received"
def onConnect(event, data):
print "Connected"
client = secsgem.hsmsHandler("10.211.55.33", 5000, True, 0, "test", eventHandler=secsgem.EventHandler(events={'RemoteConnected': onConnect}))
client.registerCallback(1, 1, S1F1Handler)
client.enable()
time.sleep(3)
client.disable()
"""
def __init__(self, address, port, active, session_id, name, event_handler=None, custom_connection_handler=None):
EventProducer.__init__(self, event_handler)
self.logger = logging.getLogger(self.__module__ + "." + self.__class__.__name__)
self.address = address
self.port = port
self.active = active
self.sessionID = session_id
self.name = name
self.connected = False
# repeating linktest variables
self.linktestTimer = None
self.linktestTimeout = 30
# event and packet queues
self.eventQueue = []
self.packetQueue = []
# hsms connection state fsm
self.connectionState = Fysom({
'initial': 'NOT_CONNECTED',
'events': [
{'name': 'connect', 'src': 'NOT_CONNECTED', 'dst': 'CONNECTED'},
{'name': 'disconnect', 'src': ['CONNECTED', 'NOT_SELECTED', 'SELECTED'], 'dst': 'NOT_CONNECTED'},
{'name': 'select', 'src': 'NOT_SELECTED', 'dst': 'SELECTED'},
{'name': 'deselect', 'src': 'SELECTED', 'dst': 'NOT_SELECTED'},
{'name': 'timeoutT7', 'src': 'NOT_SELECTED', 'dst': 'NOT_CONNECTED'},
],
'callbacks': {
'onNOT_SELECTED': self._on_state_connect,
'onNOT_CONNECTED': self._on_state_disconnect,
'onSELECTED': self._on_state_select,
},
'autoforward': [
{'src': 'CONNECTED', 'dst': 'NOT_SELECTED'}
]
})
# setup connection
if self.active:
if custom_connection_handler is None:
self.connection = HsmsActiveConnection(self.address, self.port, self.sessionID, self)
else:
self.connection = custom_connection_handler.create_connection(self.address, self.port, self.sessionID, self)
else:
if custom_connection_handler is None:
self.connection = HsmsPassiveConnection(self.address, self.port, self.sessionID, self)
else:
self.connection = custom_connection_handler.create_connection(self.address, self.port, self.sessionID, self)
def _on_state_connect(self, data):
"""Connection state model got event connect
:param data: event attributes
:type data: object
"""
# start linktest timer
self.linktestTimer = threading.Timer(self.linktestTimeout, self._on_linktest_timer)
self.linktestTimer.start()
#.........这里部分代码省略.........