6767import org .phoebus .ui .dialog .DialogHelper ;
6868import org .phoebus .ui .dialog .ExceptionDetailsErrorDialog ;
6969
70+ import java .text .SimpleDateFormat ;
7071import java .util .ArrayList ;
7172import java .util .Arrays ;
73+ import java .util .Date ;
7274import java .util .HashMap ;
7375import java .util .LinkedHashMap ;
7476import java .util .List ;
@@ -265,6 +267,40 @@ public void newSnapshot(Node configurationNode) {
265267 });
266268 });
267269 }
270+
271+ public String getValueVType (String pvEntry , List <SnapshotItem > entries ){
272+ String valueOutput ="" ;
273+
274+ System .out .println ("length " +entries .size ());
275+ for (SnapshotItem e : entries ) {
276+ System .out .println ("name " +e .getConfigPv ().getPvName ());
277+ if (e .getConfigPv ().getPvName ().equals (pvEntry )){
278+ VType newValue =e .getValue ();
279+ if (newValue instanceof VNumber ) {
280+ Number newVType = ((VNumber ) newValue ).getValue ();
281+ valueOutput =newVType .toString ();
282+ System .out .println ("VNumber " +valueOutput );
283+ return valueOutput ;
284+ } else if (newValue instanceof VString ) {
285+ String newVType = ((VString ) newValue ).getValue ();
286+ valueOutput =newVType .toString ();
287+ System .out .println ("VString " +valueOutput );
288+ return valueOutput ;
289+ } else if (newValue instanceof VStringArray ) {
290+ List <String > newVType =((VStringArray ) newValue ).getData ();
291+ valueOutput =newVType .toString ();
292+ System .out .println ("VStringArray " +valueOutput );
293+ return valueOutput ;
294+ } else if (newValue instanceof VEnum ) {
295+ VEnum newVType = (VEnum ) newValue ;
296+ valueOutput =newVType .getValue ().toString ();
297+ System .out .println ("VEnum " +valueOutput );
298+ return valueOutput ;
299+ }
300+ }
301+ }
302+ return valueOutput ;
303+ }
268304
269305 @ FXML
270306 @ SuppressWarnings ("unused" )
@@ -286,6 +322,37 @@ private void takeSnapshot() {
286322 snapshots .set (0 , snapshot );
287323 List <TableEntry > tableEntries = createTableEntries (snapshots .get (0 ));
288324 snapshotTable .updateTable (tableEntries , snapshots , showLiveReadbackProperty .get (), false , showDeltaPercentage );
325+
326+ SimpleDateFormat formater = null ;
327+ Date now = new Date ();
328+ formater = new SimpleDateFormat ("yy-MM-dd" );
329+ String defaultTitle ="" ;
330+ if (!Preferences .default_title_snapshot_format .equals ("" )) {
331+ String [] formatTitle =Preferences .default_title_snapshot_format .split ("_" );
332+ for (int index = 0 ; index < formatTitle .length ; index ++) {
333+ switch (formatTitle [index ]) {
334+ case "<date>" :
335+ if (!Preferences .default_title_snapshot_date_format .equals ("" )){
336+ formater = new SimpleDateFormat (Preferences .default_title_snapshot_date_format );
337+ defaultTitle +=defaultTitle +formater .format (now );
338+ }
339+ break ;
340+ case "<pv1>" :
341+ defaultTitle +=getValueVType (Preferences .default_title_snapshot_pv1 ,entries );
342+ break ;
343+ case "<pv2>" :
344+ defaultTitle +=getValueVType (Preferences .default_title_snapshot_pv2 ,entries );
345+ break ;
346+ default :
347+ System .out .println ("nothing" );
348+ break ;
349+ }
350+ if (index <formatTitle .length -1 )
351+ defaultTitle +="_" ;
352+ }
353+ }
354+ snapshotNameProperty .set (defaultTitle );
355+
289356 })
290357 );
291358 }
0 commit comments