Building Controls Virtual Test Bed
BACnet.java
Go to the documentation of this file.
1 /* A base class for the BACnet reader and BACnet writer.
2 
3 Copyright Notice
4 ----------------
5 
6 Building Controls Virtual Test Bed (BCVTB) Copyright (c) 2008-2009, The
7 Regents of the University of California, through Lawrence Berkeley
8 National Laboratory (subject to receipt of any required approvals from
9 the U.S. Dept. of Energy). All rights reserved.
10 
11 If you have questions about your rights to use or distribute this
12 software, please contact Berkeley Lab's Technology Transfer Department
13 at TTD@lbl.gov
14 
15 NOTICE. This software was developed under partial funding from the U.S.
16 Department of Energy. As such, the U.S. Government has been granted for
17 itself and others acting on its behalf a paid-up, nonexclusive,
18 irrevocable, worldwide license in the Software to reproduce, prepare
19 derivative works, and perform publicly and display publicly. Beginning
20 five (5) years after the date permission to assert copyright is obtained
21 from the U.S. Department of Energy, and subject to any subsequent five
22 (5) year renewals, the U.S. Government is granted for itself and others
23 acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide
24 license in the Software to reproduce, prepare derivative works,
25 distribute copies to the public, perform publicly and display publicly,
26 and to permit others to do so.
27 
28 
29 Modified BSD License agreement
30 ------------------------------
31 
32 Building Controls Virtual Test Bed (BCVTB) Copyright (c) 2008-2009, The
33 Regents of the University of California, through Lawrence Berkeley
34 National Laboratory (subject to receipt of any required approvals from
35 the U.S. Dept. of Energy). All rights reserved.
36 
37 Redistribution and use in source and binary forms, with or without
38 modification, are permitted provided that the following conditions are met:
39 
40  1. Redistributions of source code must retain the above copyright
41  notice, this list of conditions and the following disclaimer.
42  2. Redistributions in binary form must reproduce the above copyright
43  notice, this list of conditions and the following disclaimer in
44  the documentation and/or other materials provided with the
45  distribution.
46  3. Neither the name of the University of California, Lawrence
47  Berkeley National Laboratory, U.S. Dept. of Energy nor the names
48  of its contributors may be used to endorse or promote products
49  derived from this software without specific prior written permission.
50 
51 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
52 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
53 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
54 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
55 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
58 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
59 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
60 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 
63 You are under no obligation whatsoever to provide any bug fixes,
64 patches, or upgrades to the features, functionality or performance of
65 the source code ("Enhancements") to anyone; however, if you choose to
66 make your Enhancements available either publicly, or directly to
67 Lawrence Berkeley National Laboratory, without imposing a separate
68 written license agreement for such Enhancements, then you hereby grant
69 the following license: a non-exclusive, royalty-free perpetual license
70 to install, use, modify, prepare derivative works, incorporate into
71 other computer software, distribute, and sublicense such enhancements or
72 derivative works thereof, in binary and source code form.
73 
74 ********************************************************************
75 */
76 package bacnet.util;
77 
78 import ptolemy.actor.TypedAtomicActor;
79 import ptolemy.actor.TypedIOPort;
80 import ptolemy.actor.lib.SequenceActor;
81 import ptolemy.data.IntToken;
82 import ptolemy.data.Token;
83 import ptolemy.data.ArrayToken;
84 import ptolemy.data.expr.Parameter;
85 import ptolemy.data.type.BaseType;
86 import ptolemy.kernel.CompositeEntity;
87 import ptolemy.kernel.util.IllegalActionException;
88 import ptolemy.kernel.util.NameDuplicationException;
89 import ptolemy.data.type.ArrayType;
90 import ptolemy.data.BooleanToken;
91 import ptolemy.data.StringToken;
92 import ptolemy.data.expr.FileParameter;
93 import ptolemy.kernel.util.Workspace;
94 import ptolemy.kernel.util.Attribute;
95 import java.io.File;
96 import java.io.FileNotFoundException;
97 import java.io.IOException;
98 import java.io.BufferedReader;
99 import java.io.InputStreamReader;
100 import java.util.ArrayList;
101 import java.util.Arrays;
102 import org.xml.sax.SAXException;
103 import javax.xml.validation.Schema;
104 import javax.xml.parsers.ParserConfigurationException;
106 
109 
117 public abstract class BACnet extends TypedAtomicActor implements SequenceActor {
128  public BACnet(CompositeEntity container, String name)
129  throws NameDuplicationException, IllegalActionException {
130  super(container, name);
131 
132  /*Use errorSignal port to send error signal
133  */
134  errorSignal = new TypedIOPort(this,"errorSignal",false,true);
135  errorSignal.setTypeEquals(BaseType.INT);
136  /*Use output port to send error message
137  */
138  errorMessage = new TypedIOPort(this, "errorMessage", false, true);
139  errorMessage.setTypeEquals(BaseType.STRING);
140 
141  /* Use consoleArr to send console output
142  */
143  consoleArr = new TypedIOPort(this,"consoleOutput",false,true);
144  consoleArr.setTypeEquals(new ArrayType(BaseType.STRING));
145  /*Parameter setting the path of configuration file
146  */
147  configurationFile = new FileParameter(this, "configurationFile");
148  new Parameter(configurationFile, "allowFiles", BooleanToken.TRUE);
149  new Parameter(configurationFile, "allowDirectories", BooleanToken.FALSE);
150  /*Parameter determine whether throw exception to screen when error happens
151  */
152  continueWhenError = new Parameter(this,"continueWhenError",new BooleanToken(true));
153  continueWhenError.setTypeEquals(BaseType.BOOLEAN);
154  }
155 
164  public Object clone(Workspace workspace) throws CloneNotSupportedException {
165  BACnet newObject = (BACnet) (super.clone(workspace));
166 
167  // set the type constraints
168  newObject.errorMessage.setTypeEquals(BaseType.STRING);
169  newObject.errorSignal.setTypeEquals(BaseType.INT);
170  newObject.consoleArr.setTypeEquals(new ArrayType(BaseType.STRING));
171  newObject.configurationFile = (FileParameter) newObject
172  .getAttribute("configurationFile");
173  newObject.continueWhenError = (Parameter) newObject
174  .getAttribute("continueWhenError");
175  return newObject;
176  }
177 
183  public void attributeChanged(Attribute attribute)
184  throws IllegalActionException {
185  if (attribute == continueWhenError) {
186  _continueWhenError = ((BooleanToken)(continueWhenError.getToken())).booleanValue();
187  } else {
188  super.attributeChanged(attribute);
189  }
190  }
191 
197  protected abstract void setSchemaFileName();
198 
207  public void initialize() throws IllegalActionException
208  {
209  super.initialize();
210  /*Initialize variables
211  */
212  _errsig = 0;
213  _errmsg = "";
214  _firecount = 0;
215 
217 
218  /*check if configuration file exists
219  */
221 
222  /*set configuration file path
223  */
225  /*check if schema file exists
226  */
228 
229  /*check if the operation system is Mac OS X
230  */
231  checkOperatingSystem();
232 
233  /* Make instance of the BACnet device manager */
235 
236  /*check if the BACnet-stack library has been compiled
237  */
238  checkBACnetStackCompilation();
239 
240  /*Validate configuration file syntax
241  */
242  validateSyntax();
243 
244  /*Store data in configuration file to bot_arr
245  */
247 
248  /*Store the device instance array to devins_arr
249  */
251  nDev = devins_arr.size();
252 
253  /*Check if object type is part of the standard
254  */
256 
257  /*Check if property name is part of the standard
258  */
260 
261  /*Validate device connection specified in configuration file
262  */
263  validateDevice();
264 
265  /* Read all the properties specified in configuration file,
266  and store it to prop_arr
267  */
269  nPro = prop_arr.size();
270 
271  // Assign storage for arrays
272  propval_arr = new ArrayList<String>(nPro);
273  consout_arr = new ArrayList<String>(nPro);
274  propval_arr_temp = new ArrayList<String>(nPro);
275  consout_arr_temp = new ArrayList<String>(nPro);
276  exitval_arr = new ArrayList<Integer>(nPro);
277 
278  devcon_arr = new ArrayList<Integer>(nDev);
279  }
280 
288  public void checkConfFileExists() throws IllegalActionException
289  {
290  try{
291  final File confile = configurationFile.asFile();
292  //check if file exists
293  if(!confile.exists())
294  throw new IllegalActionException("The configuration file '"
295  + confile.getPath() +
296  "' cannot be found.");
297  }
298  catch(NullPointerException e)
299  {
300  String em;
301  if (e.getMessage() == null)
302  em = "Failed to read configuration file in BACnetReader or BACnetWriter." + LS +
303  "Check parameters of these actors.";
304  else
305  em = e.getMessage();
306  throw new IllegalActionException(em);
307  }
308  }
309 
314  public void setConfigurationFilePath() throws IllegalActionException
315  {
316  configurationFilePath = configurationFile.asFile().getPath();
317  }
318 
324  public void checkSchemaFileExists() throws IllegalActionException
325  {
326  File schemaFile = new File(schemaFileName);
327  if(!schemaFile.exists())
328  throw new IllegalActionException("The schema file '" + schemaFileName
329  + "' cannot be found.");
330  }
331 
338  void checkOperatingSystem() throws IllegalActionException
339  {
340  if(osName.startsWith("Mac"))
341  throw new IllegalActionException( "This program is only working on Windows and Linux."
342  + LS + "The operating system '" + osName + "' is not supported.");
343  }
344 
352  void checkBACnetStackCompilation() throws IllegalActionException
353  {
354  String globalwi = bacDevMan.getGlobalwiBinaryPath();
355  String bacrp = bacDevMan.getReadPropertyBinaryPath();
356  String bacwp = bacDevMan.getWritePropertyBinaryPath();
357  File fglobalwi = new File(globalwi);
358  File fbacrp = new File(bacrp);
359  File fbacwp = new File(bacwp);
360  if(!fglobalwi.exists() || !fbacrp.exists() || !fbacwp.exists())
361  throw new IllegalActionException
362  ("The BACnet-stack library has not been compiled."
363  + LS + "Please compile it.");
364  }
365 
375  public ArrayList<BACnetObjectType> readXMLConfigurationFile()
376  throws IllegalActionException
377  {
378  ArrayList<BACnetObjectType> confdata = new ArrayList<BACnetObjectType>();
379  try{
380  confdata = bacDevMan.parseBACnetObjectType(configurationFilePath);
381  }
382  catch(SAXException e)
383  {
384  throw new IllegalActionException(e.getMessage());
385  }
386  catch(ParserConfigurationException e)
387  {
388  throw new IllegalActionException(e.getMessage());
389  }
390  catch(IOException e)
391  {
392  throw new IllegalActionException(e.getMessage());
393  }
394  return confdata;
395  }
396 
405  public ArrayList<Integer> readDeviceArray() throws
406  IllegalActionException
407  {
408  ArrayList<Integer> devint = new ArrayList<Integer>();
409  try{
410  devint = bacDevMan.readDeviceArray(bot_arr);
411  }
412  catch(NumberFormatException e)
413  {
414  throw new IllegalActionException(e.getMessage());
415  }
416  return devint;
417  }
418 
427  public void checkConnection() throws IllegalActionException
428  {
429  ArrayList<Integer> devintcon = new ArrayList<Integer>();
430  devintcon = bacDevMan.findDevice();
431  devcon_arr = devintcon;
432  }
433 
434 
443  public void validateDevice() throws IllegalActionException
444  {
445  checkConnection();
446  for(int i=0; i<devins_arr.size();i++)
447  {
448  int dev = devins_arr.get(i);
449  boolean foundDevice = false;
450  for(int j=0; j<devcon_arr.size(); j++)
451  {
452  if(dev==devcon_arr.get(j))
453  foundDevice = true;
454  }
455  if(!foundDevice)
456  {
457  String em = "The specified device with instance number "
458  + Integer.toString(dev) + " cannot be found in the network,"
459  + LS + " please check your configuration file and check the network connection.";
460  throw new IllegalActionException(em);
461  }
462  }
463  }
464 
475  public void validateObjectType() throws IllegalActionException
476  {
477  for(int i=0; i<devins_arr.size();i++)
478  {
479  int devinst = devins_arr.get(i);
480  ArrayList<BACnetObject> objlist = new ArrayList<BACnetObject>();
481  //read object list for each device
482  try
483  {
484  objlist = bacDevMan.readObjectList(bot_arr,devinst);
485  }
486  catch(NumberFormatException e)
487  {
488  throw new IllegalActionException(e.getMessage());
489  }
490  //validate each object type
491  for(int j=0;j<objlist.size();j++)
492  {
493  BACnetObject bacobj = objlist.get(j);
494  try
495  {
496  bacDevMan.validateObjectType(bacobj.getObjectType());
497  }
498  catch(IllegalArgumentException e)
499  {
500  throw new IllegalActionException(e.getMessage());
501  }
502  }
503  }
504  }
505 
515  public void validatePropertyName() throws IllegalActionException
516  {
517  for(int i=0; i<bot_arr.size();i++)
518  {
519  BACnetObjectType bot = bot_arr.get(i);
520  //get the property map arraylist of each BACnetObjectType
521  ArrayList<BACnetPropertyValue> mapPI = bot.getBOTPI();
522  //iterate through the arraylist
523  for(int j=0; j<mapPI.size();j++)
524  {
525  BACnetPropertyValue bpv = mapPI.get(j);
526  String piname = bpv.getName();
527  bacDevMan.validatePropertyName(piname);
528  }
529  }
530  }
531 
542  public void validateAttributes() throws IllegalActionException
543  {
544  for(int i=0; i<bot_arr.size();i++)
545  {
546  BACnetObjectType bot = bot_arr.get(i);
547  //get the property map arraylist of each BACnetObjectType
548  ArrayList<BACnetPropertyValue> mapPI = bot.getBOTPI();
549  //iterate through the arraylist
550  for(int j=0; j<mapPI.size();j++)
551  {
552  BACnetPropertyValue bpv = mapPI.get(j);
553  String[] propval = bpv.getValue();
554  String apptag = propval[1];
555  //check if application tag is part of the standard
556  bacDevMan.validateApplicationTag(apptag);
557  }
558  }
559  }
560 
572  public ArrayList<BACnetCompleteProperty> readDevicePropertyArray()
573  throws IllegalActionException
574  {
575  ArrayList<BACnetCompleteProperty> proparr = new ArrayList<BACnetCompleteProperty>();
576  for(int i=0; i<devins_arr.size(); i++)
577  {
578  int devins = devins_arr.get(i);
579  ArrayList<BACnetCompleteProperty> devproparr =
580  new ArrayList<BACnetCompleteProperty>();
581  try
582  {
583  devproparr = bacDevMan.readDevicePropertyList(bot_arr,devins);
584  }
585  catch(NumberFormatException e)
586  {
587  throw new IllegalActionException(e.getMessage());
588  }
589 
590  for(int j=0; j<devproparr.size();j++)
591  {
592  BACnetCompleteProperty bcp = devproparr.get(j);
593  proparr.add(bcp);
594  }
595  }
596  proparr.trimToSize();
597  return proparr;
598  }
599 
604  {
605  Object[] propval_arr_obj = new String[nPro];
606  String[] propval_arr_str = (String[]) propval_arr.toArray(propval_arr_obj);
607  String[] propval_arr_temp_str = new String[propval_arr_obj.length];
608  System.arraycopy(propval_arr_str,0,propval_arr_temp_str,0,nPro);
609  propval_arr_temp = new ArrayList<String>(Arrays.asList(propval_arr_temp_str));
610 
611  Object[] consout_arr_obj = new String[nPro];
612  String[] consout_arr_str = (String[])consout_arr.toArray(consout_arr_obj);
613  String[] consout_arr_temp_str = new String[consout_arr_obj.length];
614  System.arraycopy(consout_arr_str,0,consout_arr_temp_str,0,nPro);
615  consout_arr_temp = new ArrayList<String>(Arrays.asList(consout_arr_temp_str));
616  }
617 
626  private boolean throwExceptions(){
627  return ( (_continueWhenError==false ) || (_firecount == 1 ) );
628  }
629 
639  public void executeProcess(ArrayList<ProcessBuilder> process_arr)
640  throws IllegalActionException
641  {
642  Process p = null;
643  String line = "";
644  String allline = ""; //for all console outputs
645  String infoline = ""; //for only useful information
646  //increase firecount by 1
647  _firecount += 1;
648  //store new values to arraylist
649  for(int i=0;i<process_arr.size();i++){
650  try{
651  p = process_arr.get(i).redirectErrorStream(true).start();
652  }
653  catch(IOException e)
654  {
655  String em = "Error while executing processes."
656  + LS + e.getMessage();
657  _errsig = 1;
658  _errmsg = em;
659  if( throwExceptions() )
660  throw new IllegalActionException(em);
661  }
662  catch(NullPointerException e)
663  {
664  String em = "Some of the command arguments are null."
665  + LS + e.getMessage();
666  _errmsg = em;
667  _errsig = 1;
668  if( throwExceptions() )
669  throw new IllegalActionException(em);
670  }
671  catch(IndexOutOfBoundsException e)
672  {
673  String em = "The proecss list is empty." +
674  LS + e.getMessage();
675  _errsig = 1;
676  _errmsg = em;
677  if( throwExceptions() )
678  throw new IllegalActionException(em);
679  }
680  catch(SecurityException e)
681  {
682  String em = "Creation of the process is not allowed."
683  + LS + e.getMessage();
684  _errsig = 1;
685  _errmsg = em;
686  if( throwExceptions() )
687  throw new IllegalActionException(em);
688  }
689  BufferedReader br = new BufferedReader(new InputStreamReader
690  (p.getInputStream()));
691  try{
692  while((line=br.readLine())!=null)
693  {
694  allline = allline + line;
695  if(!line.startsWith("Error:") &&
696  !line.contains("BACnet Abort") && !line.contains("BACnet Reject")
697  && !line.contains("BACnet Error") && !line.contains("Null")
698  && !line.contains("TSM Error") && !line.contains("TSM Timeout")
699  && !line.contains("Abort") && !line.contains("APDU Timeout")
700  && !line.contains("Unknown Property")){
701  // propval_arr.set(i, line);
702  infoline = infoline + line;
703  }
704  else
705  {
706  String em = "The property with index " + (i+1) +
707  " in the configuration file cannot be "
708  + "read." + LS + "Please check whether this property exists." + LS
709  + "The response from BACnet is '" + line + "'." + LS;
710  _errsig = 1;
711  _errmsg += em;
712  if( throwExceptions() )
713  throw new IllegalActionException(em);
714  else{ // use data from last call
715  //set is only used to replace current element
716  // propval_arr.set(i, propval_arr_temp.get(i));
717  propval_arr.add(propval_arr_temp.get(i));
718  }
719  }
720  }
721  }
722  catch(IOException e)
723  {
724  String em = "Error while reading response." +
725  LS + e.getMessage();
726  _errmsg = em;
727  _errsig = 1;
728  if( throwExceptions() )
729  throw new IllegalActionException(em);
730  }
731  try{
732  p.waitFor();
733  }
734  catch(InterruptedException e)
735  {
736  String em = "The process of running bacnet stack" + LS
737  + "command has been interrupted" + LS +
738  e.getMessage();
739  _errsig = 1;
740  _errmsg = em;
741  if( throwExceptions() )
742  throw new IllegalActionException(em);
743  }
744  consout_arr.add(allline);
745  allline = "";
746  propval_arr.add(infoline);
747  infoline = "";
748  int exit = p.exitValue();
749  if(exit!=0)
750  {
751  String em = "BACnet-stack process quit abnormally.";
752  _errmsg = em;
753  _errsig = 1;
754  if( throwExceptions() )
755  throw new IllegalActionException(em);
756  }
757  // exitval_arr.set(i, exit);
758  exitval_arr.add(exit);
759  }
760  consout_arr.trimToSize();
761  propval_arr.trimToSize();
762  exitval_arr.trimToSize();
763  }
764 
768  public Token[] transformArrayList(ArrayList<String> data_str)
769  {
770  Token[] valArray = new Token[data_str.size()];
771  for(int i=0; i<data_str.size(); i++)
772  valArray[i] = new StringToken( data_str.get(i) );
773  return valArray;
774  }
775 
784  public void prepareTokensToSend() throws IllegalActionException
785  {
788  //error signal and error message have been handled in
789  //executeprocess
792  }
793 
796 
797 
804  public void sendToken() throws IllegalActionException
805  {
806  errorSignal.send(0,new IntToken(_errsig));
807  errorMessage.send(0,new StringToken(_errmsg));
808  consoleArr.send(0,new ArrayToken(BaseType.STRING,consout_tok));
809  }
810 
816  public void validateSyntax() throws IllegalActionException
817  {
818 
819  try{
820  Schema schema = bacDevMan.loadSchema(schemaFileName);
821  bacDevMan.validateXMLFile(configurationFilePath,schema);
822  }
823  catch(FileNotFoundException e)
824  {
825  throw new IllegalActionException(e.getMessage());
826  }
827  catch(IOException e)
828  {
829  throw new IllegalActionException(e.getMessage());
830  }
831  catch (SAXException e) {
832  throw new IllegalActionException(e.getMessage());
833  }
834 
835  }
841  public void removeToken() throws IllegalActionException
842  {
843  propval_arr.clear();
844  consout_arr.clear();
845  exitval_arr.clear();
846  }
847 
850 
854  public TypedIOPort errorMessage;
855 
858  public TypedIOPort errorSignal;
859 
862  protected TypedIOPort consoleArr;
863 
866  protected Parameter errorMessage_tokenProductionRate;
867 
871  protected Parameter errorMessage_tokenInitProduction;
872 
875  private int _errsig;
876 
879  private String _errmsg;
880 
882  public Parameter continueWhenError;
883 
885  protected boolean _continueWhenError;
886 
889  public FileParameter configurationFile;
890 
893  protected String configurationFilePath;
894 
897  protected String schemaFileName;
898 
901  private ArrayList<BACnetObjectType> bot_arr;
902 
906  private ArrayList<Integer> devins_arr;
907 
911  private ArrayList<Integer> devcon_arr;
912 
916  protected ArrayList<BACnetCompleteProperty> prop_arr;
917 
920  protected ArrayList<ProcessBuilder> proc_arr;
921 
924  private ArrayList<String> propval_arr;
925 
929  private ArrayList<String> propval_arr_temp;
930 
933  protected Token[] propval_tok;
934 
938  protected ArrayList<String> consout_arr;
939 
943  private ArrayList<String> consout_arr_temp;
944 
947  protected Token[] consout_tok;
948 
951  protected ArrayList<Integer> exitval_arr;
952 
954  private int _firecount;
955 
957  public final static String FS = System.getProperty("file.separator");
958 
960  public final static String LS = System.getProperty("line.separator");
961 
963  public final static String bcvtbhome = System.getenv("BCVTB_HOME");
964 
966  public final static String osName= System.getProperty("os.name");
967 
970 
972  private int nDev;
974  private int nPro;
975 }
void checkConnection()
Check if the connection is lost.
Definition: BACnet.java:427
String schemaFileName
Schema file path.
Definition: BACnet.java:897
void checkSchemaFileExists()
Check if schema file exists.
Definition: BACnet.java:324
void validateDevice()
validate device specified in configuration file.
Definition: BACnet.java:443
boolean _continueWhenError
Parameter to control whether to contine if there was an error message.
Definition: BACnet.java:885
ArrayList< Integer > readDeviceArray()
Read the device array from the configuration file.
Definition: BACnet.java:405
for i
Definition: compile.m:69
BACnetDeviceManager bacDevMan
The BACnet device manager.
Definition: BACnet.java:969
ArrayList< Integer > devins_arr
ArrayList containing device instance number read from configuration file.
Definition: BACnet.java:906
boolean throwExceptions()
Returns true if an exception should be thrown, or false if only an error message should be sent to th...
Definition: BACnet.java:626
void validatePropertyName()
Validate property name.
Definition: BACnet.java:515
Object clone(Workspace workspace)
Clone the actor into the specified workspace.
Definition: BACnet.java:164
ArrayList< String > consout_arr
ArrayList containing strings of response from device for both reading and writing process...
Definition: BACnet.java:938
void validateObjectType()
Validate Object Type.
Definition: BACnet.java:475
This class reads the XML configuration file and stores the data in the BACnetObjectType data type...
int _errsig
signal to indicate whether there is an error, 0 means right, 1 means wrong
Definition: BACnet.java:875
String configurationFilePath
String of configuration file path.
Definition: BACnet.java:893
ArrayList< BACnetObjectType > readXMLConfigurationFile()
Read the xml configuration file, store the elements to BACnetObjectType ArrayList.
Definition: BACnet.java:375
int _firecount
parameter indicate how many times executeProcess function has been run
Definition: BACnet.java:954
void removeToken()
Remove tokens in previous time step.
Definition: BACnet.java:841
int nDev
Number of BACnet devices specified in the configuration file.
Definition: BACnet.java:972
void validateSyntax()
Validate xml configuration file syntax.
Definition: BACnet.java:816
This is an abstract base class for actors that generates an output stream.
Definition: BACnet.java:117
void checkConfFileExists()
Check if configuration file exists.
Definition: BACnet.java:288
static final String FS
File seperator.
Definition: BACnet.java:957
ArrayList< String > propval_arr
ArrayList containing strings of prperty values read from device.
Definition: BACnet.java:924
void setConfigurationFilePath()
Set configuration file path.
Definition: BACnet.java:314
BACnet(CompositeEntity container, String name)
Construct an actor with the given container and name.
Definition: BACnet.java:128
Parameter errorMessage_tokenProductionRate
The rate parameter for the errorMessage port.
Definition: BACnet.java:866
This object stores information of BACnet objects.
This class is used to create objects that have the information from the xml configuration file...
Token[] consout_tok
Token array of console outputs.
Definition: BACnet.java:947
ArrayList< String > consout_arr_temp
ArrayList temporarily holding console outputs read from previous time step.
Definition: BACnet.java:943
void executeProcess(ArrayList< ProcessBuilder > process_arr)
Execute Processes, store results to consoleoutput_arr and exitvalue-arr.
Definition: BACnet.java:639
void initialize()
Initialization section, initialize variiables and check possible errors.
Definition: BACnet.java:207
This class stores the BACnet property name and property value array pair.
static final String osName
Name of the operating system.
Definition: BACnet.java:966
void attributeChanged(Attribute attribute)
Override the base class to determine which argument is being used.
Definition: BACnet.java:183
FileParameter configurationFile
Parameter to specify the path for configuraton file.
Definition: BACnet.java:889
This is the driver class in BACnet.
ArrayList< BACnetCompleteProperty > prop_arr
Arraylist containing BACnetCompleteProperty read from configuration file.
Definition: BACnet.java:916
TypedIOPort errorMessage
The errorMessage port.
Definition: BACnet.java:854
ArrayList< Integer > devcon_arr
ArrayList containing device instance number that are found in the network.
Definition: BACnet.java:911
Parameter continueWhenError
Parameter to control whether to contine if there was an error message.
Definition: BACnet.java:882
TypedIOPort consoleArr
The port that send response from console.
Definition: BACnet.java:862
static final String LS
Line Seperator.
Definition: BACnet.java:960
void sendToken()
Sends the error signal to the errorSignal port, the error message to the errorMessage port...
Definition: BACnet.java:804
Token[] transformArrayList(ArrayList< String > data_str)
Transform String Arraylist to Token Arrays.
Definition: BACnet.java:768
void prepareTokensToSend()
Get tokens to send for the next timestep.
Definition: BACnet.java:784
void validateAttributes()
Validate application tag, priority and index.
Definition: BACnet.java:542
ArrayList< ProcessBuilder > proc_arr
Arraylist containing processes to be executed in console.
Definition: BACnet.java:920
void storeDataInLastTimeStep()
Store response from last time step.
Definition: BACnet.java:603
ArrayList< String > propval_arr_temp
ArrayList temporarily holding property values read from previous time step.
Definition: BACnet.java:929
ArrayList< BACnetObjectType > bot_arr
ArrayList containing elements read from configuration file.
Definition: BACnet.java:901
TypedIOPort errorSignal
The port that outputs the error signal.
Definition: BACnet.java:858
String _errmsg
detailed error message
Definition: BACnet.java:879
int nPro
Number of BACnet properties specified in the configuration file.
Definition: BACnet.java:974
static final String bcvtbhome
String that points to root directory of the BCVTB.
Definition: BACnet.java:963
Token[] propval_tok
Token array of property values.
Definition: BACnet.java:933
Parameter errorMessage_tokenInitProduction
The rate parameter for the errorMessage port that declares the initial production.
Definition: BACnet.java:871
ArrayList< Integer > exitval_arr
ArrayList containing strings process exit values for each process.
Definition: BACnet.java:951
ArrayList< BACnetCompleteProperty > readDevicePropertyArray()
Read all properties listed in the configuration file.
Definition: BACnet.java:572
abstract void setSchemaFileName()
Abstract class that sets the schema file name.