  
//////////////////////////////////////////////////////////////////////////////  
// Functions for msg_conv und cmd_conv  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetMsgConv(string dpe,anytype &dpc)  
{  
  int         i,num_conv,imp_rstval,imp_edge,round_val,linint_num,  
              poly_grade,Id=paMyModuleId();  
  bool        trig_up,round_inv;  
  float       log_base,trig_lim,null_from,null_to,null_res,  
              linint1_x,linint1_y,linint2_x,linint2_y,linint3_x,linint3_y,  
              linint4_x,linint4_y,linint5_x,linint5_y,  
              poly_a,poly_b,poly_c,poly_d,poly_e;  
  string      config=paGetDpConfig(globalOpenConfig[Id]);  
  dyn_int     list_conv;  
  dyn_anytype dany,da;  
  
  dpGet(dpe+":"+config+".._num_conv",num_conv,  
        dpe+":"+config+".._list_conv",list_conv);  
  
  dpc[1]=num_conv;  
  dpc[2]=list_conv;  
  dpc[3]=dany;  
  
  for (i=1;i<=num_conv;i++)  
  {  
    dany[i]=da;  
    switch (list_conv[i])  
    {  
      case DPDETAIL_CONV_INVERT:  
        dpc[3][i]=dany[i];  
        break;  
      case DPDETAIL_CONV_LIN_INT:  
        dpGet(dpe+":"+config+"."+i+"._linint_num",linint_num,  
              dpe+":"+config+"."+i+"._linint1_x",linint1_x,  
              dpe+":"+config+"."+i+"._linint1_y",linint1_y,  
              dpe+":"+config+"."+i+"._linint2_x",linint2_x,  
              dpe+":"+config+"."+i+"._linint2_y",linint2_y,  
              dpe+":"+config+"."+i+"._linint3_x",linint3_x,  
              dpe+":"+config+"."+i+"._linint3_y",linint3_y,  
              dpe+":"+config+"."+i+"._linint4_x",linint4_x,  
              dpe+":"+config+"."+i+"._linint4_y",linint4_y,  
              dpe+":"+config+"."+i+"._linint5_x",linint5_x,  
              dpe+":"+config+"."+i+"._linint5_y",linint5_y);  
        dany[i][1]=linint_num;  
        dany[i][2]=linint1_x;  
        dany[i][3]=linint1_y;  
        dany[i][4]=linint2_x;  
        dany[i][5]=linint2_y;  
        dany[i][6]=linint3_x;  
        dany[i][7]=linint3_y;  
        dany[i][8]=linint4_x;  
        dany[i][9]=linint4_y;  
        dany[i][10]=linint5_x;  
        dany[i][11]=linint5_y;  
        dpc[3][i]=dany[i];  
        break;  
      case DPDETAIL_CONV_LOG:  
        dpGet(dpe+":"+config+"."+i+"._log_base",log_base); 
        dany[i][1]=log_base;  
        dpc[3][i]=dany[i]; 
        break;  
      case DPDETAIL_CONV_POLY:  
        dpGet(dpe+":"+config+"."+i+"._poly_grade",poly_grade,  
              dpe+":"+config+"."+i+"._poly_a",poly_a,  
              dpe+":"+config+"."+i+"._poly_b",poly_b,  
              dpe+":"+config+"."+i+"._poly_c",poly_c,  
              dpe+":"+config+"."+i+"._poly_d",poly_d,  
              dpe+":"+config+"."+i+"._poly_e",poly_e);  
        dany[i][1]=poly_grade;  
        dany[i][2]=poly_a;  
        dany[i][3]=poly_b;  
        dany[i][4]=poly_c;  
        dany[i][5]=poly_d;  
        dany[i][6]=poly_e;  
        dpc[3][i]=dany[i];  
        break;  
      case DPDETAIL_CONV_PREC:  
        dpGet(dpe+":"+config+"."+i+"._round_val",round_val,  
              dpe+":"+config+"."+i+"._round_inv",round_inv);  
        dany[i][1]=round_val;  
        dany[i][2]=round_inv;  
        dpc[3][i]=dany[i]; 
        break;  
      case DPDETAIL_CONV_NULL_SUPP:  
        dpGet(dpe+":"+config+"."+i+"._null_from",null_from,  
              dpe+":"+config+"."+i+"._null_to",null_to,  
              dpe+":"+config+"."+i+"._null_res",null_res);  
        dany[i][1]=null_from;  
        dany[i][2]=null_to;  
        dany[i][3]=null_res;  
        dpc[3][i]=dany[i];  
        break;  
      case DPDETAIL_CONV_TRIGGER:  
        dpGet(dpe+":"+config+"."+i+"._trig_lim",trig_lim,  
              dpe+":"+config+"."+i+"._trig_up",trig_up);  
        dany[i][1]=trig_lim;  
        dany[i][2]=trig_up;  
        dpc[3][i]=dany[i];  
        break;  
      case DPDETAIL_CONV_COUNTER:  
        dpGet(dpe+":"+config+"."+i+"._imp_rstval",imp_rstval,  
              dpe+":"+config+"."+i+"._imp_edge",imp_edge);  
        dany[i][1]=imp_rstval;  
        dany[i][2]=imp_edge;  
        dpc[3][i]=dany[i];  
        break;  
    }  
  }  
  globalConvDpc=dpc;  
}  
  
