Faceplate

18 views
Skip to first unread message

Rubén Martí

unread,
Nov 11, 2011, 4:01:58 AM11/11/11
to FBDK
Hi Chirs,

I am working with FBDK and my teacher want to modify the faceplate of
PID, is it possible?is there exist any manual to create new figures
like your tank or faceplate.

Best regards.

James Christensen

unread,
Nov 11, 2011, 10:00:23 AM11/11/11
to fb...@googlegroups.com
Well... it depends on how brave you are. You would have to be a fairly
experienced Java programmer and familiar with GUI programming using
the Java Swing classes. If so, here are the steps to do it (IDE such
as Eclipse or NetBeans recommended - be sure to put fbrt.jar on the
classpath).

1. Modify the attached FBFaceplate.java as necessary for the new
display, save and compile it.
2. Move the new FBFaceplate.class file to the FBDK/lib/fb/rt/process
subdirectory.

To do a different tank rendering, you would do the following:

1. Add a new enumerated value, say TANK, to VSTYLE and compile it (The
new VSTYLE.class will be in FBDK/lib/fb/rt/mva).
2. Modify the attached FBMechanismView.java by adding a VSTYLE.TANK
case to the paintView(Graphics, int, int) method which invokes a new
paintTank(Graphics, int, int) method.
3. Compile and copy the new FBMechanismView.class file to FBDK/lib/fb/rt/mva.

Not easy - recommended only for the experienced and brave.
--
Best regards,
Jim Christensen

FBFaceplate.java
FBMechanismView.java

Rubén Martí

unread,
Nov 28, 2011, 7:44:32 AM11/28/11
to FBDK
Hi Christensen,

Thank you for your help, making this change in your FBFaceplate.java:

/** The set point slider. */
//public JSlider sp = new JSlider(0, 100);
public FBBar sp = new FBBar();

we are obtaining the following errors:

Exception in thread "Thread-10" java.lang.NoSuchFieldError: sp
at fb.rt.process.FACEPLATE.service_INIT(FACEPLATE.java:97)
at fb.rt.INITEvent.serviceEvent(INITEvent.java:36)
at fb.rt.EventOutput.serviceEvent(EventOutput.java:80)
at fb.rt.mva.XABS_VIEW.service_INIT(XABS_VIEW.java:93)
at fb.rt.INITEvent.serviceEvent(INITEvent.java:36)
at fb.rt.EventOutput.serviceEvent(EventOutput.java:80)

is it necessary to modify another file? is it necessary to add/modify
a file between FBFaceplate.java and FACEPLATE.java ?

On the other hand, do you mind borrowing me FBBar.java to understand
this kind of relation between graphic code in java and FunctionBlock
java code.

Bests regards.

James Christensen

unread,
Nov 28, 2011, 12:55:50 PM11/28/11
to fb...@googlegroups.com
The problem is that you can't arbitrarily replace the contents of a
public field (sp) with an incompatible class. FBBar does not have the
same behaviors or interface as JSlider. If all you want to do is
change the way the slider is painted, you should be able (in the
FBFaceplate constructor) to give the JSlider (sp) a new UI by saying
sp.setUI(new MySliderUI(sp)). I haven't tried this, but maybe
MySliderUI could be a subclass of javax.swing.plaf.BasicSliderUI with
just new paintTrack(...), paintThumb(...), getMinimumThumbSize() and
getMaximumThumbSize() methods.

Attached is the FBBar.java code.


--
Best regards,
Jim Christensen

FBBar.java
Reply all
Reply to author
Forward
0 new messages