add sim for ls372
+ fix bin/sim-server Change-Id: I6cad963d9e37faea172ca51a327474406ecafa4a
This commit is contained in:
@ -110,6 +110,7 @@ class Server(LineServer):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwds):
|
||||||
super().__init__(*args, **kwds)
|
super().__init__(*args, **kwds)
|
||||||
|
self.secnode = None
|
||||||
self.dispatcher = self.Dispatcher()
|
self.dispatcher = self.Dispatcher()
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,3 +71,57 @@ class Ls370Sim(Communicator):
|
|||||||
reply = ';'.join(reply)
|
reply = ';'.join(reply)
|
||||||
self.comLog('< %s' % reply)
|
self.comLog('< %s' % reply)
|
||||||
return reply
|
return reply
|
||||||
|
|
||||||
|
|
||||||
|
class Ls372Sim(Communicator):
|
||||||
|
CHANNEL_COMMANDS = [
|
||||||
|
('RDGR?%d', '1.0'),
|
||||||
|
('RDGK?%d', '1.5'),
|
||||||
|
('RDGST?%d', '0'),
|
||||||
|
('RDGRNG?%d', '0,5,5,0,0'),
|
||||||
|
('INSET?%d', '1,5,5,0,0'),
|
||||||
|
('FILTER?%d', '1,5,80'),
|
||||||
|
]
|
||||||
|
OTHER_COMMANDS = [
|
||||||
|
('*IDN?', 'LSCI,MODEL372,372184,05302003'),
|
||||||
|
('SCAN?', '3,1'),
|
||||||
|
('PID?1', '10,10,0'),
|
||||||
|
('*OPC?', '1'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def earlyInit(self):
|
||||||
|
super().earlyInit()
|
||||||
|
self._data = dict(self.OTHER_COMMANDS)
|
||||||
|
for fmt, v in self.CHANNEL_COMMANDS:
|
||||||
|
for chan in range(1,17):
|
||||||
|
self._data[fmt % chan] = v
|
||||||
|
|
||||||
|
def communicate(self, command):
|
||||||
|
self.comLog('> %s' % command)
|
||||||
|
# simulation part, time independent
|
||||||
|
for channel in range(1,17):
|
||||||
|
_, _, _, _, excoff = self._data['RDGRNG?%d' % channel].split(',')
|
||||||
|
if excoff == '1':
|
||||||
|
self._data['RDGST?%d' % channel] = '6'
|
||||||
|
else:
|
||||||
|
self._data['RDGST?%d' % channel] = '0'
|
||||||
|
|
||||||
|
chunks = command.split(';')
|
||||||
|
reply = []
|
||||||
|
for chunk in chunks:
|
||||||
|
if '?' in chunk:
|
||||||
|
reply.append(self._data[chunk])
|
||||||
|
else:
|
||||||
|
for nqarg in (1,0):
|
||||||
|
if nqarg == 0:
|
||||||
|
qcmd, arg = chunk.split(' ', 1)
|
||||||
|
qcmd += '?'
|
||||||
|
else:
|
||||||
|
qcmd, arg = chunk.split(',', nqarg)
|
||||||
|
qcmd = qcmd.replace(' ', '?', 1)
|
||||||
|
if qcmd in self._data:
|
||||||
|
self._data[qcmd] = arg
|
||||||
|
break
|
||||||
|
reply = ';'.join(reply)
|
||||||
|
self.comLog('< %s' % reply)
|
||||||
|
return reply
|
||||||
|
Reference in New Issue
Block a user