@@ -65,11 +65,6 @@ public class WidgetRuntime<MW extends Widget> {
6565 */
6666 public final static Logger logger = Logger .getLogger (WidgetRuntime .class .getPackageName ());
6767
68- /**
69- * Extension point for contributing custom widget runtime
70- */
71- public static final String EXTENSION_POINT = "org.csstudio.display.builder.runtime.widgets" ;
72-
7368 /**
7469 * The widget handled by this runtime
7570 */
@@ -83,7 +78,7 @@ public class WidgetRuntime<MW extends Widget> {
8378 /**
8479 * start() involves background jobs to start script support etc.
8580 * This latch indicates that they have completed
86- * and lazily set variables (action_scripts, writable_pvs, ..)
81+ * and lazily set variables (action_scripts, writable_pvs, ... )
8782 * can now be used.
8883 */
8984 private volatile CountDownLatch started = new CountDownLatch (1 );
@@ -237,7 +232,8 @@ public void start() {
237232 try {
238233 final String expanded = MacroHandler .replace (widget .getMacrosOrProperties (), pv_name );
239234 final RuntimePV pv = PVFactory .getPV (expanded );
240- action_pvs .put (expanded , pv );
235+ String cleanPvName = getCleanPvName (expanded );
236+ action_pvs .put (cleanPvName , pv );
241237 addPV (pv , true );
242238 } catch (Exception ex ) {
243239 logger .log (Level .WARNING , widget + " cannot start action to write PV '" + pv_name + "'" , ex );
@@ -258,6 +254,26 @@ public void start() {
258254 started .countDown ();
259255 }
260256
257+ /**
258+ * Get PV Name without initialisation value
259+ */
260+ private String getCleanPvName (String expandedName ) {
261+
262+ String nameToCheck = expandedName ;
263+ // For local PV,
264+ if (nameToCheck .startsWith ("loc://" )) {
265+ // strip optional data type ...
266+ int sep = nameToCheck .indexOf ('<' );
267+ if (sep > 0 )
268+ nameToCheck = nameToCheck .substring (0 , sep );
269+ // or initializer ...
270+ sep = nameToCheck .indexOf ('(' );
271+ if (sep > 0 )
272+ nameToCheck = nameToCheck .substring (0 , sep );
273+ }
274+ return nameToCheck ;
275+ }
276+
261277 /**
262278 * Are Scripts or Rules defined for Widget?
263279 */
@@ -395,31 +411,20 @@ public void writePrimaryPV(final Object value) {
395411 */
396412 public void writePV (final String pv_name , final Object value ) throws Exception {
397413 final String expanded = MacroHandler .replace (widget .getMacrosOrProperties (), pv_name );
398- String name_to_check = expanded ;
399- // For local PV,
400- if (name_to_check .startsWith ("loc://" )) {
401- // strip optional data type ...
402- int sep = name_to_check .indexOf ('<' );
403- if (sep > 0 )
404- name_to_check = name_to_check .substring (0 , sep );
405- // or initializer ..
406- sep = name_to_check .indexOf ('(' );
407- if (sep > 0 )
408- name_to_check = name_to_check .substring (0 , sep );
409- }
414+ String nameToCheck = getCleanPvName (expanded );
410415 awaitStartup ();
411416 final Map <String , RuntimePV > safe_pvs = writable_pvs ;
412417 if (safe_pvs != null ) {
413- final RuntimePV pv = safe_pvs .get (name_to_check );
418+ final RuntimePV pv = safe_pvs .get (nameToCheck );
414419 if (pv != null ) {
415420 try {
416421 pv .write (value );
417422 } catch (final Exception ex ) {
418- throw new Exception ("Failed to write " + value + " to PV " + name_to_check , ex );
423+ throw new Exception ("Failed to write " + value + " to PV " + nameToCheck , ex );
419424 }
420425 }
421426 else {
422- throw new Exception ("Unknown PV '" + pv_name + "' (expanded: '" + name_to_check + "')" );
427+ throw new Exception ("Unknown PV '" + pv_name + "' (expanded: '" + nameToCheck + "')" );
423428 }
424429 }
425430 }
0 commit comments