paDpSetMsgConv(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int    i,Id=paMyModuleId(),num_conv;  
  string config=paGetDpConfig(globalOpenConfig[Id]);  
  
  getValue("num_conv","text",num_conv);
  for (i=1;i<=dpc[1];i++)  
  {  
    paErrorHandlingDpSet(  
    dpSetWait(dpe+":"+config+"."+i+"._type",dpc[2][i]),all_right);  
    switch (dpc[2][i])  
    {  
      case DPDETAIL_CONV_INVERT:  
        break;  
      case DPDETAIL_CONV_LIN_INT:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._linint_num",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._linint1_x",dpc[3][i][2],  
                  dpe+":"+config+"."+i+"._linint1_y",dpc[3][i][3],  
                  dpe+":"+config+"."+i+"._linint2_x",dpc[3][i][4],  
                  dpe+":"+config+"."+i+"._linint2_y",dpc[3][i][5],  
                  dpe+":"+config+"."+i+"._linint3_x",dpc[3][i][6],  
                  dpe+":"+config+"."+i+"._linint3_y",dpc[3][i][7],  
                  dpe+":"+config+"."+i+"._linint4_x",dpc[3][i][8],  
                  dpe+":"+config+"."+i+"._linint4_y",dpc[3][i][9],  
                  dpe+":"+config+"."+i+"._linint5_x",dpc[3][i][10],  
                  dpe+":"+config+"."+i+"._linint5_y",dpc[3][i][11]),all_right);  
        break;  
      case DPDETAIL_CONV_LOG:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._log_base",dpc[3][i][1]),all_right);  
        break;  
      case DPDETAIL_CONV_POLY:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._poly_grade",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._poly_a",dpc[3][i][2],  
                  dpe+":"+config+"."+i+"._poly_b",dpc[3][i][3],  
                  dpe+":"+config+"."+i+"._poly_c",dpc[3][i][4],  
                  dpe+":"+config+"."+i+"._poly_d",dpc[3][i][5],  
                  dpe+":"+config+"."+i+"._poly_e",dpc[3][i][6]),all_right);  
        break;  
      case DPDETAIL_CONV_PREC:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._round_val",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._round_inv",dpc[3][i][2]),all_right);  
        break;  
      case DPDETAIL_CONV_NULL_SUPP:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._null_from",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._null_to",dpc[3][i][2],  
                  dpe+":"+config+"."+i+"._null_res",dpc[3][i][3]),all_right);  
        break;  
      case DPDETAIL_CONV_TRIGGER:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._trig_lim",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._trig_up",dpc[3][i][2]),all_right);  
        break;  
      case DPDETAIL_CONV_COUNTER:  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+"."+i+"._imp_rstval",dpc[3][i][1],  
                  dpe+":"+config+"."+i+"._imp_edge",dpc[3][i][2]),all_right);  
        break;  
        default: break;  
    }  
  }  
  if (!all_right) return;
  for (i=num_conv;i>dpc[1];i--)  
  {  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":"+config+"."+i+"._type",DPDETAIL_CONV_NONE),all_right); 
    if (!all_right) break; 
  }  
}          
  
paDpCopyMsgConv(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllMsgConvAttributes(string dpe, dyn_anytype dpc)  
{  
  int        i,pos, Id=paMyModuleId();
  bool       bFixed;  
  string     config = paGetDpConfig(globalOpenConfig[Id]);
  dyn_int    conv_codes=makeDynInt(DPDETAIL_CONV_INVERT,  
                                   DPDETAIL_CONV_LIN_INT,  
                                   DPDETAIL_CONV_LOG,  
                                   DPDETAIL_CONV_POLY,  
                                   DPDETAIL_CONV_PREC,  
                                   DPDETAIL_CONV_NULL_SUPP,  
                                   DPDETAIL_CONV_TRIGGER,  
                                   DPDETAIL_CONV_COUNTER),  
             di;  
  dyn_string dsDps = dpNames("_mp_*",dpTypeName(dpe));
  dyn_string conv_names=makeDynString(getCatStr("para","conv_invert"),  
                                      getCatStr("para","conv_lin_int"),  
                                      getCatStr("para","conv_log"),  
                                      getCatStr("para","conv_poly"),  
                                      getCatStr("para","conv_prec"),  
                                      getCatStr("para","conv_null_supp"),  
                                      getCatStr("para","conv_trigger"),  
                                      getCatStr("para","conv_counter")),  
             ds;  

  daIsPcFixed( dpe+":"+config, bFixed);
  setMultiValue("Button1", "enabled", (bFixed || dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling ),
                "Button3", "enabled", (bFixed || dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling ));

  for (i=1;i<=dpc[1];i++)  
  {  
    pos=dynContains(conv_codes,dpc[2][i]);  
    if (pos>0)  
    {  
      ds[i]=conv_names[pos];  
      di[i]=conv_codes[pos];  
    }  
  }  
  setMultiValue("conv_list","items",ds,  
                "conv_num","items",di, 
                "num_conv","text",dpc[1]);
}  
  
bool paReadPanelAllMsgConvAttributes(string dpe, dyn_anytype &dpc)  
{  
  dpc=globalConvDpc;  
}  
  
paSaveAllMsgConvAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllMsgConvAttributes(dpe,dpc);  
  paDpSetMsgConv(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
