00001 package ;
00002
00003
00011
00012
00013 import config.*;
00014
00015
00016 class Param_Impl implements Param {
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 String m_name;
00031 private float m_value;
00032 private float m_loAlarm;
00033 private float m_loWarn;
00034 private float m_hiWarn;
00035 private float m_hiAlarm;
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 public Param_Impl() {
00046 p_is_valid = false;
00047 }
00048
00049 public Param_Impl(config.Configuration db, config.ConfigObject obj) {
00050 init_config_params(db, obj);
00051 }
00052
00053 public void init_config_params(config.Configuration db, config.ConfigObject obj) {
00054 p_db = db;
00055 p_obj = obj;
00056 p_was_read = false;
00057 p_is_valid = true;
00058 p_uid = p_obj.UID();
00059 p_class_name = p_obj.class_name();
00060 }
00061
00062 public String UID() {
00063 return p_uid;
00064 }
00065
00066 public String class_name() {
00067 return p_class_name;
00068 }
00069
00070 public void update(boolean set_non_valid) {
00071 if(set_non_valid == true) {
00072 p_is_valid = false;
00073 }
00074 else {
00075 p_was_read = false;
00076 p_obj.clean();
00077 init();
00078 }
00079 }
00080
00081 public void unread() {
00082 p_was_read = false;
00083 }
00084
00085 public boolean is_valid() {
00086 return p_is_valid;
00087 }
00088
00089
00090
00091 private void init() throws config.NotFoundException, config.NotValidException, config.SystemException {
00092 if(p_was_read == true) {return;}
00093
00094 if(p_is_valid == false) {
00095 String text = "ERROR [.Param_Impl.init()]: object " + p_uid + "@" + p_class_name + " is not valid";
00096 System.err.println(text);
00097 throw new config.NotValidException(text);
00098 }
00099
00100 m_name = p_obj.get_string("name");
00101 m_name = (String)p_db.convert((Object)m_name, p_obj, "name");
00102
00103 m_value = p_obj.get_float("value");
00104
00105 m_loAlarm = p_obj.get_float("loAlarm");
00106
00107 m_loWarn = p_obj.get_float("loWarn");
00108
00109 m_hiWarn = p_obj.get_float("hiWarn");
00110
00111 m_hiAlarm = p_obj.get_float("hiAlarm");
00112
00113
00114 p_was_read = true;
00115
00116 }
00117
00118 public String get_name() {
00119 if(p_was_read == false) {init();}
00120 return m_name;
00121 }
00122
00123 public void set_name(String value) {
00124 p_obj.clean();
00125 p_obj.set_string("name", value);
00126 }
00127
00128 public float get_value() {
00129 if(p_was_read == false) {init();}
00130 return m_value;
00131 }
00132
00133 public void set_value(float value) {
00134 p_obj.clean();
00135 p_obj.set_float("value", value);
00136 }
00137
00138 public float get_loAlarm() {
00139 if(p_was_read == false) {init();}
00140 return m_loAlarm;
00141 }
00142
00143 public void set_loAlarm(float value) {
00144 p_obj.clean();
00145 p_obj.set_float("loAlarm", value);
00146 }
00147
00148 public float get_loWarn() {
00149 if(p_was_read == false) {init();}
00150 return m_loWarn;
00151 }
00152
00153 public void set_loWarn(float value) {
00154 p_obj.clean();
00155 p_obj.set_float("loWarn", value);
00156 }
00157
00158 public float get_hiWarn() {
00159 if(p_was_read == false) {init();}
00160 return m_hiWarn;
00161 }
00162
00163 public void set_hiWarn(float value) {
00164 p_obj.clean();
00165 p_obj.set_float("hiWarn", value);
00166 }
00167
00168 public float get_hiAlarm() {
00169 if(p_was_read == false) {init();}
00170 return m_hiAlarm;
00171 }
00172
00173 public void set_hiAlarm(float value) {
00174 p_obj.clean();
00175 p_obj.set_float("hiAlarm", value);
00176 }
00177
00178 public config.ConfigObject config_object() {
00179 return p_obj;
00180 }
00181
00182 public void print(String dx) {
00183 System.out.println(dx + "Param object:" );
00184 System.out.println(dx + " id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00185
00186
00187
00188
00189 System.out.println(dx + " name: " + get_name());
00190 System.out.println(dx + " value: " + get_value());
00191 System.out.println(dx + " loAlarm: " + get_loAlarm());
00192 System.out.println(dx + " loWarn: " + get_loWarn());
00193 System.out.println(dx + " hiWarn: " + get_hiWarn());
00194 System.out.println(dx + " hiAlarm: " + get_hiAlarm());
00195
00196
00197
00198
00199 }
00200
00206 public void destroy(config.Configuration db) {
00207 db.destroy(config_object());
00208 }
00209 }