Merge branch 'wip' of git.psi.ch:sinqdev/frappy into wip

This commit is contained in:
l_samenv 2020-09-08 13:37:01 +02:00
commit 1f832388d7
2 changed files with 73 additions and 78 deletions

View File

@ -1,4 +1,4 @@
# Frappy Framework # Frappy Framework
current running code at SINQ, with newset changes not yet pushed current running code at SINQ, with newest changes not yet pushed
through the Gerrit workflow at MLZ through the Gerrit workflow at MLZ

View File

@ -1,77 +1,72 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ***************************************************************************** # *****************************************************************************
# This program is free software; you can redistribute it and/or modify it under # This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software # the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later # Foundation; either version 2 of the License, or (at your option) any later
# version. # version.
# #
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details. # details.
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., # this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# Module authors: # Module authors:
# Markus Zolliker <markus.zolliker@psi.ch> # Markus Zolliker <markus.zolliker@psi.ch>
# ***************************************************************************** # *****************************************************************************
"""a very simple simulator for a LakeShore Model 370""" """a very simple simulator for a LakeShore Model 370"""
from secop.modules import Communicator from secop.modules import Communicator
#from secop.lib import mkthread
class Ls370Sim(Communicator):
class Ls370Sim(Communicator): CHANNEL_COMMANDS = [
CHANNEL_COMMANDS = [ ('RDGR?%d', '1.0'),
('RDGR?%d', '1.0'), ('RDGST?%d', '0'),
('RDGST?%d', '0'), ('RDGRNG?%d', '0,5,5,0,0'),
('RDGRNG?%d', '0,5,5,0,0'), ('INSET?%d', '1,5,5,0,0'),
('INSET?%d', '1,5,5,0,0'), ('FILTER?%d', '1,5,80'),
('FILTER?%d', '1,5,80'), ]
] OTHER_COMMANDS = [
OTHER_COMMANDS = [ ('*IDN?', 'LSCI,MODEL370,370184,05302003'),
('*IDN?', 'LSCI,MODEL370,370184,05302003'), ('SCAN?', '3,1'),
('SCAN?', '3,1'), ]
] def earlyInit(self):
def earlyInit(self): self._data = dict(self.OTHER_COMMANDS)
self._data = dict(self.OTHER_COMMANDS) for fmt, v in self.CHANNEL_COMMANDS:
for fmt, v in self.CHANNEL_COMMANDS: for chan in range(1,17):
for chan in range(1,17): self._data[fmt % chan] = v
self._data[fmt % chan] = v # mkthread(self.run)
# mkthread(self.run)
def do_communicate(self, command):
def do_communicate(self, command): # simulation part, time independent
# simulation part, time independent for channel in range(1,17):
for channel in range(1,17): _, _, _, _, excoff = self._data['RDGRNG?%d' % channel].split(',')
_, _, _, _, excoff = self._data['RDGRNG?%d' % channel].split(',') if excoff == '1':
if excoff == '1': self._data['RDGST?%d' % channel] = '6'
self._data['RDGST?%d' % channel] = '6' else:
else: self._data['RDGST?%d' % channel] = '0'
self._data['RDGST?%d' % channel] = '0'
chunks = command.split(';')
chunks = command.split(';') reply = []
reply = [] for chunk in chunks:
for chunk in chunks: if '?' in chunk:
if '?' in chunk: reply.append(self._data[chunk])
reply.append(self._data[chunk]) else:
else: for nqarg in (1,0):
for nqarg in (1,0): if nqarg == 0:
if nqarg == 0: qcmd, arg = chunk.split(' ', 1)
qcmd, arg = chunk.split(' ', 1) qcmd += '?'
qcmd += '?' else:
else: qcmd, arg = chunk.split(',', nqarg)
qcmd, arg = chunk.split(',', nqarg) qcmd = qcmd.replace(' ', '?', 1)
qcmd = qcmd.replace(' ', '?', 1) if qcmd in self._data:
if qcmd in self._data: self._data[qcmd] = arg
self._data[qcmd] = arg break
break #if command.startswith('R'):
#if command.startswith('R'): # print('> %s\t< %s' % (command, reply))
# print('> %s\t< %s' % (command, reply)) return ';'.join(reply)
return ';'.join(reply)
#def run(self):
# # time dependent simulation
# while True:
# time.sleep(1)