Skip to content
Snippets Groups Projects
Commit 66a63203 authored by Martin Scarcia's avatar Martin Scarcia
Browse files

first import - only code - synced with SVN rev. 25269

parent ae20b6bb
No related branches found
Tags 1.0.0
No related merge requests found
# exclude pyc files
*.pyc
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
Provides provides some usefull classes that will be used from
the other modules and classes inside the *fermidaq*.
``logger = MyLogger(); logger.info("hello world")``
FermiDaqSystem: definition of some classes, variables and functions that are
used by the other modules.
"""
import sys
import os
import time
debug_ = False
dbg_ = False
LOGFILTER = 20
class FermiDaqExc(Exception): pass
class FatalInternalError(FermiDaqExc):pass
class MyLogger():
""" Wrapper class that allow logging likely the PyTango logging.
From a Tango Device server, you should pass logger = self.get_logger(),
and using the debug, info, error, warn methods, you will use the
PyTango logging system.
There are 4 defined levels:
* :meth:`~MyLogger.info`
* :meth:`~MyLogger.debug`
"""
def info(self,msg):
""" Info level for debbugger.
:param: msg The message to warn
"""
if dbg_: print "INFO: ", msg
pass
def debug(self,msg):
"""Debug level"""
if dbg_: print "DEBUG: ",msg
return
def error(self,msg):
if dbg_: print "ERROR: ",msg
#sys.stderr.write("ERROR: "+msg+'\n')
pass
def warn(self,msg):
if dbg_: print "WARN: ",msg
#sys.stderr.write("WARN: "+msg+'\n')
pass
class TangoDeviceWrapper():
""" Wrapper the TangoDevice functions.
It wrappers the functions that will be called from the TangoDevice
for the purpose of test this thread outside the Tango Device.
"""
def __init__(self):
self.st = 0
self.file_path = ''
pass
def set_state(self,st):
self.st = st
pass
def set_status(self,status):
pass
def get_state(self):
return self.st
def notify_service(self, full_path):
self.file_path = full_path
pass
class BunchManagerWrapper:
""" The minimul interface for BunchManager.
.. attribute:: b
Information from the bunch number.
.. method:: last_bunch() -> current_bunch
Returns the current bunch number.
.. method:: data_ready(daq_pt, initial_bunch, final_bunch)
Receive the data_ready information.
"""
def __init__(self):
self.b = 0
def last_bunch(self):
"""
Returns the current bunch number.
:return: The current bunch number.
:rtype: integer
"""
#print 'BunchManagerWrapper bunch = ',self.b
self.b += 1
time.sleep(0.1)
return self.b
def data_ready(self,daq_pt,bn_in,bn_f):
"""Do not receive.
:param daq_pt: Pointer to FermiDaq object.
:param bn_in: Initial bunch number.
:param bn_f: Final bunch number.
:type bn_in: integer or None
"""
if dbg_: print 'Manager: ',daq_pt,bn_in, bn_f
def notify_state(self,key,msg,o):
pass
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
class Foo:
"""Docstring for class Foo."""
#: Doc comment for class attribute Foo.bar.
#: It can have multiple lines.
bar = 1
flox = 1.5 #: Doc comment for Foo.flox. One line only.
baz = 2
"""Docstring for class attribute Foo.baz."""
def __init__(self):
#: Doc comment for instance attribute qux.
self.qux = 3
self.spam = 4
"""Docstring for instance attribute spam."""
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment