|
|
@@ -499,6 +499,121 @@ static int proc_modbus(dictionary *dic, int op, modbus_data_t *mb)
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+static int proc_phase_3_1(dictionary *dic,int op,phase_seq_3_1_t *ph_1)
|
|
|
+{
|
|
|
+ int r=0;
|
|
|
+ char temp[100];
|
|
|
+ char *p,*token=NULL;
|
|
|
+
|
|
|
+ if(op==PARAS_CHECK) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (op==PARAS_CREATE) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (op==PARAS_WRITE) {
|
|
|
+ r = proc_phase_3_1(dic, PARAS_CHECK, ph_1);
|
|
|
+ if(r) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ token = "ph_3_1:phase";
|
|
|
+ if(op==PARAS_READ) {
|
|
|
+ const char * str = iniparser_getstring(dic, token,NULL);
|
|
|
+ if(str == NULL) {
|
|
|
+ LOGE("___ iniparser_getstring %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ memcpy(&ph_1->phase_seq[0],str,strlen(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sprintf(temp, "%s", ph_1->phase_seq);
|
|
|
+ r = iniparser_set(dic, token, temp);
|
|
|
+ if(r) {
|
|
|
+ LOGE("___ iniparser_set %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ r = 0;
|
|
|
+ if(op==PARAS_READ) {
|
|
|
+ r = proc_phase_3_1(dic, PARAS_CHECK, ph_1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
+static int proc_phase_3_2(dictionary *dic,int op,phase_seq_3_2_t *ph_2)
|
|
|
+{
|
|
|
+ int r=0;
|
|
|
+ char temp[100];
|
|
|
+ char *p,*token=NULL;
|
|
|
+
|
|
|
+ if(op==PARAS_CHECK) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (op==PARAS_CREATE) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (op==PARAS_WRITE) {
|
|
|
+ r = proc_phase_3_2(dic, PARAS_CHECK, ph_2);
|
|
|
+ if(r) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ token = "ph_3_2:phase_left";
|
|
|
+ if(op==PARAS_READ) {
|
|
|
+ const char * str = iniparser_getstring(dic, token,NULL);
|
|
|
+ if(str == NULL) {
|
|
|
+ LOGE("___ iniparser_getstring %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ memcpy(&ph_2->phase_left[0],str,strlen(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sprintf(temp, "%s", ph_2->phase_left);
|
|
|
+ r = iniparser_set(dic, token, temp);
|
|
|
+ if(r) {
|
|
|
+ LOGE("___ iniparser_set %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ token = "ph_3_2:phase_right";
|
|
|
+ if(op==PARAS_READ) {
|
|
|
+ const char * str = iniparser_getstring(dic, token,NULL);
|
|
|
+ if(str == NULL) {
|
|
|
+ LOGE("___ iniparser_getstring %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ memcpy(&ph_2->phase_right[0],str,strlen(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sprintf(temp, "%s", ph_2->phase_right);
|
|
|
+ r = iniparser_set(dic, token, temp);
|
|
|
+ if(r) {
|
|
|
+ LOGE("___ iniparser_set %s failed\n", token);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ r = 0;
|
|
|
+ if(op==PARAS_READ) {
|
|
|
+ r = proc_phase_3_2(dic, PARAS_CHECK, ph_2);
|
|
|
+ }
|
|
|
+
|
|
|
+ return r;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
static int proc_sensor(dictionary *dic, int op, sensor_th_t sensor[])
|
|
|
{
|
|
|
int r=0;
|
|
|
@@ -3520,6 +3635,16 @@ static dictionary* ini_load(char *path, paras_data_t *info)
|
|
|
if(r){
|
|
|
LOGE("proc_snmp failed\n");
|
|
|
}
|
|
|
+
|
|
|
+ r=proc_phase_3_1(dic,PARAS_READ,&info->phase_seq);
|
|
|
+ if(r){
|
|
|
+ LOGE("proc_phase_3_1 failed\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ r=proc_phase_3_2(dic,PARAS_READ,&info->phase_seq_2);
|
|
|
+ if(r){
|
|
|
+ LOGE("proc_phase_3_2 failed\n");
|
|
|
+ }
|
|
|
return dic;
|
|
|
}
|
|
|
static int ini_check(char *path)
|
|
|
@@ -3606,9 +3731,18 @@ static int ini_reset(paras_handle_t *h)
|
|
|
fprintf(fp, "version = \"%d\"\n", p->snmp.version);
|
|
|
fprintf(fp, "public = \"%s\"\n", p->snmp.publics);
|
|
|
fprintf(fp, "trap_mode = \"%d\"\n", p->snmp.trapmode);
|
|
|
- fprintf(fp, "nms_ip = \"%s\"\n", p->snmp.nms_ip);
|
|
|
+ fprintf(fp, "nms_ip = \"%s\"\n", p->snmp.nms_ip);
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
|
+ fprintf(fp, "[ph_3_1]\n");
|
|
|
+ fprintf(fp, "phase = \"%s\"\n", p->phase_seq.phase_seq);
|
|
|
+ fprintf(fp, "\n");
|
|
|
+
|
|
|
+ fprintf(fp, "[ph_3_2]\n");
|
|
|
+ fprintf(fp, "phase_left = \"%s\"\n", p->phase_seq_2.phase_left);
|
|
|
+ fprintf(fp, "phase_right = \"%s\"\n", p->phase_seq_2.phase_right);
|
|
|
+ fprintf(fp, "\n");
|
|
|
+
|
|
|
fclose(fp);
|
|
|
if(h->dic) {
|
|
|
iniparser_freedict(h->dic);
|
|
|
@@ -3647,7 +3781,20 @@ static int ini_save(paras_handle_t *h)
|
|
|
if(r) {
|
|
|
LOGE("___ini_w_snmp failed\n");
|
|
|
return -1;
|
|
|
- }
|
|
|
+ }
|
|
|
+ r=proc_phase_3_1(h->dic,PARAS_WRITE,&h->paras.phase_seq);
|
|
|
+ if(r){
|
|
|
+ LOGE("proc_phase_3_1 failed\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ r=proc_phase_3_2(h->dic,PARAS_WRITE,&h->paras.phase_seq_2);
|
|
|
+ if(r){
|
|
|
+ LOGE("proc_phase_3_2 failed\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
FILE *fp=fopen(h->path, "w");
|
|
|
if(!fp) {
|
|
|
LOGE("___%s open failed\n", h->path);
|