00001 package ;
00002
00003
00011
00012
00013 import config.*;
00014
00015
00016
00017
00018 import .PowerParam;
00019 import .PowerParam_Helper;
00020
00021
00022 class PowerChannel_Impl implements PowerChannel {
00023
00024
00025
00026 private config.Configuration p_db;
00027 private config.ConfigObject p_obj;
00028 private boolean p_was_read;
00029 private boolean p_is_valid;
00030 private String p_uid;
00031 private String p_class_name;
00032
00033
00034
00035
00036 private short m_id;
00037 private short m_MUR;
00038 private short m_module;
00039
00040
00041
00042
00043 private PowerParam[] m_params;
00044
00045
00046
00047
00048
00049 public PowerChannel_Impl() {
00050 p_is_valid = false;
00051 }
00052
00053 public PowerChannel_Impl(config.Configuration db, config.ConfigObject obj) {
00054 init_config_params(db, obj);
00055 }
00056
00057 public void init_config_params(config.Configuration db, config.ConfigObject obj) {
00058 p_db = db;
00059 p_obj = obj;
00060 p_was_read = false;
00061 p_is_valid = true;
00062 p_uid = p_obj.UID();
00063 p_class_name = p_obj.class_name();
00064 }
00065
00066 public String UID() {
00067 return p_uid;
00068 }
00069
00070 public String class_name() {
00071 return p_class_name;
00072 }
00073
00074 public void update(boolean set_non_valid) {
00075 if(set_non_valid == true) {
00076 p_is_valid = false;
00077 }
00078 else {
00079 p_was_read = false;
00080 p_obj.clean();
00081 init();
00082 }
00083 }
00084
00085 public void unread() {
00086 p_was_read = false;
00087 }
00088
00089 public boolean is_valid() {
00090 return p_is_valid;
00091 }
00092
00093
00094
00095 private void init() throws config.NotFoundException, config.NotValidException, config.SystemException {
00096 if(p_was_read == true) {return;}
00097
00098 if(p_is_valid == false) {
00099 String text = "ERROR [.PowerChannel_Impl.init()]: object " + p_uid + "@" + p_class_name + " is not valid";
00100 System.err.println(text);
00101 throw new config.NotValidException(text);
00102 }
00103
00104 m_id = p_obj.get_short("id");
00105
00106 m_MUR = p_obj.get_short("MUR");
00107
00108 m_module = p_obj.get_short("module");
00109
00110 {
00111 ConfigObject[] objs = p_obj.get_objects("params");
00112 m_params = new PowerParam[objs.length];
00113 for( int i = 0; i < objs.length; i++ ) {
00114 m_params[i] = PowerParam_Helper.get(p_db, objs[i]);
00115 }
00116 }
00117
00118
00119 p_was_read = true;
00120
00121 }
00122
00123 public short get_id() {
00124 if(p_was_read == false) {init();}
00125 return m_id;
00126 }
00127
00128 public void set_id(short value) {
00129 p_obj.clean();
00130 p_obj.set_short("id", value);
00131 }
00132
00133 public short get_MUR() {
00134 if(p_was_read == false) {init();}
00135 return m_MUR;
00136 }
00137
00138 public void set_MUR(short value) {
00139 p_obj.clean();
00140 p_obj.set_short("MUR", value);
00141 }
00142
00143 public short get_module() {
00144 if(p_was_read == false) {init();}
00145 return m_module;
00146 }
00147
00148 public void set_module(short value) {
00149 p_obj.clean();
00150 p_obj.set_short("module", value);
00151 }
00152
00153 public PowerParam[] get_params() {
00154 if(p_was_read == false) {init();}
00155 return m_params;
00156 }
00157
00158 public void set_params(PowerParam[] value) {
00159 p_obj.clean();
00160 config.ConfigObject[] objs = new config.ConfigObject[value.length];
00161 for(int i = 0; i < value.length; i++) {
00162 objs[i] = value[i].config_object();
00163 }
00164 p_obj.set_objects("params", objs);
00165 }
00166
00167 public config.ConfigObject config_object() {
00168 return p_obj;
00169 }
00170
00171 public void print(String dx) {
00172 System.out.println(dx + "PowerChannel object:" );
00173 System.out.println(dx + " id: \'" + UID() + "\', class name: \'" + class_name() + "\'");
00174
00175
00176
00177
00178 System.out.println(dx + " id: " + get_id());
00179 System.out.println(dx + " MUR: " + get_MUR());
00180 System.out.println(dx + " module: " + get_module());
00181
00182
00183
00184
00185 if(get_params().length > 0) {
00186 System.out.print(dx + " " + get_params().length + " object(s) in params :\n");
00187
00188 for(int i = 0; i < get_params().length; i++) {
00189 get_params()[i].print(dx.concat(" "));
00190 }
00191 }
00192 else {
00193 System.out.println(dx + " params value is empty");
00194 }
00195
00196 }
00197
00203 public void destroy(config.Configuration db) {
00204 db.destroy(config_object());
00205 }
00206 }