commit 89d8f2cb11423a7c1d5b6e94d39b26387077556a Author: gobbo_a Date: Tue May 14 14:52:28 2024 +0200 Creation diff --git a/config/config.properties b/config/config.properties new file mode 100644 index 0000000..0404c59 --- /dev/null +++ b/config/config.properties @@ -0,0 +1,59 @@ +#Tue May 14 14:52:10 CEST 2024 +autoSaveScanData=true +simulation=false +xscanCrlogicChannel= +dataScanSaveOutput=false +userAuthenticator= +dataScanSaveScript=false +notifiedTasks= +parallelInitialization=false +fdaSerialization=false +dataTransferPath= +xscanAppendSuffix=true +saveConsoleSessionFiles=false +hostName= +disableEmbeddedAttributes=true +serverPort=8080 +versionTrackingEnabled=true +dataPath={data}/{date}/{name} +serverEnabled=true +depthDimension=0 +logLevel=Info +dataLayout=table +disableDataFileLogs=true +sessionHandling=Off +terminalEnabled=false +notificationLevel=Off +terminalPort=3579 +dataTransferUser= +xscanContinuousUpdate=false +versionTrackingLogin= +noBytecodeFiles=false +versionTrackingRemote= +dataScanLazyTableCreation=false +pythonHome= +xscanMoveTimeout=600 +logDaysToLive=7 +xscanCrlogicSimulated=false +logLevelConsole=Off +filePermissionsConfig=Default +scanStreamerPort=-1 +dataScanSaveSetpoints=false +versionTrackingManual=false +dataTransferMode=Off +userManagement=false +instanceName=MiniArchiver +dataServerPort=-1 +hideServerMessages=false +dataScanReleaseRecords=true +dataScanPreserveTypes=true +dataScanFlushRecords=true +filePermissionsLogs=Default +logPath={logs}/{date}_{time} +filePermissionsScripts=Default +xscanCrlogicPrefix= +filePermissionsData=Default +xscanCrlogicAbortable=true +dataProvider=txt +xscanCrlogicIoc= +saveCommandStatistics=false diff --git a/config/jcae.properties b/config/jcae.properties new file mode 100644 index 0000000..3604a21 --- /dev/null +++ b/config/jcae.properties @@ -0,0 +1,12 @@ +#Fri May 10 14:18:40 CEST 2024 +ch.psi.jcae.ContextFactory.addressList= +ch.psi.jcae.ContextFactory.serverPort= +ch.psi.jcae.ContextFactory.maxArrayBytes= +ch.psi.jcae.ContextFactory.maxSendArrayBytes= +ch.psi.jcae.ChannelFactory.retries=1 +ch.psi.jcae.ChannelFactory.timeout=1000 +ch.psi.jcae.impl.DefaultChannelService.retries= +ch.psi.jcae.impl.DefaultChannelService.timeout= +ch.psi.jcae.ContextFactory.autoAddressList=false +ch.psi.jcae.ContextFactory.useShellVariables=true +ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false diff --git a/config/mail.properties b/config/mail.properties new file mode 100644 index 0000000..21f7d52 --- /dev/null +++ b/config/mail.properties @@ -0,0 +1,9 @@ +#Fri May 10 13:44:32 CEST 2024 +port=0 +usr= +auth=None +smsSuffix=@sms.switch.ch +host= +from= +to= +pwd= diff --git a/config/preferences.json b/config/preferences.json new file mode 100644 index 0000000..c1f2a2c --- /dev/null +++ b/config/preferences.json @@ -0,0 +1,134 @@ +{ + "fontShellPanel" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontShellCommand" : { + "name" : "SansSerif", + "style" : 0, + "size" : 13 + }, + "fontOutput" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontEditor" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontPlotLabel" : { + "name" : "SansSerif", + "style" : 0, + "size" : 11 + }, + "fontPlotTick" : { + "name" : "SansSerif", + "style" : 0, + "size" : 10 + }, + "fontPlotTitle" : { + "name" : "SansSerif", + "style" : 1, + "size" : 13 + }, + "fontTerminal" : { + "name" : "Monospaced", + "style" : 0, + "size" : 14 + }, + "tabSize" : 4, + "contentWidth" : 0, + "editorBackground" : null, + "editorForeground" : null, + "simpleEditor" : false, + "hideEditorLineNumbers" : false, + "hideEditorContextMenu" : false, + "consoleLocation" : "Left", + "dataPanelLocation" : "Status", + "openDataFilesInDocTab" : false, + "noVariableEvaluationPropagation" : false, + "processingScripts" : [ ], + "asyncViewersUpdate" : false, + "asyncHistoryPlotsUpdate" : false, + "scanPlotDisabled" : false, + "scanTableDisabled" : false, + "cachedDataPanel" : false, + "dataExtensions" : null, + "dataSubFiles" : null, + "hideFileName" : false, + "showEmergencyStop" : false, + "showHomingButtons" : false, + "showJogButtons" : false, + "hideScanPanel" : false, + "hideOutputPanel" : false, + "showXScanFileBrowser" : false, + "showQueueBrowser" : false, + "backgroundRendering" : false, + "showImageStatusBar" : true, + "persistRendererWindows" : false, + "defaultRendererColormap" : "Grayscale", + "linePlot" : "ch.psi.pshell.plot.LinePlotJFree", + "matrixPlot" : "ch.psi.pshell.plot.MatrixPlotJFree", + "surfacePlot" : null, + "timePlot" : "ch.psi.pshell.plot.TimePlotJFree", + "plotsDetached" : false, + "plotsHidden" : false, + "plotLayout" : "Vertical", + "quality" : "High", + "defaultPlotColormap" : "Temperature", + "markerSize" : 0, + "plotBackground" : null, + "gridColor" : null, + "outlineColor" : null, + "disableOffscreenBuffer" : false, + "defaultPanels" : [ { + "deviceClassName" : "ch.psi.pshell.epics.Scaler", + "panelClassName" : "ch.psi.pshell.swing.ScalerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.epics.Scienta", + "panelClassName" : "ch.psi.pshell.swing.ScientaPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Motor", + "panelClassName" : "ch.psi.pshell.swing.MotorPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.MasterPositioner", + "panelClassName" : "ch.psi.pshell.swing.MasterPositionerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ProcessVariable", + "panelClassName" : "ch.psi.pshell.swing.ProcessVariablePanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.MotorGroup", + "panelClassName" : "ch.psi.pshell.swing.MotorGroupPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.DiscretePositioner", + "panelClassName" : "ch.psi.pshell.swing.DiscretePositionerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Camera", + "panelClassName" : "ch.psi.pshell.swing.CameraPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Slit", + "panelClassName" : "ch.psi.pshell.swing.SlitPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.HistogramGenerator", + "panelClassName" : "ch.psi.pshell.swing.HistogramGeneratorPanel" + }, { + "deviceClassName" : "ch.psi.pshell.bs.Stream", + "panelClassName" : "ch.psi.pshell.swing.StreamPanel" + }, { + "deviceClassName" : "ch.psi.pshell.bs.StreamChannel", + "panelClassName" : "ch.psi.pshell.swing.StreamChannelPanel" + }, { + "deviceClassName" : "ch.psi.pshell.camserver.CamServerStream", + "panelClassName" : "ch.psi.pshell.swing.CamServerStreamPanel" + }, { + "deviceClassName" : "ch.psi.pshell.camserver.CamServerService", + "panelClassName" : "ch.psi.pshell.swing.CamServerServicePanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister", + "panelClassName" : "ch.psi.pshell.swing.DeviceValueChart" + } ], + "scriptPopupDialog" : "None" +} \ No newline at end of file diff --git a/config/setup.properties b/config/setup.properties new file mode 100644 index 0000000..20b080d --- /dev/null +++ b/config/setup.properties @@ -0,0 +1,25 @@ +#Fri May 10 13:44:32 CEST 2024 +scriptPath={home}/script +sessionsPath={outp}/sessions +configFileDevices={config}/devices.properties +xscanPath={script} +queuePath={script} +extensionsPath={home}/extensions +configPath={home}/config +configFileSessions={config}/sessions.properties +userSessionsPath={sessions}/user +dataPath={outp}/data +configFileVariables={config}/variables.properties +wwwPath={home}/www +logPath={outp}/log +configFile={config}/config.properties +configFileTasks={config}/tasks.properties +pluginsPath={home}/plugins +consoleSessionsPath={sessions}/console +libraryPath={script}; {script}/Lib +contextPath={outp}/context +configFilePlugins={config}/plugins.properties +devicesPath={home}/devices +configFileSettings={config}/settings.properties +imagesPath={data} +scriptType=py diff --git a/config/tasks.properties b/config/tasks.properties new file mode 100644 index 0000000..f08c0b9 --- /dev/null +++ b/config/tasks.properties @@ -0,0 +1 @@ +archiver/short_term_archiver=10.0;1.0 diff --git a/config/variables.properties b/config/variables.properties new file mode 100644 index 0000000..7da40d9 --- /dev/null +++ b/config/variables.properties @@ -0,0 +1,4 @@ +#Tue May 14 14:48:40 CEST 2024 +LastRunDate=240514 +DaySequentialNumber=29 +FileSequentialNumber=40 diff --git a/devices/dp1.properties b/devices/dp1.properties new file mode 100644 index 0000000..7094688 --- /dev/null +++ b/devices/dp1.properties @@ -0,0 +1,12 @@ +#Tue May 14 10:37:17 CEST 2024 +motor7=null +motor8=null +motor5=null +motor6=null +precision=-1 +description=null +positions=Park|Ready|Out|Clear +motor3=null +motor4=null +motor1=0.0|4.0|8.0|0.0 +motor2=0.0|5.0|3.0|NaN diff --git a/devices/m1.properties b/devices/m1.properties new file mode 100644 index 0000000..d9ecd30 --- /dev/null +++ b/devices/m1.properties @@ -0,0 +1,17 @@ +#Tue May 14 10:37:17 CEST 2024 +offset=0.0 +maxValue=10.0 +rotation=false +precision=2 +scale=1.0 +description=null +estbilizationDelay=0 +maxSpeed=10.0 +resolution=NaN +startRetries=1 +minValue=-10.0 +unit=mm +defaultSpeed=1.0 +sign_bit=0 +monitorByPosition=false +minSpeed=0.1 diff --git a/devices/m2.properties b/devices/m2.properties new file mode 100644 index 0000000..d9ecd30 --- /dev/null +++ b/devices/m2.properties @@ -0,0 +1,17 @@ +#Tue May 14 10:37:17 CEST 2024 +offset=0.0 +maxValue=10.0 +rotation=false +precision=2 +scale=1.0 +description=null +estbilizationDelay=0 +maxSpeed=10.0 +resolution=NaN +startRetries=1 +minValue=-10.0 +unit=mm +defaultSpeed=1.0 +sign_bit=0 +monitorByPosition=false +minSpeed=0.1 diff --git a/devices/p1.properties b/devices/p1.properties new file mode 100644 index 0000000..0ea0ce5 --- /dev/null +++ b/devices/p1.properties @@ -0,0 +1,11 @@ +#Tue May 14 10:37:17 CEST 2024 +minValue=0.0 +unit=mm +offset=0.0 +maxValue=1000.0 +rotation=false +precision=-1 +sign_bit=0 +scale=1.0 +description=null +resolution=NaN diff --git a/devices/src1.properties b/devices/src1.properties new file mode 100644 index 0000000..6342906 --- /dev/null +++ b/devices/src1.properties @@ -0,0 +1,25 @@ +#Tue May 14 10:46:48 CEST 2024 +spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=NaN +spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=Temperature +invert=false +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=true +roiY=0 +roiX=0 +transpose=false diff --git a/devices/src2.properties b/devices/src2.properties new file mode 100644 index 0000000..31b7cea --- /dev/null +++ b/devices/src2.properties @@ -0,0 +1,25 @@ +#Tue May 14 10:46:48 CEST 2024 +spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=NaN +spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=Grayscale +invert=false +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=true +roiY=0 +roiX=0 +transpose=false diff --git a/script/archiver/short_term_archiver.py b/script/archiver/short_term_archiver.py new file mode 100644 index 0000000..d04ff44 --- /dev/null +++ b/script/archiver/short_term_archiver.py @@ -0,0 +1,96 @@ +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/" + +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) + channel = channel.replace(":", "_") #FILENAMES DO NOT SUPPORT : + return path + "/"+ channel + ".txt" + + + +if "stop_short_term_archiver" in globals(): + stop_short_term_archiver() + +def _log(msg): + print msg + log(msg) + + +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) + #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) + + + """ + class Timestamp(Readable): + def read(self): + timestamp = ch.takeTimestamped().timestamp + return timestamp + timestamp = Timestamp() + devices = (ch, timestamp) + if monitored: + mscan(channel, devices, take_initial=True, display=False, keep=False, tag=channel) + else: + tscan(devices, -1, interval*100, display=False, keep=False, tag=channel) + """ + + except Exception as ex: + _log("ERROR: " + str( sys.exc_info()[1])) + traceback.print_exc() + finally: + _log("Exit: " + str(channel)) + + +short_term_archiver_cfg = {} +short_term_archiver_tasks=[] + +def start_short_term_archiver(metadata=False): + global short_term_archiver_cfg + global short_term_archiver_tasks + 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()]) + +def wait_short_term_archiver(): + global short_term_archiver_tasks + join(short_term_archiver_tasks) + +def stop_short_term_archiver(): + global short_term_archiver_tasks + print "Stopping Short Term Archiver" + for task in short_term_archiver_tasks: + try: + task.cancel(True) + except: + pass + +try: + start_short_term_archiver() + wait_short_term_archiver() +finally: + stop_short_term_archiver() \ No newline at end of file diff --git a/script/config/A_RF_RFStations_BT_HVMOD.config b/script/config/A_RF_RFStations_BT_HVMOD.config new file mode 100644 index 0000000..97e8295 --- /dev/null +++ b/script/config/A_RF_RFStations_BT_HVMOD.config @@ -0,0 +1,35 @@ +#PVs from the RF Booster / Teststand HV Modulator VME IOC +################################################################### +ABORF-A0:FirstError None None Monitor +ABORF-CAV0:Vcav 1 10 150 +ABORF-A0-D50W:Pi 1 10 600 +ABORF-A0-D50W:Pi.EGU None None Monitor +ABORF-A0-D50W:Pi-C 1 10 600 +ABORF-A0-D50W:Pi-C.EGU None None Monitor +ABORF-A0-D50W:Pr-C 1 10 600 +ABORF-A0-D50W:Pr-C.EGU None None Monitor +ABORF-A0-AMLP:Vlim-R 6 30 600 +ABORF-A0-AMLP:Vlim-R.EGU None None Monitor +ABORF-A0:ARCS None None Monitor +ABORF-WG0-CO1:Pki 1 10 600 +ABORF-WG0-CO1:Pki.EGU None None Monitor +ABORF-WG0-CO1:Pki-C 1 10 600 +ABORF-WG0-CO1:Pki-C.EGU None None Monitor +ABORF-WG0-CO1:Pkr 1 10 600 +ABORF-WG0-CO1:Pkr.EGU None None Monitor +ABORF-WG0-CO1:Pkr-C 1 10 600 +ABORF-WG0-CO1:Pkr-C.EGU None None Monitor +ABORF-A0-HVPS:I 1 10 600 +ABORF-A0-HVPS:I.EGU None None Monitor +ABORF-A0-FIL:I 1 10 600 +ABORF-A0-FIL:I.EGU None None Monitor +ABORF-A0-MOD:I 1 10 600 +ABORF-A0-MOD:I.EGU None None Monitor +ABORF-A0-IPS1:V 1 10 600 +ABORF-A0-IPS1:V.EGU None None Monitor +ABORF-CAV0-CLRK:FlowPr 1 10 600 +ABORF-CAV0-CLRK:FlowPr.EGU None None Monitor +ABORF-CAV0-CLRK:ValvPos 1 10 600 +ABORF-CAV0-CLRK:ValvPos.EGU None None Monitor +ABORF-CIR0TCU:COIL_CURRENT 1 10 600 +ABORF-CIR0TCU:COIL_CURRENT.EGU None None Monitor diff --git a/script/config/A_RF_RFStations_TS_CCS.config b/script/config/A_RF_RFStations_TS_CCS.config new file mode 100644 index 0000000..961a02e --- /dev/null +++ b/script/config/A_RF_RFStations_TS_CCS.config @@ -0,0 +1,82 @@ +#PVs from the RF Teststand Cooling PLC +################################################################### +#mbbi +ATSRF-CAVR:EndDiscIn-Water-Flowswitch1 None None Monitor +ATSRF-CAVR:EndDiscIn-Water-Flowswitch2 None None Monitor +ATSRF-CAVR:EndDiscOut-Water-Flowswitchw1 None None Monitor +ATSRF-CAVR:EndDiscOut-Water-Flowswitchw2 None None Monitor +ATSRF-CAVR:Wedge-Water-Flowswitch None None Monitor +ATSRF-CAVR:TuningPlunger-Water-Flowswitch None None Monitor +ATSRF-CAVR:TopWG-Water-Flowswitch None None Monitor +ATSRF-CAVR:LeftWG-Water-Flowswitch None None Monitor +ATSRF-CAVR:RightWG-Water-Flowswitch None None Monitor +ATSRF-CAVR:Coupler-Water-Flowswitch None None Monitor +ATSRF-CAVR:BodyRidge1-Water-Flowswitch None None Monitor +ATSRF-CAVR:BodyRidge2-Water-Flowswitch None None Monitor +ATSRF-CAVR:Body-Water-Flowswitch1 None None Monitor +ATSRF-CAVR:Body-Water-Flowswitch2 None None Monitor +ATSRF-CAVR:Body-Water-Flowswitch3 None None Monitor +ATSRF-CAVR:Coupler-Plunger-Water-Flowswitch None None Monitor +ATSRF-CAVR:Coupler-Air-Pressureswitch None None Monitor +################################################################### +#bi +ATSRF-CAV:Water-Leak None None Monitor +ATSRF-CAV:Vacuum-SumILK None None Monitor +ATSRF-CAVR:Inlet-Watervalve-Open None None Monitor +ATSRF-CAVR:Inlet-Valvevalve-Closed None None Monitor +ATSRF-CAVR:Outlet-Watervalve-Open None None Monitor +ATSRF-CAVR:Outlet-Watervalve-Closed None None Monitor +ATSRF-CAVR:Inlet-Watervalve None None Monitor +ATSRF-CAVR:Outlet-Watervalve None None Monitor +ATSRF-CAVR:Outlet-Airvalve None None Monitor +################################################################### +#ai +ATSRF-CAVR:Water-Flow None 60 3600 +ATSRF-CAVR:Water-Flow.EGU None None Monitor +ATSRF-CAVR:Water-Flow.HIHI None None Monitor +ATSRF-CAVR:Water-Flow.LOLO None None Monitor +# +ATSRF-CAVR:Coupler-Air-Flow None 60 3600 +ATSRF-CAVR:Coupler-Air-Flow.EGU None None Monitor +ATSRF-CAVR:Coupler-Air-Flow.HIHI None None Monitor +ATSRF-CAVR:Coupler-Air-Flow.LOLO None None Monitor +# +ATSRF-CAVR:Water-Pressure-Inlet None 60 3600 +ATSRF-CAVR:Water-Pressure-Inlet.EGU None None Monitor +ATSRF-CAVR:Water-Pressure-Inlet.HIHI None None Monitor +ATSRF-CAVR:Water-Pressure-Inlet.LOLO None None Monitor +# +ATSRF-CAVR:Water-Pressure-Outlet None 60 3600 +ATSRF-CAVR:Water-Pressure-Outlet.EGU None None Monitor +ATSRF-CAVR:Water-Pressure-Outlet.HIHI None None Monitor +ATSRF-CAVR:Water-Pressure-Outlet.LOLO None None Monitor +# +ATSRF-CAVR:Inlet-Watervalve-Temp None 60 3600 +ATSRF-CAVR:Inlet-Watervalve-Temp.EGU None None Monitor +ATSRF-CAVR:Inlet-Watervalve-Temp.HIHI None None Monitor +ATSRF-CAVR:Inlet-Watervalve-Temp.LOLO None None Monitor +# +ATSRF-CAVR:Outlet-Watervalve-Temp None 60 3600 +ATSRF-CAVR:Outlet-Watervalve-Temp.EGU None None Monitor +ATSRF-CAVR:Outlet-Watervalve-Temp.HIHI None None Monitor +ATSRF-CAVR:Outlet-Watervalve-Temp.LOLO None None Monitor +# +ATSRF-CAVR:Wedge-Water-Temp None 60 3600 +ATSRF-CAVR:Wedge-Water-Temp.EGU None None Monitor +ATSRF-CAVR:Wedge-Water-Temp.HIHI None None Monitor +ATSRF-CAVR:Wedge-Water-Temp.LOLO None None Monitor +# +ATSRF-CAVR:Tuner-Water-Temp None 60 3600 +ATSRF-CAVR:Tuner-Water-Temp.EGU None None Monitor +ATSRF-CAVR:Tuner-Water-Temp.HIHI None None Monitor +ATSRF-CAVR:Tuner-Water-Temp.LOLO None None Monitor +# +ATSRF-CAVR:Coupler-Water-Temp None 60 3600 +ATSRF-CAVR:Coupler-Water-Temp.EGU None None Monitor +ATSRF-CAVR:Coupler-Water-Temp.HIHI None None Monitor +ATSRF-CAVR:Coupler-Water-Temp.LOLO None None Monitor +# +ATSRF-CAVR:Coupler-Air-Temp None 60 3600 +ATSRF-CAVR:Coupler-Air-Temp.EGU None None Monitor +ATSRF-CAVR:Coupler-Air-Temp.HIHI None None Monitor +ATSRF-CAVR:Coupler-Air-Temp.LOLO None None Monitor diff --git a/script/local.groovy b/script/local.groovy new file mode 100644 index 0000000..eef7106 --- /dev/null +++ b/script/local.groovy @@ -0,0 +1,3 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.groovy +/////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/script/local.js b/script/local.js new file mode 100644 index 0000000..e2eeaad --- /dev/null +++ b/script/local.js @@ -0,0 +1,4 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.js +/////////////////////////////////////////////////////////////////////////////////////////////////// + diff --git a/script/local.py b/script/local.py new file mode 100644 index 0000000..66f811d --- /dev/null +++ b/script/local.py @@ -0,0 +1,127 @@ +################################################################################################### +# Deployment specific global definitions - executed after startup.py +################################################################################################### + + +import java.time.format.DateTimeFormatter as DateTimeFormatter +import java.time.Instant as Instant +import java.time.LocalDateTime as LocalDateTime +import java.time.ZoneOffset as ZoneOffset +import org.jfree.chart.axis.DateAxis as DateAxis +import traceback +import ch.psi.pshell.epics.InvalidValueAction as InvalidValueAction + +#with Channel("ABORF-A0-HVPS:I", monitored=False) as ch: +# print ch.read() + +class Channel: + def __init__(self,channel_name, monitored, polling): + self.channel_name=channel_name + self.monitored= monitored + self.polling = polling + + def __enter__(self): + self.channel=GenericChannel(self.channel_name,self.channel_name, True, InvalidValueAction.None) + self.channel.setMonitored(self.monitored) + self.channel.setPolling(self.polling) + self.channel.initialize() + return self.channel + + def __exit__(self, exc_type, exc_val, exc_tb): + self.channel.close() + + +#timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS") +timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS") + +def get_time_str(timestamp): + #instant = Instant.ofEpochMilli(timestamp) + #currentTime = LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault()) + #return currentTime.format(timeFormatter); + return str(timestamp) + +ITEM_SEPARATOR = "; " + +def init_archiver(f, cls = None): + if cls is None: + cls = "java.lang.Double" + f.write ("#Timestamp" + ITEM_SEPARATOR + "Value" + ITEM_SEPARATOR + "\n") + f.write ("#java.lang.Long" + ITEM_SEPARATOR + Class.getName(cls) + ITEM_SEPARATOR + "\n") + f.flush() + +def write_archive(f, timestamp, value): + v = get_time_str(timestamp) + ITEM_SEPARATOR+ str(value) + ITEM_SEPARATOR + f.write (v+ "\n") + f.flush() + + +class ChannelListener (DeviceListener): + def __init__(self, f): + self.f = f + + def onCacheChanged(self, ch, value, former, timestamp, valueChange): + if self.f.tell() == 0: + cls=ch.getElementType() + init_archiver(self.f, cls) + write_archive(self.f, timestamp, value) + + + +def parse_archiver_config(metadata=True, file_name=None): + ret = {} + if not file_name: + for file_name in os.listdir(expand_path("{script}/config")): + 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))) + else: + with open(file_name, 'r') as f: + for line in f: + line = line.strip() + if line.startswith('#'): + continue # Skip lines starting with '#' + parts = line.split() # Split the line by whitespace + if len(parts) >= 4: + def adjust(v): + try: + if v=="None": + return False + elif v=="Monitor": + return True + else: + return int(v) + except Exception as e: + print (e) + return None + name = parts[0] + if metadata or not "." in name: + v1 = adjust(parts[1]) + v2 = adjust(parts[2]) + v3 = adjust(parts[3]) + ret[name] = [v1, v2, v3] + return ret + + +def parse_short_term_archiver_config(metadata): + ret = parse_archiver_config(metadata) + return {name:v[2] for name,v in ret.items()} + + + + +def plot_channel(channel, day, title=None): + path="/"+day+"/archiver|/" + channel.replace(":", "_") + data =load_data(path) + tm = [i[0]for i in data] + val = [i[1]for i in data] + p=plot(val, name=channel + " [" + day + "]", xdata=tm, title=title)[0] + axis = DateAxis(None) + axis.setTickLabelPaint(p.getAxisTextColor()) + p.getChart().getXYPlot().setDomainAxis(axis) + + +#channels = parse_short_term_archiver_config(False) +#for c in channels.keys(): +# print c, caget(c) + + diff --git a/script/test/test_channel.py b/script/test/test_channel.py new file mode 100644 index 0000000..d7e20bc --- /dev/null +++ b/script/test/test_channel.py @@ -0,0 +1,55 @@ +import java.time.format.DateTimeFormatter as DateTimeFormatter +import java.time.Instant as Instant +import java.time.LocalDateTime as LocalDateTime +import java.time.ZoneOffset as ZoneOffset + +#with Channel("ABORF-A0-HVPS:I", monitored=False) as ch: +# print ch.read() + +class Channel: + def __init__(self,channel_name, monitored, polling): + self.channel_name=channel_name + self.monitored= monitored + self.polling = polling + + def __enter__(self): + self.channel=GenericChannel(self.channel_name,self.channel_name) + self.channel.setMonitored(self.monitored) + self.channel.setPolling(self.polling) + self.channel.initialize() + return self.channel + + def __exit__(self, exc_type, exc_val, exc_tb): + self.channel.close() + + +timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS") + +def get_time_str(timestamp): + instant = Instant.ofEpochMilli(timestamp) + currentTime = LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault()) + return currentTime.format(timeFormatter); + + +def write_archive(f, timestamp, value): + print f + " " + get_time_str(timestamp) + " " + str(value) + + +class ChannelListener (DeviceListener): + def onCacheChanged(self, ch, value, former, timestamp, valueChange): + write_archive(ch.name, timestamp, value) + +val=None +with Channel("ABORF-A0-HVPS:I", True, 0) as ch: + #val = ch.update() + #val=ch.takeTimestamped() + #write_archive(ch.name, val.timestamp, val.value) + channel_listener = ChannelListener() + ch.addListener(channel_listener) + ch.update() + val=ch.take() + time.sleep(10.0) + + + + \ No newline at end of file diff --git a/script/test/test_plot b/script/test/test_plot new file mode 100644 index 0000000..479a8cd --- /dev/null +++ b/script/test/test_plot @@ -0,0 +1,16 @@ +import org.jfree.chart.axis.DateAxis as DateAxis + + +def plot_channel(channel, day, title=None): + path=day+"/archiver|/" + channel.replace(":", "_") + print(path) + data =load_data(path) + tm = [i[0]for i in data] + val = [i[1]for i in data] + p=plot(val, name=channel + " [" + day + "]", xdata=tm, title=title)[0] + axis = DateAxis(None) + axis.setTickLabelPaint(p.getAxisTextColor()) + p.getChart().getXYPlot().setDomainAxis(axis) + + +plot_channel("ATSRF-CAVR:Water-Pressure-Inlet","20240514")