This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#Tue May 14 14:52:29 CEST 2024
|
||||
LastRunDate=240514
|
||||
DaySequentialNumber=30
|
||||
FileSequentialNumber=41
|
||||
#Thu May 23 00:00:00 CEST 2024
|
||||
LastRunDate=240523
|
||||
DaySequentialNumber=1
|
||||
FileSequentialNumber=104
|
||||
|
||||
11
devices/Time.properties
Normal file
11
devices/Time.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
#Fri May 17 16:39:43 CEST 2024
|
||||
minValue=NaN
|
||||
unit=null
|
||||
offset=0.0
|
||||
maxValue=NaN
|
||||
rotation=false
|
||||
precision=-1
|
||||
sign_bit=0
|
||||
scale=1.0
|
||||
description=null
|
||||
resolution=NaN
|
||||
@@ -1,21 +1,19 @@
|
||||
import java.io.IOException as IOException
|
||||
|
||||
if get_context().localMode:
|
||||
raise Exception ("Must run in exclusive mode")
|
||||
|
||||
set_exec_pars(name="archiver", open=True)
|
||||
|
||||
#data_path = "/sls/rf/data/SLS_Teststand/PShell/data/"
|
||||
|
||||
|
||||
set_exec_pars(name="archiver", open=True)
|
||||
DATA_PATH = get_exec_pars().path #expand_path("{data}/{date}/{name}")
|
||||
|
||||
def get_data_path(channel):
|
||||
#path = data_path + expand_path("{date}")
|
||||
#path = expand_path("{data}/{date}/archiver")
|
||||
path = get_exec_pars().path
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
path = DATA_PATH
|
||||
channel = channel.replace(":", "_") #FILENAMES DO NOT SUPPORT :
|
||||
return path + "/"+ channel + ".txt"
|
||||
|
||||
|
||||
|
||||
if "stop_short_term_archiver" in globals():
|
||||
stop_short_term_archiver()
|
||||
|
||||
@@ -23,29 +21,33 @@ def _log(msg):
|
||||
print msg
|
||||
log(msg)
|
||||
|
||||
_log("Data path:" + str(DATA_PATH))
|
||||
|
||||
|
||||
def archive_channel(channel, interval):
|
||||
_log("Enter: " + str(channel))
|
||||
|
||||
try:
|
||||
monitored = interval == True
|
||||
polling = 0 if monitored else int (interval)
|
||||
filename = get_data_path(channel)
|
||||
monitored = interval is True
|
||||
polling = 0 if monitored else int (interval * 1000)
|
||||
#dev = "ca://" + channel + ("?monitored=true" if monitored else ")
|
||||
while True:
|
||||
with Channel(channel, monitored, polling) as ch:
|
||||
with open(filename, 'a') as data_file:
|
||||
_log("Opened: " + filename)
|
||||
channel_listener = ChannelListener(data_file)
|
||||
ch.addListener(channel_listener)
|
||||
ch.update()
|
||||
while True:
|
||||
if filename != get_data_path(channel):
|
||||
_log("Closing: " + filename)
|
||||
break
|
||||
time.sleep(1.0)
|
||||
|
||||
|
||||
try:
|
||||
with Channel(channel, monitored, polling) as ch:
|
||||
filename = get_data_path(channel)
|
||||
with open(filename, 'a') as data_file:
|
||||
_log("Opened: " + filename + " monitor: " + str(monitored) + " polling: " + str(polling))
|
||||
channel_listener = ChannelListener(data_file)
|
||||
ch.addListener(channel_listener)
|
||||
ch.update()
|
||||
while True:
|
||||
if filename != get_data_path(channel):
|
||||
_log("Closing: " + filename)
|
||||
break
|
||||
time.sleep(1.0)
|
||||
except IOException:
|
||||
_log("Error processing channel " + str(channel) + ": " + str( sys.exc_info()[1]))
|
||||
time.sleep(60.0 * 10)
|
||||
"""
|
||||
class Timestamp(Readable):
|
||||
def read(self):
|
||||
@@ -66,19 +68,40 @@ def archive_channel(channel, interval):
|
||||
_log("Exit: " + str(channel))
|
||||
|
||||
|
||||
def archive_monitor():
|
||||
global DATA_PATH
|
||||
_log("Start Monitor")
|
||||
try:
|
||||
while(True):
|
||||
path = expand_path(get_context().config.dataPath)
|
||||
if path != DATA_PATH:
|
||||
_log("Day change")
|
||||
set_exec_pars(open=False)
|
||||
set_exec_pars(name="archiver", open=True)
|
||||
DATA_PATH = path #get_exec_pars().path
|
||||
_log("Data path:" + str(DATA_PATH))
|
||||
#os.makedirs(path)
|
||||
time.sleep(1.0)
|
||||
finally:
|
||||
_log("Stop Monitor")
|
||||
|
||||
short_term_archiver_cfg = {}
|
||||
short_term_archiver_tasks=[]
|
||||
short_term_archiver_monitor=None
|
||||
|
||||
def start_short_term_archiver(metadata=False):
|
||||
global short_term_archiver_cfg
|
||||
global short_term_archiver_tasks
|
||||
global short_term_archiver_monitor
|
||||
print "Starting Short Term Archiver"
|
||||
short_term_archiver_cfg = parse_short_term_archiver_config(metadata)
|
||||
short_term_archiver_tasks = fork(* [[archive_channel,[channel, interval,]] for channel,interval in short_term_archiver_cfg.items()])
|
||||
short_term_archiver_monitor = fork(archive_monitor)[0]
|
||||
|
||||
def wait_short_term_archiver():
|
||||
global short_term_archiver_tasks
|
||||
join(short_term_archiver_tasks)
|
||||
join(short_term_archiver_monitor)
|
||||
|
||||
def stop_short_term_archiver():
|
||||
global short_term_archiver_tasks
|
||||
@@ -88,7 +111,10 @@ def stop_short_term_archiver():
|
||||
task.cancel(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
short_term_archiver_monitor.cancel(True)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
start_short_term_archiver()
|
||||
wait_short_term_archiver()
|
||||
|
||||
@@ -24,6 +24,7 @@ class Channel:
|
||||
self.channel=GenericChannel(self.channel_name,self.channel_name, True, InvalidValueAction.None)
|
||||
self.channel.setMonitored(self.monitored)
|
||||
self.channel.setPolling(self.polling)
|
||||
#self.channel.setPolling(1000)
|
||||
self.channel.initialize()
|
||||
return self.channel
|
||||
|
||||
@@ -67,13 +68,16 @@ class ChannelListener (DeviceListener):
|
||||
|
||||
|
||||
|
||||
|
||||
def parse_archiver_config(metadata=True, file_name=None):
|
||||
#path = expand_path("{script}/config")
|
||||
path = "/sls/rf/data/SLS_Teststand/PShell/sls_archiver/config/RF"
|
||||
ret = {}
|
||||
if not file_name:
|
||||
for file_name in os.listdir(expand_path("{script}/config")):
|
||||
for file_name in os.listdir(path):
|
||||
if file_name.endswith(".config"):
|
||||
# If the file has the desired extension, add it to the list
|
||||
ret.update(parse_archiver_config(metadata, expand_path("{script}/config/" + file_name)))
|
||||
ret.update(parse_archiver_config(metadata, path + "/" + file_name))
|
||||
else:
|
||||
with open(file_name, 'r') as f:
|
||||
for line in f:
|
||||
@@ -89,7 +93,7 @@ def parse_archiver_config(metadata=True, file_name=None):
|
||||
elif v=="Monitor":
|
||||
return True
|
||||
else:
|
||||
return int(v)
|
||||
return float(v)
|
||||
except Exception as e:
|
||||
print (e)
|
||||
return None
|
||||
@@ -104,7 +108,10 @@ def parse_archiver_config(metadata=True, file_name=None):
|
||||
|
||||
def parse_short_term_archiver_config(metadata):
|
||||
ret = parse_archiver_config(metadata)
|
||||
return {name:v[2] for name,v in ret.items()}
|
||||
log("Initializing " + str(len(ret)) + " channels")
|
||||
cfg = {name:v[0] for name,v in ret.items()}
|
||||
log(str(cfg))
|
||||
return cfg
|
||||
|
||||
|
||||
|
||||
|
||||
3
script/pull.py
Normal file
3
script/pull.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import subprocess
|
||||
ret = subprocess.check_output("git pull", shell=True, cwd="/sls/rf/data/SLS_Teststand/PShell/sls_archiver")
|
||||
set_return(ret)
|
||||
6
script/test/test_power_max.py
Normal file
6
script/test/test_power_max.py
Normal file
@@ -0,0 +1,6 @@
|
||||
name='ATSRF-CAV:CO1i-POWER-MAX'
|
||||
channel=GenericChannel(name,name, True, InvalidValueAction.None)
|
||||
channel.setMonitored(True)
|
||||
channel.initialize()
|
||||
add_device(channel, True)
|
||||
mscan (channel, channel, -1, 10.0)
|
||||
Reference in New Issue
Block a user