Source code: diagapplet/diagappletMain.java
1 package diagapplet;
2
3 //***************************************************************************
4 // diagapplet.java: Applet
5 //
6 //***************************************************************************
7
8 import java.io.*;
9 import java.awt.*;
10 import java.awt.event.*;
11 import java.applet.*;
12 import java.util.*;
13 import java.net.URL;
14 import java.net.URLConnection;
15 import diagapplet.CodeGen.*;
16 import diagapplet.plotter.*;
17 import diagapplet.plotter.dplotter;
18 import diagapplet.utils.*;
19 import diagapplet.CodeGen.EnumTypeInfo;
20 import diagapplet.CodeDisplayPanel;
21 import diagapplet.utils.StandAloneApplet;
22 import rcs.RCS_VERSION;
23 import rcs.nml.*;
24 import rcs.utils.*;
25
26
27
28 //==============================================================================
29 // Main Class for applet diagapplet
30 //
31 //==============================================================================
32 public class diagappletMain extends StandAloneApplet implements Runnable, ActionListener, ItemListener, AdjustmentListener
33 {
34 static public int MIN_WIDTH = 700;
35 static public int MIN_HEIGHT = 600;
36 static public int MAX_WIDTH = 1000;
37 static public int MAX_HEIGHT = 1000;
38
39
40
41 public XAxisVarData x_axis_var_data=null;
42 public boolean updating_status = false;
43 static int thread_num = 0;
44 int modules_connected = 0;
45 Panel stateTablePanel = null;
46 private boolean universal_connect_denied = false;
47 private boolean universal_read_denied = false;
48 private boolean universal_write_denied = false;
49 Panel detailsPanel = null;
50 LayoutManager detailsPanelLayout = null;
51 boolean run_needed = true;
52 Hashtable auxBuffersHashtable = null;
53 String currentViewString = "Hierarchy";
54
55
56 LayoutManager stateTablePanelLayout = null;
57 Panel stateTableInnerPanel = null;
58 GridBagLayout stateTableInnerPanelLayout = null;
59 CodeDisplayPanel stateTableCodePanel = null;
60 Scrollbar stateTableCodePanelHorzScrollbar = null;
61 Scrollbar stateTableCodePanelVertScrollbar = null;
62 TextField stateTableInfoTextField = null;
63 Panel debugFlagPanel = null;
64 Panel debugFlagInnerPanel = null;
65 LayoutManager debugFlagPanelLayout = null;
66 GridBagLayout debugFlagInnerPanelLayout = null;
67 Checkbox nmlReadDebugCheckbox = null;
68 Checkbox nmlWriteDebugCheckbox = null;
69 Checkbox nmlConfigDebugCheckbox = null;
70 Checkbox diagappletDebugCheckbox = null;
71 Checkbox hierarchyPanelDebugCheckbox = null;
72 Checkbox plotterDebugCheckbox = null;
73 Checkbox codegenDebugCheckbox = null;
74 Checkbox moduleinfoDebugCheckbox = null;
75 Checkbox fileloaderDebugCheckbox = null;
76 Checkbox xdrDebugCheckbox = null;
77 Checkbox diagNMLmessageDictDebugCheckbox = null;
78 Checkbox diagNMLmsgDebugCheckbox = null;
79 Checkbox fastListPanelDebugCheckbox = null;
80 private boolean interrupt_connecting = false;
81 private boolean interrupt_loading = false;
82 private boolean is_loading_hierarchy = false;
83 private boolean cmd_stat_toggle = false;
84 public boolean reload_hierarchy_needed = false;
85 public boolean reconnect_needed = false;
86 public boolean first_repaint_occurred = false;
87 boolean repaint_needed = false;
88 boolean login_needed = false;
89 Panel codeGenerationPanel = null;
90 LayoutManager codeGenerationPanelLayout = null;
91 Panel codeGenerationInnerPanel = null;
92 Panel loginPanel = null;
93 LayoutManager loginPanelLayout =null;
94 Panel loginInnerPanel = null;
95 GridBagLayout loginInnerPanelLayout = null;
96 Label loginNameLabel = null;
97 Label loginPasswdLabel = null;
98 TextField loginNameTextField = null;
99 TextField loginPasswdTextField = null;
100 Button loginButton = null;
101 TextArea loginStatusTextArea = null;
102 boolean is_logging_on = false;
103 boolean is_connecting = false;
104 boolean interrupt_logon = false;
105 Checkbox thisModuleConnectedCheckbox = null;
106 Label moduleNewDataCountLabel = null;
107 Label moduleHostLabel = null;
108 TextField moduleHostTextField = null;
109 Label moduleCmdPortLabel = null;
110 TextField moduleCmdPortTextField = null;
111 Label moduleCmdBufferNumberLabel = null;
112 TextField moduleCmdBufferNumberTextField = null;
113 Label moduleStatPortLabel = null;
114 TextField moduleStatPortTextField = null;
115 Label moduleStatBufferNumberLabel = null;
116 TextField moduleStatBufferNumberTextField = null;
117
118 int total_cycles = 0;
119 long original_start_time_millis = 0;
120 int load_percent = 0;
121 int cycles_skipped = 0;
122 long last_cycle_time_millis = 0;
123 long current_time_millis = 0;
124 LoadPercentPanel loadPercentPanel = null;
125 Label loadPercentLabel = null;
126 CountButton stop_all_plotting_button = null;
127 long first_plot_start_time = 0;
128 Hashtable plot_tracker_hashtable = null;
129 Checkbox statPlotCheckbox = null;
130 Checkbox cmdPlotCheckbox = null;
131 Checkbox statMakeXAxisCheckbox = null;
132 Checkbox cmdMakeXAxisCheckbox = null;
133 Enumeration plot_track_enumeration = null;
134 Panel superChoicePanel = null;
135 GridBagLayout superChoicePanelLayout = null;
136 Panel choicePanel = null;
137 CardLayout choicePanelLayout = null;
138 Panel errlogPanel = null;
139 LayoutManager errlogPanelLayout = null;
140 Choice displayChoice = null;
141 dplotter sub_plotter = null;
142 Panel errlogInnerPanel = null;
143 GridBagLayout errlogInnerPanelLayout = null;
144 boolean force_update = false;
145 URLLoadInfoPanel m_loadingPanel = null;
146 int refreshTime_milliseconds = 100;
147 int HTTPport = 0;
148 int m_currentErrlogId = 0;
149 Panel m_errlogPanel = null;
150 Panel m_textFilePanel = null;
151 Panel m_graphPanel = null;
152 CountButton m_errlogButton = null;
153 CountButton m_textFileButton = null;
154 CountButton m_graphButton = null;
155 Panel m_switchPanel = null;
156 CountButton m_browseLocalButton = null;
157 int m_browseLocalButtonCount = 0;
158 boolean m_hierarchyLoadedOnce = false;
159 boolean m_readErrlog = false;
160 Checkbox m_readErrlogCheckbox = null;
161 CountList m_modifyVarList = null;
162 int m_modifyVarListCount = 0;
163 Panel m_findPanel = null;
164 Label m_findLabel = null;
165 TextField m_findTextField = null;
166 CountButton m_findButton = null;
167 CountButton m_quitButton = null;
168 int m_findButtonCount = 0;
169 Label m_modulesLabel = null;
170 Label m_cmdLabel = null;
171 Label m_statLabel = null;
172 Label m_cmdsAvailLabel = null;
173 Label m_cmdToSendLabel = null;
174 Label m_hierarchyFileLabel = null;
175 Checkbox m_connectedCheckbox = null;
176 Panel m_connectedPanel = null;
177 Panel m_topPanel = null;
178 Panel m_refreshTimePanel = null;
179 Panel m_modifyVarPanel = null;
180 Panel m_modifyVarTextPanel = null;
181 Panel m_modifyVarListPanel = null;
182 Label m_refreshTimeLabel = null;
183 Label m_modifyVarLabel = null;
184 Scrollbar m_refreshTimeScrollbar = null;
185 TextField m_modifyVarTextField = null;
186 CountButton m_modifyVarButton = null;
187 CountButton m_clearVarButton = null;
188 int m_modifyVarButtonCount = 0;
189 int m_clearVarButtonCount = 0;
190 TextField m_hierarchyFileTextField = null;
191 CountButton m_hierarchyFileLoadButton = null;
192 CountList m_modulesList = null;
193 FastListPanel m_cmdsAvailList = null;
194 FastListContainer cmdsAvailListContainer = null;
195 FastListPanel m_cmdList = null;
196 FastListContainer cmdListContainer = null;
197 FastListPanel m_statList = null;
198 FastListContainer statListContainer = null;
199 FastListPanel m_cmdToSendList = null;
200 FastListContainer cmdToSendListContainer = null;
201 CountButton m_sendCmdButton = null;
202 Checkbox m_useColorCheckbox = null;
203 TextArea m_errlogArea = null;
204 boolean m_useColorLast = true;
205 int m_hierarchyFileLoadButtonCount = 0;
206 int m_lastModulesListCount = 0;
207 int m_lastCmdsAvailListCount = 0;
208 int m_lastCmdListCount = 0;
209 Long m_currentCmdId;
210 Long m_currentStatId;
211 int m_lastStatListCount = 0;
212 int m_lastCmdListIndex = -1;
213 int m_lastStatListIndex = -1;
214 int m_lastCmdToSendListCount = 0;
215 int m_lastSendCmdButtonCount = 0;
216 Panel m_currentModulePanel = null;
217 ModuleInfo m_currentModule = null;
218 Hashtable m_modulesHashTable = null;
219 boolean is_connected = false;
220 Panel hierarchyPanel = null;
221 LayoutManager hierarchyPanelLayout = null;
222 Panel graphPanel = null;
223 LayoutManager graphPanelLayout = null;
224 Panel innerGraphPanel = null;
225 GridBagLayout innerGraphPanelLayout = null;
226 Label maxPointsLabel = null;
227 Scrollbar maxPointsScrollbar = null;
228
229 Panel m_hierarchyOuterPanel = null;
230 HierarchyPanel m_hierarchyInnerPanel = null;
231 Scrollbar m_hierarchyVertScrollBar = null;
232 Scrollbar m_hierarchyHorzScrollBar = null;
233 int number_of_modules = 0;
234 boolean disconnectedOnStop = false;
235 CodeGen codeGenerationApplet = null;
236 Button aboutButton = null;
237 Button refreshButton = null;
238 boolean refresh_needed = true;
239
240 Panel auxChannelsPanel = null;
241 FlowLayout auxChannelsLayout = null;
242 Panel auxInnerChannelsPanel = null;
243 GridBagLayout auxInnerChannelsLayout = null;
244
245 Label auxChannelsLabel = null;
246 Label auxMsgsAvailableLabel = null;
247 Label auxMsgToSendLabel = null;
248 CountButton auxMsgSendButton = null;
249 int auxMsgSendCount = 0;
250 FastListPanel auxChannelsList = null;
251 FastListContainer auxChannelsListContainer = null;
252 FastListPanel auxMsgsAvailableList = null;
253 FastListContainer auxMsgsAvailableListContainer = null;
254 FastListPanel auxMsgToSendList = null;
255 FastListContainer auxMsgToSendListContainer = null;
256 CountButton auxModifyVarButton = null;
257 CountButton auxClearVarButton = null;
258 Label auxVarNameLabel = null;
259 Panel auxModifyVarTextListPanel = null;
260 CardLayout auxModifyVarTextListLayout = null;
261 TextField auxModifyVarTextField = null;
262 java.awt.List auxModifyVarList = null;
263 Checkbox auxConnectedCheckbox = null;
264 Label auxCountLabel = null;
265 Label auxHostLabel = null;
266 TextField auxHostField = null;
267 Label auxPortLabel = null;
268 TextField auxPortField = null;
269 Label auxBufLineLabel = null;
270 Label auxViewLabel = null;
271 FastListPanel auxViewList = null;
272 FastListContainer auxViewListContainer = null;
273 Checkbox auxPlotCheckbox = null;
274
275
276
277
278 // ANIMATION SUPPORT:
279 // m_Graphics used for storing the applet's Graphics context
280 // m_Images[] the array of Image objects for the animation
281 // m_nCurrImage the index of the next image to be displayed
282 // m_ImgWidth width of each image
283 // m_ImgHeight height of each image
284 // m_fAllLoaded indicates whether all images have been loaded
285 // NUM_IMAGES number of images used in the animation
286 //--------------------------------------------------------------------------
287 private Graphics m_Graphics;
288 private Image m_Images[];
289 private int m_nCurrImage;
290 private int m_nImgWidth = 0;
291 private int m_nImgHeight = 0;
292 private boolean m_fAllLoaded = false;
293 private final int NUM_IMAGES = 18;
294 public boolean list_modules_by_number=false;
295
296 // PARAMETER SUPPORT:
297 // Parameters allow an HTML author to pass information to the applet;
298 // the HTML author specifies them using the <PARAM> tag within the <APPLET>
299 // tag. The following variables are used to store the values of the
300 // parameters.
301 //--------------------------------------------------------------------------
302
303 // Members for applet parameters
304 // <type> <MemberVar> = <Default Value>
305 //--------------------------------------------------------------------------
306 private String m_hierarchyFile = "";
307 private float m_refreshTime = 1.0f;
308 private String m_systemHost = "isd.cme.nist.gov";
309 private int m_cmdPort = 0;
310 private int m_statPort = 0;
311 private String m_cmdsFile = "";
312 private String m_statsFile = "";
313 private boolean m_connectOnStartup = false;
314 private boolean m_minimalMode = false;
315 private boolean m_useColor = true;
316 private String m_SourceCodeDirectory = null;
317 private String DefaultSourceCodeDirectory = null;
318 private boolean ShowCodeGen = false;
319
320 // Parameter names. To change a name of a parameter, you need only make
321 // a single change. Simply modify the value of the parameter string below.
322 //--------------------------------------------------------------------------
323 public static final String PARAM_hierarchyFile = "hierarchyFile";
324 public static final String PARAM_refreshTime = "refreshTime";
325 public static final String PARAM_systemHost = "systemHost";
326 public static final String PARAM_cmdPort = "cmdPort";
327 public static final String PARAM_statPort = "statPort";
328 public static final String PARAM_cmdsFile = "cmdsFile";
329 public static final String PARAM_statsFile = "statsFile";
330 public static final String PARAM_connectOnStartup = "connectOnStartup";
331 public static final String PARAM_minimalMode = "minimalMode";
332 public static final String PARAM_useColor = "useColor";
333 public static final String PARAM_readErrlog = "readErrlog";
334 public static final String PARAM_debug = "debug";
335 public static final String PARAM_SourceCodeDirectory = "SourceCodeDirectory";
336 public static final String PARAM_ShowCodeGen = "ShowCodeGen";
337 public static final String PARAM_MIN_WIDTH = "MinWidth";
338 public static final String PARAM_MIN_HEIGHT = "MinHeight";
339 public static final String PARAM_MAX_WIDTH = "MaxWidth";
340 public static final String PARAM_MAX_HEIGHT = "MaxHeight";
341 private static final String PARAM_LIST_MODULES_BY_NUMBER = "ListModulesByNumber";
342
343 static {
344 NMLConnection.default_poll_state = true;
345 }
346
347 // diagapplet Class Constructor
348 //--------------------------------------------------------------------------
349 public diagappletMain()
350 {
351 // TODO: Add constructor code here
352 System.out.print(getAppletInfo());
353 ModuleInfo.application_type = ModuleInfo.RCS_DIAGNOSTICS_APPLICATION_TYPE;
354 m_modulesHashTable = new Hashtable();
355 m_hierarchyInnerPanel = new HierarchyPanel();
356 plot_tracker_hashtable = new Hashtable();
357 NMLConnection.default_poll_state = true;
358 }
359 public void actionPerformed(ActionEvent evt)
360 {
361 boolean ret_val = false;
362 try
363 {
364 private_action(evt);
365 }
366 catch(Exception e)
367 {
368 e.printStackTrace();
369 }
370 return;
371 }
372
373
374 private void private_action(ActionEvent evt)
375 {
376 try
377 {
378 if(evt.getSource() == moduleHostTextField)
379 {
380 m_currentModule.setHost(moduleHostTextField.getText());
381 set_force_update();
382 return;
383 }
384 if(evt.getSource() == auxModifyVarButton || evt.getSource() == auxModifyVarTextField)
385 {
386 int selected_var = auxMsgToSendList.getSelectedIndex();
387 if(debug_on)
388 {
389 System.out.println("auxModifyVarButton pressed");
390 System.out.println("auxVarNameLabel ="+auxVarNameLabel.getText());
391 System.out.println("auxModifyVarTextField ="+auxModifyVarTextField.getText());
392 System.out.println("selected_var ="+selected_var);
393 }
394 if(selected_var < 0)
395 {
396 return;
397 }
398 auxMsgToSendList.replaceItem(auxVarNameLabel.getText()+"="+auxModifyVarTextField.getText(), selected_var);
399 auxMsgToSendList.repaint();
400 return;
401 }
402
403 if( evt.getSource() == (loginNameTextField))
404 {
405 loginPasswdTextField.requestFocus();
406 return;
407 }
408 if(evt.getSource() == (stateTableInfoTextField))
409 {
410 String new_info_text = stateTableInfoTextField.getText();
411 if(null == new_info_text)
412 {
413 return;
414 }
415 if(new_info_text.length() < 1)
416 {
417 return;
418 }
419 int paren_index = new_info_text.indexOf('(');
420 if(paren_index > 0)
421 {
422 stateTableCodePanel.LoadCodeFile(new_info_text.substring(0,paren_index));
423 int paren2_index = new_info_text.indexOf(')', paren_index);
424 if(paren2_index > 0)
425 {
426 try
427 {
428 stateTableCodePanel.setLineNumber(
429 StrToInt.convert(new_info_text.substring(paren_index+1, paren2_index)));
430
431 }
432 catch(Exception e)
433 {
434 }
435 }
436 }
437 else
438 {
439 stateTableCodePanel.LoadCodeFile(new_info_text);
440 }
441 stateTableCodePanelVertScrollbar.setValues(stateTableCodePanel.first_line_to_show, stateTableCodePanel.num_lines_on_screen, 0, stateTableCodePanel.total_lines);
442 stateTableCodePanelHorzScrollbar.setValues(0, stateTableCodePanel.getSize().width, 0, stateTableCodePanel.max_width);
443 set_force_update();
444 return;
445 }
446 if(evt.getSource() == (loginButton) ||
447 evt.getSource() == (loginPasswdTextField))
448 {
449 if(!is_logging_on)
450 {
451 login_needed = true;
452 }
453 else
454 {
455 interrupt_logon = true;
456 NMLConnection.interrupt_login = false;
457 login_needed = false;
458 if(is_connecting)
459 {
460 interrupt_connecting = true;
461 }
462 }
463 set_force_update();
464 }
465 if(evt.getSource() == m_browseLocalButton)
466 {
467 InterruptLoad();
468 set_force_update();
469 }
470
471 if(evt.getSource() == (m_hierarchyFileLoadButton) )
472 {
473 if(debug_on)
474 {
475 System.out.println("diagapplet.m_hierarchyFileLoadButton pressed");
476 }
477 m_hierarchyFile = m_hierarchyFileTextField.getText();
478 if(is_loading_hierarchy || codeGenerationApplet.is_loading_hierarchy && ! interrupt_loading)
479 {
480 InterruptLoad();
481 set_force_update();
482 }
483 else
484 {
485 reload_hierarchy_needed = true;
486 interrupt_loading = false;
487 ModuleInfo.interrupt_loading = false;
488 if(null != codeGenerationApplet)
489 {
490 codeGenerationApplet.interrupt_loading = false;
491 }
492 if(null == main_applet_thread)
493 {
494 main_applet_thread = new Thread(this, "Diagapplet "+thread_num);
495 thread_num++;
496 main_applet_thread.start();
497 }
498 if(null != m_loadingPanel)
499 {
500 m_loadingPanel.URLname = m_hierarchyFile;
501 m_loadingPanel.content_length = -1;
502 m_loadingPanel.bytes_read = 0;
503 m_loadingPanel.repaint();
504 }
505
506 }
507 set_force_update();
508 }
509 if(evt.getSource() == (m_modifyVarTextField))
510 {
511 if(null != m_modifyVarButton)
512 {
513 m_modifyVarButton.count++;
514 }
515 m_modifyVarButtonCount = m_modifyVarButton.count;
516 int item_num = m_cmdToSendList.getSelectedIndex();
517 if(item_num >= 0)
518 {
519 m_cmdToSendList.replaceItem(m_modifyVarLabel.getText()+"="+m_modifyVarTextField.getText(),item_num);
520 if(m_cmdToSendList.countItems() > item_num+1)
521 {
522 m_cmdToSendList.select(item_num+1);
523 ModifyVarToSend();
524 }
525 else
526 {
527 m_cmdToSendList.select(0);
528 ModifyVarToSend();
529 }
530 }
531 set_force_update();
532 return;
533 }
534 if(evt.getSource() == (m_hierarchyFileTextField))
535 {
536 m_hierarchyFile = m_hierarchyFileTextField.getText();
537 if(null != m_hierarchyFileLoadButton)
538 {
539 m_hierarchyFileLoadButton.count++;
540 }
541 reload_hierarchy_needed = true;
542 set_force_update();
543 return;
544 }
545 if(evt.getSource() == (m_findTextField))
546 {
547 if(null != m_findButton)
548 {
549 m_findButton.count++;
550 }
551 UpdateDisplay(false);
552 set_force_update();
553 return;
554 }
555 if(evt.getSource() == (stop_all_plotting_button))
556 {
557 set_force_update();
558 StopAllPlotting();
559 }
560 if(evt.getSource() == refreshButton)
561 {
562 refresh();
563 }
564 }
565 catch(Exception e)
566 {
567 System.err.println("Error processing action for event="+evt);
568 e.printStackTrace();
569 }
570 }
571 boolean sleeping = false;
572 boolean suspended = false;
573
574 public void InterruptLoad()
575 {
576 try
577 {
578 if(is_loading_hierarchy || codeGenerationApplet.is_loading_hierarchy && ! interrupt_loading)
579 {
580 reload_hierarchy_needed = false;
581 reconnect_needed = false;
582 interrupt_loading = true;
583 ModuleInfo.interrupt_loading = true;
584 if(null != codeGenerationApplet)
585 {
586 codeGenerationApplet.interrupt_loading = true;
587 codeGenerationApplet.reload_hierarchy_needed = false;
588 }
589 if(debug_on)
590 {
591 System.out.println("Interrupting Hierarchy Load");
592 }
593 if(m_useColor)
594 {
595 m_hierarchyFileLoadButton.setBackground(Color.red);
596 m_hierarchyFileLoadButton.repaint();
597 }
598 m_connectedCheckbox.setState(false);
599 DisconnectAllModules();
600 m_modifyVarButtonCount = m_modifyVarButton.count;
601 m_clearVarButtonCount = m_clearVarButton.count;
602 m_hierarchyFileLoadButtonCount = m_hierarchyFileLoadButton.count;
603 m_lastSendCmdButtonCount = m_sendCmdButton.count;
604 m_lastModulesListCount = m_modulesList.count;
605 m_lastCmdsAvailListCount = m_cmdsAvailList.count;
606 m_lastCmdToSendListCount = m_cmdToSendList.count;
607 if(null != m_loadingPanel)
608 {
609 m_loadingPanel.URLname += " -- Stopped";
610 m_loadingPanel.repaint();
611 }
612 if(null != main_applet_thread)
613 {
614 main_applet_thread.stop();
615 is_loading_hierarchy = false;
616 codeGenerationApplet.is_loading_hierarchy = false;
617 ModuleInfo.ClearStaticData();
618 if(null != m_modulesList)
619 {
620 m_modulesList.removeAll();
621 }
622 if(null != m_hierarchyInnerPanel)
623 {
624 m_hierarchyInnerPanel.clear();
625 }
626 NMLConnection.ClearStaticData();
627 try
628 {
629 Thread.sleep(100);
630 }
631 catch(InterruptedException ie)
632 {
633 }
634 System.runFinalization();
635 }
636 }
637 set_force_update();
638 }
639 catch(Exception e)
640 {
641 e.printStackTrace();
642 }
643 }
644
645 int force_update_count = 0;
646
647 private void set_force_update()
648 {
649 force_update_count = 2;
650 repaint_count = 2;
651 force_update = true;
652 if(debug_on)
653 {
654 //Thread.dumpStack();
655 }
656
657 if(null == main_applet_thread)
658 {
659 main_applet_thread = new Thread(this, "Diagapplet "+thread_num);
660 thread_num++;
661 main_applet_thread.start();
662 }
663
664 if(null != main_applet_thread)
665 {
666 if(sleeping)
667 {
668 main_applet_thread.interrupt();
669 }
670 if(suspended)
671 {
672 main_applet_thread.resume();
673 }
674 }
675 }
676
677
678 private void refresh()
679 {
680 try
681 {
682 // Thread.dumpStack();
683 set_force_update();
684 if(null == main_applet_thread)
685 {
686 main_applet_thread = new Thread(this);
687 main_applet_thread.start();
688 }
689 set_force_update();
690 repaint_needed = true;
691 main_applet_thread.resume();
692
693 }
694 catch(Exception e)
695 {
696 e.printStackTrace();
697 }
698 }
699
700
701
702 private void MakeVariableXAxis(int variable_number,String variable_name, boolean is_cmd_value)
703 {
704 x_axis_var_data = new XAxisVarData();
705 x_axis_var_data.variable_number = variable_number;
706 x_axis_var_data.variable_name = variable_name;
707 x_axis_var_data.is_cmd_value = is_cmd_value;
708 x_axis_var_data.module = m_currentModule;
709 }
710
711 private void MakeTimeXAxisVariable(int variable_number,String variable_name, String msg_name, boolean is_cmd_value)
712 {
713 }
714
715 private void StartPlottingVariable(int variable_number,String variable_name, boolean is_cmd_value)
716 {
717 try
718 {
719 if(first_plot_start_time < 1)
720 {
721 first_plot_start_time = System.currentTimeMillis();
722 }
723 if(variable_number < 2)
724 {
725 System.err.println("Can't plot variable "+variable_name+", (variable_number == "+variable_number+" )" );
726 return;
727 }
728 if(null == m_currentModule)
729 {
730 System.err.println("Can't plot variable "+variable_name+", (null == m_currentModule)");
731 return;
732 }
733 PlotTracker plot_tracker = new PlotTracker();
734 plot_tracker.plot_data = new PlotData();
735 plot_tracker.var_number = variable_number;
736 plot_tracker.module = m_currentModule;
737 int index = variable_name.indexOf('=');
738 if(index > 0)
739 {
740 variable_name = variable_name.substring(0,index);
741 }
742 index = variable_name.lastIndexOf(' ');
743 if(index > 0)
744 {
745 variable_name = variable_name.substring(index+1);
746 }
747 String plot_name = null;
748 if(is_cmd_value)
749 {
750 plot_name = m_currentModule.Name+"."+m_currentModule.lastCmdName+"."+variable_name;
751 m_currentModule.cmd_plotting_variables.put(new Integer(variable_number), plot_tracker);
752 if(variable_number > m_currentModule.max_cmd_var_number)
753 {
754 m_currentModule.max_cmd_var_number = variable_number;
755 }
756 m_currentModule.cmd_has_been_plotted = false;
757 plot_tracker.msg_type = m_currentModule.cmd_msg_type;
758 }
759 else
760 {
761 plot_name = m_currentModule.Name+"."+m_currentModule.status_type_name+"."+variable_name;
762 m_currentModule.stat_plotting_variables.put(new Integer(variable_number), plot_tracker);
763 if(variable_number > m_currentModule.max_stat_var_number)
764 {
765 m_currentModule.max_stat_var_number = variable_number;
766 }
767 m_currentModule.stat_has_been_plotted = false;
768 plot_tracker.msg_type = m_currentModule.stat_msg_type;
769 }
770 plot_tracker.is_cmd_value = is_cmd_value;
771 dplotter.AddPlot(plot_tracker.plot_data,plot_name);
772 plot_tracker_hashtable.put(plot_name,plot_tracker);
773 if(debug_on)
774 {
775 System.out.println("Start plotting "+plot_name);
776 }
777 }
778 catch(Exception e)
779 {
780 System.err.println("Error trying to start plotting for "+variable_name);
781 e.printStackTrace();
782 }
783 }
784
785 private void StartPlottingAuxVariable(int variable_number,String variable_name, String channelName)
786 {
787 try
788 {
789 BufferInfo bi = (BufferInfo) auxBuffersHashtable.get(channelName);
790 String plot_name;
791 if(first_plot_start_time < 1)
792 {
793 first_plot_start_time = System.currentTimeMillis();
794 }
795 PlotTracker plot_tracker = new PlotTracker();
796 plot_tracker.plot_data = new PlotData();
797 plot_tracker.var_number = variable_number;
798 plot_tracker.module = null;
799 int index = variable_name.indexOf('=');
800 if(index > 0)
801 {
802 variable_name = variable_name.substring(0,index);
803 }
804 index = variable_name.lastIndexOf(' ');
805 if(index > 0)
806 {
807 variable_name = variable_name.substring(index+1);
808 }
809 plot_name = bi.Name+"."+variable_name;
810 if(null == bi.plotting_variables)
811 {
812 bi.plotting_variables = new Hashtable();
813 }
814 bi.plotting_variables.put(new Integer(variable_number), plot_tracker);
815 if(variable_number > bi.max_plot_var_number)
816 {
817 bi.max_plot_var_number = variable_number;
818 }
819 bi.has_been_plotted = false;
820 plot_tracker.msg_type = bi.id;
821 plot_tracker.is_cmd_value = false;
822 plot_tracker.is_aux_channel = true;
823 plot_tracker.auxBufferInfo = bi;
824 dplotter.AddPlot(plot_tracker.plot_data,plot_name);
825 plot_tracker_hashtable.put(plot_name,plot_tracker);
826 bi.add_plotting_variable(variable_number, plot_tracker);
827 if(debug_on)
828 {
829 System.out.println("Start plotting "+plot_name+ "( variable_number = "+variable_number+", variable_name = "+variable_name+", channelName = "+channelName+")" );
830 }
831 }
832 catch(Exception e)
833 {
834 System.err.println("Error trying to start plotting for "+variable_name);
835 e.printStackTrace();
836 }
837 }
838
839 private void StopPlottingAuxVariable(int variable_number,String variable_name, String auxChannelname)
840 {
841 String plot_name = null;
842 int index = variable_name.indexOf('=');
843 if(index > 0)
844 {
845 variable_name = variable_name.substring(0,index);
846 }
847 index = variable_name.lastIndexOf(' ');
848 if(index > 0)
849 {
850 variable_name = variable_name.substring(index+1);
851 }
852 plot_name = auxChannelname+"."+variable_name;
853
854 RemovePlot(plot_name);
855 }
856
857 private void StopPlottingVariable(int variable_number,String variable_name, String msg_name, boolean is_cmd_value)
858 {
859 String plot_name = null;
860 int index = variable_name.indexOf('=');
861 if(index > 0)
862 {
863 variable_name = variable_name.substring(0,index);
864 }
865 index = variable_name.lastIndexOf(' ');
866 if(index > 0)
867 {
868 variable_name = variable_name.substring(index+1);
869 }
870 if(is_cmd_value)
871 {
872 plot_name = m_currentModule.Name+"."+msg_name+"."+variable_name;
873 }
874 else
875 {
876 plot_name = m_currentModule.Name+"."+msg_name+"."+variable_name;
877 }
878 RemovePlot(plot_name);
879 }
880 private void RemovePlot(String name)
881 {
882 PlotTracker plot_tracker = (PlotTracker) plot_tracker_hashtable.get(name);
883 if(null == plot_tracker)
884 {
885 return;
886 }
887 RemovePlotTracker(plot_tracker);
888 if(debug_on)
889 {
890 System.out.println("RemovePlot "+name);
891 }
892 }
893 private void RemovePlotTracker(PlotTracker plot_tracker)
894 {
895 if(null == plot_tracker.module)
896 {
897 return;
898 }
899 if(plot_tracker.is_aux_channel)
900 {
901 plot_tracker.auxBufferInfo.plotting_variables.remove(new Integer(plot_tracker.var_number));
902 if(plot_tracker.auxBufferInfo.plotting_variables.size() < 1)
903 {
904 plot_tracker.auxBufferInfo.plotting_variables.clear();
905 plot_tracker.auxBufferInfo.max_plot_var_number = 0;
906 }
907 }
908 else
909 {
910 if(plot_tracker.is_cmd_value)
911 {
912 plot_tracker.module.cmd_plotting_variables.remove(new Integer(plot_tracker.var_number));
913 if(plot_tracker.module.cmd_plotting_variables.size() < 1)
914 {
915 plot_tracker.module.cmd_plotting_variables.clear();
916 plot_tracker.module.max_cmd_var_number = 0;
917 }
918 }
919 else
920 {
921 plot_tracker.module.stat_plotting_variables.remove(new Integer(plot_tracker.var_number));
922 if(plot_tracker.module.stat_plotting_variables.size() < 1)
923 {
924 plot_tracker.module.stat_plotting_variables.clear();
925 plot_tracker.module.max_stat_var_number = 0;
926 }
927 }
928 }
929 plot_tracker_hashtable.remove(plot_tracker.plot_data.name);
930 }
931
932 private void StopAllPlotting()
933 {
934 try
935 {
936 if(null == plot_tracker_hashtable)
937 {
938 return;
939 }
940 Enumeration plot_names = plot_tracker_hashtable.keys();
941 while(plot_names.hasMoreElements())
942 {
943 String plot_name = (String) plot_names.nextElement();
944 RemovePlot(plot_name);
945 }
946 plot_tracker_hashtable.clear();
947 Enumeration modules_enum = m_modulesHashTable.elements();
948 while(modules_enum.hasMoreElements())
949 {
950 ModuleInfo mod = (ModuleInfo) modules_enum.nextElement();
951 if(null == mod)
952 {
953 break;
954 }
955 mod.stat_plotting_variables.clear();
956 mod.cmd_plotting_variables.clear();
957 mod.max_cmd_var_number = 0;
958 mod.max_stat_var_number = 0;
959 }
960 if(null != cmdPlotCheckbox)
961 {
962 cmdPlotCheckbox.setState(false);
963 }
964 if(null != cmdMakeXAxisCheckbox)
965 {
966 cmdMakeXAxisCheckbox.setState(false);
967 }
968 if(null != statPlotCheckbox)
969 {
970 statPlotCheckbox.setState(false);
971 }
972 if(null != statMakeXAxisCheckbox)
973 {
974 statMakeXAxisCheckbox.setState(false);
975 }
976 if(null != auxPlotCheckbox)
977 {
978 auxPlotCheckbox.setState(false);
979 }
980
981 }
982 catch(Exception e)
983 {
984 e.printStackTrace();
985 }
986 }
987
988 int last_maxPointsScrollbar_value = 0;
989 int last_m_hierarchyVertScrollBar_value = 0;
990 int last_m_hierarchyHorzScrollBar_value = 0;
991 int last_m_refreshTimeScrollBar_value = 0;
992
993 public void adjustmentValueChanged(AdjustmentEvent evt)
994 {
995 int temp = 0;
996 try
997 {
998 if(evt.getSource() == maxPointsScrollbar)
999 {
1000 temp = evt.getValue();
1001 if(temp != last_maxPointsScrollbar_value)
1002 {
1003 last_maxPointsScrollbar_value = temp;
1004 int max_points = maxPointsScrollbar.getValue();
1005 dplotter.set_max_points_per_plot(max_points);
1006 maxPointsLabel.setText("Max Points To Plot:"+max_points);
1007 maxPointsScrollbar.setValue(max_points);
1008 refresh();
1009 }
1010 return;
1011 }
1012 if(evt.getSource() == m_hierarchyVertScrollBar)
1013 {
1014 temp = evt.getValue();
1015 if(temp != last_m_hierarchyVertScrollBar_value)
1016 {
1017 last_m_hierarchyVertScrollBar_value = temp;
1018 m_hierarchyInnerPanel.scroll_y = temp;
1019 if(debug_on)
1020 {
1021 System.out.println("m_hierarchyInnerPanel.scroll_y = "+m_hierarchyInnerPanel.scroll_y);
1022 }
1023 set_force_update();
1024 }
1025 return;
1026 }
1027 if(evt.getSource() == m_hierarchyHorzScrollBar)
1028 {
1029 temp = evt.getValue();
1030 if(temp != last_m_hierarchyHorzScrollBar_value)
1031 {
1032 last_m_hierarchyHorzScrollBar_value = temp;
1033 m_hierarchyInnerPanel.scroll_x = temp;
1034 if(debug_on)
1035 {
1036 System.out.println("m_hierarchyInnerPanel.scroll_x = "+m_hierarchyInnerPanel.scroll_x);
1037 }
1038 set_force_update();
1039 }
1040 return;
1041 }
1042 /* if(evt.getSource() == (m_refreshTimeScrollbar))
1043 {
1044 temp = evt.getValue();
1045 System.out.println("temp="+temp);
1046 if(temp != last_m_refreshTimeScrollBar_value)
1047 {
1048 last_m_refreshTimeScrollBar_value = temp;
1049 m_refreshTimeScrollbar.setValue(temp);
1050 refresh();
1051 }
1052 return;
1053 } */
1054 }
1055 catch(Exception e)
1056 {
1057 e.printStackTrace();
1058 }
1059 }
1060
1061 public void itemStateChanged(ItemEvent evt)
1062 {
1063 int temp = 0;
1064 try
1065 {
1066 if(debug_on)
1067 {
1068 System.out.println("itemStateChanged("+evt+")");
1069 }
1070 if(evt.getSource() == (displayChoice))
1071 {
1072 set_force_update();
1073 currentViewString = displayChoice.getSelectedItem();
1074 choicePanelLayout.show(choicePanel,currentViewString);
1075 }
1076 if(evt.getSource() == (cmdPlotCheckbox))
1077 {
1078 set_force_update();
1079 if(cmdPlotCheckbox.getState())
1080 {
1081 if(-1 == m_cmdList.getSelectedIndex())
1082 {
1083 m_cmdList.select(0);
1084 }
1085 StartPlottingVariable(m_cmdList.getSelectedVarNumber()+2, m_cmdList.getSelectedItem(),true);
1086 }
1087 else
1088 {
1089 StopPlottingVariable(m_cmdList.getSelectedVarNumber()+2, m_cmdList.getSelectedItem(),m_currentModule.lastCmdName,true);
1090 }
1091 }
1092
1093 if(evt.getSource() == (cmdMakeXAxisCheckbox))
1094 {
1095 set_force_update();
1096 if(cmdMakeXAxisCheckbox.getState())
1097 {
1098 if(-1 == m_cmdList.getSelectedIndex())
1099 {
1100 m_cmdList.select(0);
1101 }
1102 MakeVariableXAxis(m_cmdList.getSelectedVarNumber()+2, m_cmdList.getSelectedItem(),true);
1103 }
1104 else
1105 {
1106 MakeTimeXAxisVariable(m_cmdList.getSelectedVarNumber()+2, m_cmdList.getSelectedItem(),m_currentModule.lastCmdName,true);
1107 }
1108 }
1109
1110
1111 if(evt.getSource() == (statPlotCheckbox))
1112 {
1113 set_force_update();
1114 if(statPlotCheckbox.getState())
1115 {
1116 if(-1 == m_statList.getSelectedIndex())
1117 {
1118 m_statList.select(1);
1119 }
1120 StartPlottingVariable(m_statList.getSelectedVarNumber()+2, m_statList.getSelectedItem(),false);
1121 }
1122 else
1123 {
1124 StopPlottingVariable(m_statList.getSelectedVarNumber()+2, m_statList.getSelectedItem(),m_currentModule.status_type_name,false);
1125 }
1126 }
1127
1128
1129 if(evt.getSource() == (statMakeXAxisCheckbox))
1130 {
1131 set_force_update();
1132 if(statMakeXAxisCheckbox.getState())
1133 {
1134 if(-1 == m_statList.getSelectedIndex())
1135 {
1136 m_statList.select(0);
1137 }
1138 MakeVariableXAxis(m_statList.getSelectedVarNumber()+2, m_statList.getSelectedItem(),false);
1139 }
1140 else
1141 {
1142 MakeTimeXAxisVariable(m_statList.getSelectedVarNumber()+2, m_statList.getSelectedItem(),m_currentModule.lastStatName,false);
1143 }
1144 }
1145
1146 if(evt.getSource() == (auxPlotCheckbox))
1147 {
1148 set_force_update();
1149 if(auxPlotCheckbox.getState())
1150 {
1151 if(-1 == auxViewList.getSelectedIndex())
1152 {
1153 auxViewList.select(1);
1154 }
1155 StartPlottingAuxVariable(auxViewList.getSelectedVarNumber()+2, auxViewList.getSelectedItem(),auxChannelsList.getSelectedItem());
1156 }
1157 else
1158 {
1159 StopPlottingAuxVariable(auxViewList.getSelectedVarNumber()+2, auxViewList.getSelectedItem(),auxChannelsList.getSelectedItem());
1160 }
1161 }
1162
1163
1164 if(evt.getSource() == (m_useColorCheckbox))
1165 {
1166 if(m_useColorCheckbox.getState() != m_useColorLast)
1167 {
1168 m_useColor = m_useColorCheckbox.getState();
1169 m_useColorLast = m_useColor;
1170 if(null != sub_plotter)
1171 {
1172 dplotter.setColorState(m_useColor);
1173 }
1174 if(null != m_loadingPanel)
1175 {
1176 m_loadingPanel.use_color = m_useColor;
1177 }
1178 if(null != stateTableCodePanel)
1179 {
1180 stateTableCodePanel.use_color = m_useColor;
1181 }
1182 if(!m_useColor)
1183 {
1184 if(null != m_hierarchyInnerPanel)
1185 {
1186 m_hierarchyInnerPanel.setBackground(Color.white);
1187 m_hierarchyInnerPanel.setForeground(Color.black);
1188 m_hierarchyInnerPanel.repaint();
1189 }
1190 if(null != m_connectedPanel)
1191 {
1192 m_connectedPanel.setBackground(Color.white);
1193 m_connectedPanel.setForeground(Color.black);
1194 m_connectedPanel.repaint();
1195 }
1196 if(null != m_connectedCheckbox)
1197 {
1198 m_connectedCheckbox.setBackground(Color.white);
1199 m_connectedCheckbox.setForeground(Color.black);
1200 m_connectedCheckbox.repaint();
1201 }
1202 String oldLabel = m_connectedCheckbox.getLabel();
1203 if(null != oldLabel)
1204 {
1205 if(-1 == oldLabel.indexOf("B&W"))
1206 {
1207 m_connectedCheckbox.setLabel(oldLabel + " (B&W)");
1208 }
1209 }
1210 //m_connectedCheckbox.repaint();
1211 if(null != loadPercentPanel)
1212 {
1213 loadPercentPanel.setBackground(Color.white);
1214 loadPercentPanel.setForeground(Color.black);
1215 loadPercentPanel.repaint();
1216 }
1217 }
1218 else
1219 {
1220 if(null != m_hierarchyInnerPanel)
1221 {
1222 m_hierarchyInnerPanel.setBackground(Color.blue);
1223 m_hierarchyInnerPanel.repaint();
1224 }
1225 }
1226
1227 }
1228 set_force_update();
1229 return;
1230 }
1231 if(evt.getSource() == (m_connectedCheckbox))
1232 {
1233 interrupt_connecting = true;
1234 set_force_update();
1235 }
1236 if( evt.getSource() == (nmlReadDebugCheckbox))
1237 {
1238 rcs.nml.NMLConnection.read_debug_on = nmlReadDebugCheckbox.getState();
1239 return;
1240 }
1241 if( evt.getSource() == (nmlWriteDebugCheckbox))
1242 {
1243 rcs.nml.NMLConnection.write_debug_on = nmlWriteDebugCheckbox.getState();
1244 return;
1245 }
1246 if( evt.getSource() == (nmlConfigDebugCheckbox))
1247 {
1248 rcs.nml.NMLConnection.config_debug_on = nmlConfigDebugCheckbox.getState();
1249 return;
1250 }
1251 if( evt.getSource() == (diagappletDebugCheckbox))
1252 {
1253 debug_on = diagappletDebugCheckbox.getState();
1254 return;
1255 }
1256 if( evt.getSource() == (hierarchyPanelDebugCheckbox))
1257 {
1258 HierarchyPanel.debug_on = hierarchyPanelDebugCheckbox.getState();
1259 return;
1260 }
1261 if( evt.getSource() == (plotterDebugCheckbox))
1262 {
1263 dplotter.debug_on = plotterDebugCheckbox.getState();
1264 PlotGraph.debug_on = dplotter.debug_on;
1265 return;
1266 }
1267 if( evt.getSource() == (codegenDebugCheckbox))
1268 {
1269 CodeGen.debug_on = codegenDebugCheckbox.getState();
1270 return;
1271 }
1272 if( evt.getSource() == (moduleinfoDebugCheckbox))
1273 {
1274 ModuleInfo.debug_on = moduleinfoDebugCheckbox.getState();
1275 return;
1276 }
1277 if( evt.getSource() == (fileloaderDebugCheckbox))
1278 {
1279 rcs.utils.URL_and_FileLoader.debug_on = fileloaderDebugCheckbox.getState();
1280 return;
1281 }
1282 if( evt.getSource() == (xdrDebugCheckbox))
1283 {
1284 rcs.nml.XDRFormatConverter.debug_on = xdrDebugCheckbox.getState();
1285 return;
1286 }
1287 if( evt.getSource() == (diagNMLmessageDictDebugCheckbox))
1288 {
1289 DiagNMLMessageDictionary.debug_on = diagNMLmessageDictDebugCheckbox.getState();
1290 return;
1291 }
1292 if( evt.getSource() == (diagNMLmsgDebugCheckbox))
1293 {
1294 DiagNMLmsg.debug_on = diagNMLmsgDebugCheckbox.getState();
1295 return;
1296 }
1297 if( evt.getSource() == (fastListPanelDebugCheckbox))
1298 {
1299 FastListPanel.debug_on = fastListPanelDebugCheckbox.getState();
1300 return;
1301 }
1302 if(evt.getSource() == auxConnectedCheckbox)
1303 {
1304 boolean newState = auxConnectedCheckbox.getState();
1305 String aux = auxChannelsList.getSelectedItem();
1306 if(null == aux)
1307 {
1308 return;
1309 }
1310 BufferInfo bi = (BufferInfo) auxBuffersHashtable.get(aux);
1311 if(null == bi)
1312 {
1313 return;
1314 }
1315 if(null == bi.nml)
1316 {
1317 return;
1318 }
1319 if(newState != bi.nml.connected)
1320 {
1321 if(newState)
1322 {
1323 bi.nml.connect();
1324 }
1325 else
1326 {
1327 bi.nml.disconnect();
1328 }
1329 }
1330 return;
1331 }
1332
1333 if(evt.getSource() == thisModuleConnectedCheckbox)
1334 {
1335 m_currentModule.setHost(moduleHostTextField.getText());
1336 set_force_update();
1337 return;
1338 }
1339 if(evt.getSource() == m_statList)
1340 {
1341 refresh();
1342 return;
1343 }
1344 if(evt.getSource() == m_cmdList)
1345 {
1346 refresh();
1347 return;
1348 }
1349
1350 if(evt.getSource() == m_cmdToSendList)
1351 {
1352 if(evt.getStateChange() != ItemEvent.SELECTED)
1353 {
1354 return;
1355 }
1356 refresh();
1357 set_force_update();
1358 return;
1359 }
1360 if(evt.getSource() == m_cmdsAvailList)
1361 {
1362 set_force_update();
1363 return;
1364 }
1365 if(evt.getSource() == m_modulesList)
1366 {
1367 set_force_update();
1368 return;
1369 }
1370 if(evt.getSource() == auxChannelsList)
1371 {
1372 String aux = auxChannelsList.getSelectedItem();
1373 if(null == aux)
1374 {
1375 set_force_update();
1376 return;
1377 }
1378 BufferInfo bi = (BufferInfo) auxBuffersHashtable.get(aux);
1379 if(null == bi)
1380 {
1381 set_force_update();
1382 return;
1383 }
1384 auxMsgsAvailableList.removeAll();
1385 if(null != bi.msgsAvailable)
1386 {
1387 for(int i = 0; i < bi.msgsAvailable.size(); i++)
1388 {
1389 auxMsgsAvailableList.add((String) bi.msgsAvailable.elementAt(i));
1390 }
1391 }
1392 auxMsgsAvailableList.repaint();
1393 if(null != bi.nml)
1394 {
1395 auxBufLineLabel.setText(bi.nml.BufferLine);
1396 auxHostField.setText(bi.nml.host);
1397 auxPortField.setText((new Integer(bi.nml.port)).toString());
1398 auxConnectedCheckbox.setState(bi.nml.connected);
1399 }
1400 auxCountLabel.setText(String.valueOf(bi.messages_recvd)+" recvd, " + bi.messages_sent+" sent");
1401 set_force_update();
1402 return;
1403 }
1404 if(evt.getSource() == auxMsgsAvailableList)
1405 {
1406 LoadAuxMsgToSend();
1407 set_force_update();
1408 return;
1409 }
1410
1411 if(evt.getSource() == auxMsgToSendList)
1412 {
1413 String eqString = auxMsgToSendList.getSelectedItem();
1414 if(null == eqString)
1415 {
1416 return;
1417 }
1418 int eqIndex = eqString.indexOf('=');
1419 if(eqIndex <= 0)
1420 {
1421 return;
1422 }
1423 String nameString = eqString.substring(0,eqIndex);
1424 auxVarNameLabel.setText(nameString);
1425 String valString = eqString.substring(eqIndex+1);
1426 auxModifyVarTextField.setText(valString);
1427 set_force_update();
1428 return;
1429 }
1430 }
1431 catch(Exception e)
1432 {
1433 e.printStackTrace();
1434 }
1435 }
1436
1437 // APPLET INFO SUPPORT:
1438 // The getAppletInfo() method returns a string describing the applet's
1439 // author, copyright date, or miscellaneous information.
1440 //--------------------------------------------------------------------------
1441 public String getAppletInfo()
1442 {
1443 return "******************************************************************** \r\n"+
1444 "* RCS-Diagnostics \r\n" +
1445 "* \r\n" +
1446 "* Graphical Tool for monitoring and controlling RCS applications. \r\n"+
1447 "* \r\n" +
1448 "* $Id: diagappletMain.java,v 4.2 2001/06/13 19:56:28 wshackle Exp $ \r\n"+
1449 "* \r\n" +
1450 "* "+rcs.RCS_VERSION.info_string+" \r\n"+
1451 "* \r\n" +
1452 "* This software was produced by the National Institute of \r\n"+
1453 "* Standards and Technology(NIST), an agency of the U.S. government,\r\n"+
1454 "* and by statute is not subject to copyright in the United\r\n" +
1455 "* States. Recipients of this software assume all responsibility \r\n"+
1456 "* associated with its operation, modification, maintenance, and\r\n"+
1457 "* subsequent redistribution. \r\n" +
1458 "* \r\n" +
1459 "* Please contact Will Shackleford \r\n"+
1460 "* ( email: shackle@cme.nist.gov, phone: (301) 975-4286) \r\n"+
1461 "* if you have any questions, comments or problems related \r\n"+
1462 "* to this software. \r\n"+
1463 "******************************************************************** \r\n"+
1464 "\r\n";
1465 }
1466
1467 // PARAMETER SUPPORT
1468 // The getParameterInfo() method returns an array of strings describing
1469 // the parameters understood by this applet.
1470 //
1471 // diagapplet Parameter Information:
1472 // { "Name", "Type", "Description" },
1473 //--------------------------------------------------------------------------
1474 public String[][] getParameterInfo()
1475 {
1476 String[][] info =
1477 {
1478 { PARAM_hierarchyFile, "String", "URL of the file containing heirarchy information." },
1479 { PARAM_refreshTime, "float", "Time in seconds of time to wait each cycle before updating the display." },
1480 { PARAM_systemHost, "String", "Host with server for command and status of top level module." },
1481 { PARAM_cmdPort, "int", "TCP port number for commands to top module." },
1482 { PARAM_statPort, "int", "TCP port number for status of top module" },
1483 { PARAM_cmdsFile, "String", "URL of file containing info on the command types for the top level module." },
1484 { PARAM_statsFile, "String", "URL of file containing info on the status types for the top level module." },
1485 { PARAM_connectOnStartup, "boolean", "Should the applet automatically try to connect to the controller." },
1486 { PARAM_minimalMode, "boolean", "Should the applet eliminate features to try to minimize the required system resources." },
1487 { PARAM_useColor, "boolean", "Should the applet use color." },
1488 { PARAM_MIN_WIDTH, "int", "Mininum width for applet in pixels" },
1489 { PARAM_MIN_HEIGHT, "int", "Mininum height for applet in pixels" },
1490 { PARAM_MAX_WIDTH, "int", "Maxinum width for applet in pixels" },
1491 { PARAM_MAX_HEIGHT, "int", "Maxinum height for applet in pixels" },
1492 { PARAM_readErrlog, "boolean", "Should the error log be read." },
1493 { PARAM_debug, "boolean", "Should a lot of debug info be printed" },
1494 { PARAM_SourceCodeDirectory, "String", "Directory or URL base to look for state table source code." },
1495 { PARAM_ShowCodeGen,"boolean", "Should the CodeGen applet be visable."},
1496 };
1497 return info;
1498 }
1499
1500
1501
1502
1503 private void CheckForColor()
1504 {
1505 try
1506 {
1507 java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
1508 if(tk == null)
1509 {
1510 return;
1511 }
1512 java.awt.image.ColorModel cm = tk.getColorModel();
1513 if(cm == null)
1514 {
1515 return;
1516 }
1517 if(cm.getPixelSize() < 2)
1518 {
1519 m_useColor = false;
1520 }
1521 }
1522 catch(Exception e)
1523 {
1524 e.printStackTrace();
1525 }
1526 }
1527
1528
1529 boolean first_init = true;
1530
1531 GridBagLayout mainLayout = null;
1532 GridBagLayout topLayout = null;
1533
1534 void CleanupControls()
1535 {
1536 try
1537 {
1538 mainLayout = null;
1539 if(null != m_topPanel)
1540 {
1541 m_topPanel.removeAll();
1542 m_topPanel = null;
1543 }
1544 topLayout = null;
1545 if(null != superChoicePanel)
1546 {
1547 superChoicePanel.removeAll();
1548 superChoicePanel = null;
1549 }
1550 superChoicePanelLayout = null;
1551 if(null != choicePanel)
1552 {
1553 choicePanel.removeAll();
1554 choicePanel = null;
1555 }
1556 choicePanelLayout = null;
1557 if(graphPanel != null)
1558 {
1559 graphPanel.removeAll();
1560 graphPanel = null;
1561 }
1562 graphPanelLayout = null;
1563 if(null != sub_plotter)
1564 {
1565 sub_plotter.removeAll();
1566 sub_plotter = null;
1567 }
1568 removeAll();
1569 }
1570 catch(Exception e)
1571 {
1572 e.printStackTrace();
1573 }
1574
1575 }
1576
1577 // The init() method is called by the AWT when an applet is first loaded or
1578 // reloaded. Override this method to perform whatever initialization your
1579 // applet needs, such as initializing data structures, loading images or
1580 // fonts, creating frame windows, setting the layout manager, or adding UI
1581 // components.
1582 //--------------------------------------------------------------------------
1583 public void init()
1584 {
1585 try
1586 {
1587 if(inside_init)
1588 {
1589 System.err.println("diagapplet can't init twice at the same time.");
1590 return;
1591 }
1592 m_readErrlog = !m_fStandAlone;
1593 initialized = false;
1594 inside_init = true;
1595 boolean small = true;
1596 int list_shrinker = 2;
1597 CleanupControls();
1598 Dimension d = getSize();
1599 int tries = 0;
1600 while(d.width < 600 || d.height < 400)
1601 {
1602 if(tries > 20)
1603 {
1604 break;
1605 }
1606 try
1607 {
1608 Thread.sleep(100);
1609 }
1610 catch(Exception e)
1611 {
1612 }
1613 d = getSize();
1614 tries++;
1615 }
1616 tries=20;
1617 while(d.width < MIN_WIDTH || d.height < MIN_HEIGHT )
1618 {
1619 setSize(MIN_WIDTH,MIN_HEIGHT);
1620 if(tries > 20)
1621 {
1622 break;
1623 }
1624 try
1625 {
1626 Thread.sleep(100);
1627 }
1628 catch(Exception e)
1629 {
1630 }
1631 d = getSize();
1632 tries++;
1633 }
1634 if(MAX_WIDTH < MIN_WIDTH)
1635 {
1636 MAX_WIDTH = MIN_WIDTH+1;
1637 }
1638
1639 if(MAX_HEIGHT < MIN_HEIGHT)
1640 {
1641 MAX_HEIGHT = MIN_HEIGHT+1;
1642 }
1643
1644 tries = 20;
1645 while(d.width > MAX_WIDTH || d.height > MAX_HEIGHT )
1646 {
1647 setSize(MAX_WIDTH,MAX_HEIGHT);
1648 if(tries > 20)
1649 {
1650 break;
1651 }
1652 try
1653 {
1654 Thread.sleep(100);
1655 }
1656 catch(Exception e)
1657 {
1658 }
1659 d = getSize();
1660 tries++;
1661 }
1662
1663 if(debug_on)
1664 {
1665 System.out.println("Initializing diagapplet. . .");
1666 System.out.println("size = "+d.width+"x"+d.height);
1667 //Thread.dumpStack();
1668 }
1669 if(d.width < MIN_WIDTH)
1670 {
1671 d.width = MIN_WIDTH;
1672 }
1673 if(d.height < MIN_HEIGHT)
1674 {
1675 d.height = MIN_HEIGHT;
1676 }
1677 if(d.width > MAX_WIDTH)
1678 {
1679 d.width = MAX_WIDTH;
1680 }
1681 if(d.height > MAX_HEIGHT)
1682 {
1683 d.height = MAX_HEIGHT;
1684 }
1685 if(d.width > 850)
1686 {
1687 small = false;
1688 }
1689 if(d.height > 650)
1690 {
1691 list_shrinker = 0;
1692 }
1693 if(!m_fStandAlone && first_init)
1694 {
1695 GetParameters(null);
1696
1697 }
1698
1699
1700 if(debug_on)
1701 {
1702 System.out.println(" init finds size = "+d.width+"X"+d.height);
1703 }
1704
1705 try
1706 {
1707 if(!m_fStandAlone && first_init)
1708 {
1709 URL code_base_url = getCodeBase();
1710 if(null != code_base_url)
1711 {
1712 rcs.utils.URL_and_FileLoader.current_directory = code_base_url.toString();
1713 }
1714 }
1715 }
1716 catch(Exception e)
1717 {
1718 e.printStackTrace();
1719 }
1720 // PARAMETER SUPPORT
1721 // The following code retrieves the value of each parameter
1722 // specified with the <PARAM> tag and stores it in a member
1723 // variable.
1724 //----------------------------------------------------------------------
1725 first_repaint_occurred = false;
1726 String param;
1727
1728 // Set all the other debug flags based on the one for this applet.
1729 if(first_init)
1730 {
1731 rcs.nml.NMLConnection.read_debug_on = debug_on;
1732 rcs.nml.NMLConnection.write_debug_on = debug_on;
1733 rcs.nml.NMLConnection.config_debug_on = debug_on;
1734 HierarchyPanel.debug_on = debug_on;
1735 dplotter.debug_on = debug_on;
1736 CodeGen.debug_on = debug_on;
1737 ModuleInfo.debug_on = debug_on;
1738 rcs.utils.URL_and_FileLoader.debug_on = debug_on;
1739 DiagNMLMessageDictionary.debug_on = debug_on;
1740 DiagNMLmsg.debug_on = debug_on;
1741 }
1742
1743
1744 try
1745 {
1746 if(small)
1747 {
1748 Font smallFont = null;
1749 smallFont = new Font("courier",Font.PLAIN, 10);
1750 setFont(smallFont);
1751 }
1752 }
1753 catch(Exception e)
1754 {
1755 e.printStackTrace();
1756 }
1757 if(m_minimalMode)
1758 {
1759 m_useColor = false;
1760 m_connectOnStartup = false;
1761 if(m_refreshTime < 0.25)
1762 {
1763 m_refreshTime = (float) 0.25;
1764 }
1765 }
1766
1767 if(first_init)
1768 {
1769 CheckForColor();
1770 }
1771 // If you use a ResourceWizard-generated "control creator" class to
1772 // arrange controls in your applet, you may want to call its
1773 // CreateControls() method from within this method. Remove the following
1774 // call to resize() before adding the call to CreateControls();
1775 // CreateControls() does its own resizing.
1776 //----------------------------------------------------------------------
1777
1778
1779 // TODO: Place additional initialization code here
1780 mainLayout = new GridBagLayout();