Setup
Environment
- Effectively, you can only develop MPS History Server inside Eclipse on lcls-builder.
- Check out the CVS module physics/mps/mpshist into your workspace
- From now on, the root of project is referred to as $MPSHIST_ROOT
Dependencies
- ezJCA (version R0-0-10)
- javainterfaces (current version)
- MPS Config
- xal4lcls
- ext.jar (current version)
- xal.jar (current version)
Test inside Eclipse
- Select $MPSGUI_ROOT/src/edu.stanford.slac.mpshist/MpsHistManager
- Right-click => select Run As... => Java Application
- If you run the app for the first time, it should fail
- Go to Run in the Window menu
- Select "Open Run Dialog..."
- Select "MpsHistManager" in the window on the left
- Select the "Arguments" tab
- Enter the following arguments:
/usr/local/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/XYZ/mpsdb.sqlite3 password
- XYZ - the current Config version (caget IOC:BSY0:MP01:DBVERS)
- password - the current password (see also #Launch Script)
in the "Program arguments" area.
- Press "Run"
- Note: to actually receive messages, you have to stop the production server (see #Starting and Stopping)
Development
Overview
Launch Script
- mpshist under $MPSHIST_ROOT
- Gets the current version of the Config DB
- Assembles the path to it
- Sets up the CLASSPATH
- Runs MpsHistManager and tells the process to write all message into a log file
Classes and Functions
edu.stanford.slac.mps.epics.ControlSystem
- Monitors current Macro state numbers from IOC:BSY0:MP01:TTBLST.VALA
- Bypasses faults to a value for a time duration
- Monitors bypassed faults and end times
- Given a fault name, gets current state, type, and timestamp
of the fault - Given a PV, gets beam rate names (MPS and actual)
- Translates between EPICS and Java time
edu.stanford.slac.mps.jdbc.JDBCMonitor
- Loads all data from Config/Logic DB
- Config DB URL prefix: jdbc:sqlite:/usr/local/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/
- Logic DB URL prefix: jdbc:sqlite:/usr/local/lcls/epics/iocTop/MachineProtection/mpsConfiguration/algorithm/
- Checks periodically for new versions
- Current Config DB version is stored in IOC:BSY0:MP01:DBVERS
- Current Logic DB version is stored in IOC:BSY0:MP01:ALGRNAME
edu.stanford.slac.mps.jdbc.config.ConfigDB
- Singleton
- Serves as a facade to information about faults
- SQL queries are in the file sqlite.properties in the package edu.stanford.slac.mps.jdbc.config
edu.stanford.slac.mps.jdbc.logic.LogicDB
- Singleton
- Serves as a facade to information about Macros (and states), ignore conditions, current MacroStates
- SQL queries are in the file sqlite.properties in the package edu.stanford.slac.mps.jdbc.logic
Release with Eclipse
- Add a note in $MPSGUI_ROOT/RELEASE_NOTES
- Increment the tag version accordingly
- Commit to CVS
- Tag with mpsconfig-R#-#-#
- Check out the tagged version into production
cd $PHYSICS_TOP/release cvs co -r mpsconfig-R#-#-# -d mpsconfig-R#-#-# physics/mps/mpsconfig
- Select File => New Java project => Create project from existing source
- Select $PHYSICS_TOP/release/mpsconfig-R#-#-#
- Name the project mpsconfig-R#-#-#
- Press "Finish"
- Right-click on the new project mpsconfig-R#-#-# => Export...
- Select Java => JAR file
- Check mpsconfig-R#-#-# in "Resources to export"
- Check "Export generated class files and resources"
- As the export destination, type (and/or select)
$PHYSICS_TOP/release/mpsconfig-R#-#-#/jar/mpsconfig.jar
- Press "Finish"
- Move the symbolic link
cd $PHYSICS_TOP/ rm -rf mpsconfig; ln -s release/mpsconfig-R#-#-# mpsconfig
- Launch MPS GUI from lclshome
- MPS Global => MPS GUI...
- MPS Global => MPS CUD...
MPS History Server (mpshist) is a server application for saving MPS messages to Oracle.
Starting and Stopping
- Only one MPS History Server is active at any time
- To start a new server, you must login as laci on lcls-daemon2
/etc/rc3.d/S99st.mpshist start
- To stop a production server, type
/etc/rc3.d/S99st.mpshist stop
#Programmer's Guide
#User's Guide
#References
Programmer's Guide
MPS Config
Oracle
JDBC Url
jdbc:oracle:thin:MPS_HISTORY/%s@slac-oracle02.slac.stanford.edu:1521:SLACDEV jdbc:oracle:thin:MPS_HISTORY/%s@slac-oracle04.slac.stanford.edu:1521:MCCQA
where %s = the current password.
Schema
Procedures
BEGIN MPS_HISTORY.MPS_HISTORY_PKG.DML_%s1 (%s2); END;
where
%s1 = table name
%s2 = CSVs in the same order as in the #Schema (top-to-bottom = left-to-right); ignore the ID column; replace the FKs with enums from the referenced table.
Message Types
//#define HISTORY_SUPER_TIMESTAMP_SECPASTEPOCH(_pointerToHistoryData) //#define HISTORY_SUPER_TIMESTAMP_NSEC_PULSEID(_pointerToHistoryData) //#define HISTORY_SUPER_TIMESLOT(_pointerToHistoryData) //#define HISTORY_SUPER_TYPE(_pointerToHistoryData) //#define HISTORY_SUPER_ID(_pointerToHistoryData) //#define HISTORY_SUPER_OLD_VALUE(_pointerToHistoryData) //#define HISTORY_SUPER_NEW_VALUE(_pointerToHistoryData)
- Beam destination: Beam destination changed from PREVIOUS DESTINATION_NAME to CURRENT DESTINATION_NAME
- Beam rate: Beam rate rate after DEVICE_NAME changed from PREVIOUS RATE_NAME to CURRENT RATE_NAME
- Fault: DEVICE_NAME FAULT_NAME changed from PREV_STATE to CURR_STATE
- Bypass time: DEVICE_NAME FAULT_NAME is bypassed for BYPASS_TIME_IN_SECONDS sec OR DEVICE_NAME FAULT_NAME bypass had cleared
- Bypass value: DEVICE_NAME FAULT_NAME changed from PREV_VALUE to CURR_VALUE
User's Guide
Scripts
Check nohup.out, /u1/lcls/tools/mpsHistoryServer/mpshist.log
You have to run mpshist on lcls-daemon2 as laci
/etc/rc3.d/S99st.mpshist start
To stop mpshist
/etc/rc3.d/S99st.mpshist stop
Troubleshooting
Is the server running?
To test whether the Server is running, go as laci to lcls-daemon2
ps -ef | grep mpshist
Is the server working?
To test whether the server is working, use POSI:EP02:400:MTLM_LGC_BYPV, e.g.
caput POSI:EP02:400:MTLM_LGC_BYPV 1 //wait 10 seconds caput POSI:EP02:400:MTLM_LGC_BYPV 0
Verify in the MpsGui (not in cmlog).
Check if the MPS client connects
iocegr@lcls-builder$ iocConsole ioc-bsy0-mp01 /* Be very careful here */ Cexp@ioc-bsy0-mp01>printHistoryServerList() 172.27.8.41:30001 Time-to-live: 20 Is Connected: Yes 0x00000000 (0)
CTRL-a then d to exit
Note: Wait > 20 seconds before restarting the history server.
Cmlog
The cmlog facility is "MPS History".
References
http://java.sun.com/docs/books/tutorial/networking/ (esp. sockets and datagrams)
http://darksleep.com/player/JavaAndUnsignedTypes.html (java types from/to bytes)
MPS Fault Logging Statistic Reports