00001 package ;
00002
00003
00011
00012
00013 import config.*;
00014
00015
00016 class Tim_Impl implements Tim {
00017
00018
00019
00020 private config.Configuration p_db;
00021 private config.ConfigObject p_obj;
00022 private boolean p_was_read;
00023 private boolean p_is_valid;
00024 private String p_uid;
00025 private String p_class_name;
00026
00027
00028
00029
00030 private float m_triggerFrequency;
00031 private float m_resetFrequency;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 public Tim_Impl() {
00042 p_is_valid = false;
00043 }
00044
00045 public Tim_Impl(config.Configuration db, config.ConfigObject obj) {
00046 init_config_params(db, obj);
00047 }
00048
00049 public void init_config_params(config.Configuration db, config.ConfigObject obj) {
00050 p_db = db;
00051 p_obj = obj;
00052 p_was_read = false;
00053 p_is_valid = true;
00054 p_uid = p_obj.UID();
00055 p_class_name = p_obj.class_name();
00056 }
00057
00058 public String UID() {
00059 return p_uid;
00060 }
00061
00062 public String class_name() {
00063 return p_class_name;
00064 }
00065
00066 public void update(boolean set_non_valid) {
00067 if(set_non_valid == true) {
00068 p_is_valid = false;
00069 }
00070 else {
00071 p_was_read = false;
00072 p_obj.clean();
00073 init();
00074 }
00075 }
00076
00077 public void unread() {
00078 p_was_read = false;
00079 }
00080
00081 public boolean is_valid() {
00082 return p_is_valid;
00083 }
00084
00085
00086
00087 private void init() throws config.NotFoundException, config.NotValidException, config.SystemException {
00088 if(p_was_read == true) {return;}
00089
00090 if(p_is_valid == false) {
00091 String text = "ERROR [.Tim_Impl.init()]: object " + p_uid + "@" + p_class_name + " is not valid";
00092 System.err.println(text);
00093 throw new config.NotValidException(text);
00094 }
00095
00096 m_triggerFrequency = p_obj.get_float("triggerFrequency");
00097
00098 m_resetFrequency = p_obj.get_float("resetFrequency");
00099
00100
00101 p_was_read = true;
00102
00103 }
00104
00105 public float get_triggerFrequency() {
00106 if(p_was_read == false) {init();}
00107 return m_triggerFrequency;
00108 }
00109
00110 public void set_triggerFrequency(float value) {
00111 p_obj.clean();
00112 p_obj.set_float("triggerFrequency", value);
00113 }
00114
00115 public float get_resetFrequency() {
00116 if(p_was_read == false) {init();}
00117 return m_resetFrequency;
00118 }
00119
00120 public void set_resetFrequency(float value) {
00121 p_obj.clean();
00122 p_obj.set_float("resetFrequency", value);
00123 }
00124
00125 public config.ConfigObject config_object() {
00126 return p_obj;
00127 }
00128
00129 public void print(String dx) {
00130 System.out.println(dx + "Tim object:" );
00131 System.out.println(dx + " id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00132
00133
00134
00135
00136 System.out.println(dx + " triggerFrequency: " + get_triggerFrequency());
00137 System.out.println(dx + " resetFrequency: " + get_resetFrequency());
00138
00139
00140
00141
00142 }
00143
00149 public void destroy(config.Configuration db) {
00150 db.destroy(config_object());
00151 }
00152 }