// ../scripts/libs/para.ctl
//  
// Author..........: Peter Varga  
// Date............: February 1999  
// Version.........: 1.0 for PVSS II v2.10 and upwards
// Modify..........: 15.10.99 mhaslop
//                   21.05.02 peterv: mass para
//
//////////////////////////////////////////////////////////////////////////////  
//  
// This library includes procedures and functions for the para-panels.  
//  
//////////////////////////////////////////////////////////////////////////////  
// NOTICES:  
//  
// !!!
// To install a new interface driver,
// see below in section "Functions for address" 
// (serch for 'for address') 
//
// This library contains some comments and variable names in German, because  
// some functions were imported from the earlier version of para-panels.  
//  
// To use this library it is necessary to extend the dptype _Ui with two  
// dp elements: _Ui.Para.OpenConfig  
//              _Ui.Para.ModuleName  
//  
// To debug you should set the global variable paDebug to true (see initGlobals).  
//  
// To use this library in your project you should first start the routine  
// initGlobals() and initModuleNames().  
//  
// Functions used by configs are (where XXX is the name of the config, for example  
// Smooth,...) :  
//  
// paDpGetXXX                  : reads the config XXX of a dp element  
// paDpSetXXX                  : writes the config XXX of a dp element  
// paReadPanelAllXXXAttributes : reads the attributes of the config XXX from  
//                               the para-panel  
// paWritePanelAllXXXAttributes: writes the attributes of the config XXX into  
//                               the para-panel  
// paSaveAllXXXAttributes      : reads the attributes of the config XXX from the  
//                               para-panel and writes them into the dp  
// paDpCopyXXX                 : copies a dyn_anytype into another one (not used)
//                               ! z.Z. nicht verwendet !
//                               ==>> ein Beispiel siehe in paDpCopyDefault  
//  
//////////////////////////////////////////////////////////////////////////////  

//////////////////////////////////////////////////////////////////////////////  
// Definition of manager-global variables
//////////////////////////////////////////////////////////////////////////////  

global string         gMpDpstr;
global dyn_int        gMpConfigType;
global dyn_string     gMpConfigName;
global dyn_string     gMpConfigText;
global dyn_int        gMpDaConfigNumber;
global dyn_string     gMpDaConfigNameDa;
global dyn_string     gMpDaConfigName;
global string         gMpTemplateName;
global bool           gMpPowerConfigPara;
global string         gMpLastDpLocked;
global bool           gMpRightClick;
global string         globalModuleName;
global bool           gMpCustomHandling;

//////////////////////////////////////////////////////////////////////////////  
// This function removes an element of an array  
//
// NOTICE: This function should be eliminated when the bug of the
//         internal function is fixed!
//////////////////////////////////////////////////////////////////////////////  
//!!! 
dyn_anytype paDynRemove(dyn_anytype da,int idx)
{
  int         i;
  dyn_anytype db;

  for (i=1;i<idx;i++)
    db[i]=da[i];
  for (i=idx+1;i<=dynlen(da);i++)
    db[i-1]=da[i];

  return db;
}

//////////////////////////////////////////////////////////////////////////////  
// This function inserts an element into an array
//  
// NOTICE: This function should be eliminated when the bug of the
//         internal function is fixed!
//////////////////////////////////////////////////////////////////////////////  
//!!! 
dyn_anytype paDynInsertAt(dyn_anytype da,anytype a,int idx)
{
  int         i;
  dyn_anytype db;

  for (i=1;i<idx;i++)
    db[i]=da[i];
  db[idx]=a;
  for (i=idx;i<=dynlen(da);i++)
    db[i+1]=da[i];

  return db;
}

//////////////////////////////////////////////////////////////////////////////  
// This function converts a value into a string by using the format getting  
// by dpGetFormat()  
//////////////////////////////////////////////////////////////////////////////  
string ValToFormatedString(string dpe, anytype val)  
{  
  string format;  
  string valformated;  
  
  format=paDpGetFormat(dpe);  
  sprintf(valformated,format,val);  
  return(valformated);  
}   
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads the unit of a dpe  
//  
// NOTICE: This function should be eliminated when the internal function  
//         is available.  
//////////////////////////////////////////////////////////////////////////////  
//!!!  
/*
string dpGetUnit(string dpe)  
{  
int    dpaType=dpElementType(dpe);  
string unit;

if (dpaType==DPEL_FLOAT || dpaType==DPEL_DYN_FLOAT ||  
dpaType==DPEL_INT   || dpaType==DPEL_DYN_INT   ||  
dpaType==DPEL_UINT  || dpaType==DPEL_DYN_UINT)  
unit="kg";  
else  
unit="";  
return unit;  
}  
*/  
//////////////////////////////////////////////////////////////////////////////  
// This function opens a warning window in case of changing the type of  
// certain dp-configs  
//////////////////////////////////////////////////////////////////////////////  
paChangeType()  
{  
  int        ok;  
  dyn_string sPara=makeDynString(paGetCatStr("para","changetype"));  
  
  paChildPanelOn("vision/MessageWarning",  
                 paGetCatStr("para","warning"),  
                 "","",true,false,-1,-1,sPara,ok);  
}  
  
  
//////////////////////////////////////////////////////////////////////////////  
// This function initializes the needed global variables  
// globalAnytype     empty anytype-variable  
// globalDpc         contains the attribute values of the dpe-config  
// globalModuleNames contains all module names with the actual panel  
// globalOpenConfig  contains the configs being edited (DPSUB_SYS_DP_EL_CONF)  
//////////////////////////////////////////////////////////////////////////////  
paInitGlobals()  
{  
  addGlobal("globalAnytype",ANYTYPE_VAR);     
  addGlobal("globalDpc",DYN_ANYTYPE_VAR);     
  addGlobal("globalModuleNames",DYN_STRING_VAR);  
  addGlobal("globalOpenConfig",DYN_STRING_VAR);  
  addGlobal("paDebug",INT_VAR);  
  addGlobal("globalE",FLOAT_VAR);  
  addGlobal("paIsNative",DYN_BOOL_VAR);  
//!!!  globalE=2.7182818;  
  globalE=2.71828;  
  paDebug = 0;  // Debug ausgeschaltet  
  if(paDebug) DebugTN("initGlobals():");  
}   
 
//////////////////////////////////////////////////////////////////////////////  
// This function results the name of the host on which the manager is running  
//  
// NOTICE: This function should be eliminated when the internal function  
//         is available.  
//////////////////////////////////////////////////////////////////////////////  
//!!!  
string getHostName(int man_typ,int man_num)  
{  
if (man_num==myManNum())  
return getHostname();  
else  
return paGetCatStr("para","unknown");  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function initializes certain global variables  
//////////////////////////////////////////////////////////////////////////////  
int paInitModuleNames(string OpenConfig)  
{  
  int i=dynContains(globalModuleNames,myModuleName());  
  
  if (i<1)  
  {  
    i=dynAppend(globalModuleNames, myModuleName());  
    globalDpc[i]=globalAnytype;  
  }  
  paIsNative[i]=(!isMotif());  
/*!!!
  if (strpos(globalModuleNames[i],"paraPanel")>0)  
    paIsNative[i]=1;  
  else  
    paIsNative[i]=0;  
!!!*/
  globalOpenConfig[i]=OpenConfig;  
  // Debug    
  if(paDebug) DebugTN("initModuleNames():",myModuleName(),   
                     globalModuleNames,globalOpenConfig,i);   
  return(i);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function results the internel number of a mudule  
//////////////////////////////////////////////////////////////////////////////  
int paModuleId(string moduleName)  
{  
  if(paDebug) DebugTN("myModuleId():",myModuleName(),dynContains(globalModuleNames, myModuleName()));  
  return(dynContains(globalModuleNames, moduleName));  
}   
  
//////////////////////////////////////////////////////////////////////////////  
// This function results the internel number of the own mudule  
//////////////////////////////////////////////////////////////////////////////  
int paMyModuleId()  
{  
  if(paDebug) DebugTN("myModuleId():",myModuleName(),dynContains(globalModuleNames, myModuleName()));  
  return(dynContains(globalModuleNames, myModuleName()));  
}   
  
//////////////////////////////////////////////////////////////////////////////  
// This function writes the global variable globalDpc  
//////////////////////////////////////////////////////////////////////////////  
paPutGlobalDpc(string OpenConfig,dyn_anytype dpc)  
{  
  int Id=paMyModuleId(); 
  dyn_anytype da; 
  
  if(paDebug) DebugTN("vor  paPutGlobalDpc():", globalDpc[Id], Id, dpc);  
  if (Id>0)  
  {  
    // anytype initialisieren, bevor neuer Zuweisung, da anytype  
    // beinhaltet den vorigen Typ  
    // z.B.: any="abc"; ==> any=="abc"  
    //       any=123.45 ==> any=="123.45" statt any==123.45  
    globalDpc=paDynRemove(globalDpc,Id);
    globalDpc=paDynInsertAt(globalDpc,dpc,Id);
    globalOpenConfig[Id] = OpenConfig;  
  }  
  if(paDebug) DebugTN("nach paPutGlobaldpc():", globalDpc[Id], Id, dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads the global variable globalDpc  
//////////////////////////////////////////////////////////////////////////////  
dyn_anytype paGetGlobalDpc()  
{  
  int         Id;  
  dyn_anytype da; 
  
  Id = paMyModuleId();  
  if(paDebug) DebugTN("paGetGlobalDpc():","globalDpc["+Id+"]=",globalDpc[Id]);  
  if (Id>0) return(globalDpc[Id]);  
  else      return(da);   
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function compares two sets of attributes  
//////////////////////////////////////////////////////////////////////////////  
bool paCompAllConfigAttributes(dyn_anytype dpc1, dyn_anytype dpc2)  
{  
  return(dpc1 == dpc2);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function controls the config-locks  
//////////////////////////////////////////////////////////////////////////////  
paDpConnectLock(string dpa,bool locked)  
{  
  int        err;
  bool       active,all_right, isPC = false;  
  string     config=paGetDpConfig(globalOpenConfig[paMyModuleId()]);  
// !!! mp begin
  string     sType = dpTypeName(dpa), sDpe = dpSubStr(dpa, DPSUB_DP_EL);
  dyn_string dsDps = dpNames("_mp_*",sType), dsLeaf;
// !!! mp end

  if ( dpExists("_dt_" + dpTypeName(dpa)) )
  {
    dpGet("_dt_" + dpTypeName(dpa) + ".Leaf:_online.._value", dsLeaf);
    if ( strpos(sDpe, ".") < 1 ) sDpe += ".";
    strreplace(sDpe, dpSubStr(sDpe, DPSUB_DP), "_mp_" + sType);
    sDpe += ":" + config;
    isPC = ( dynContains(dsLeaf, sDpe) > 0 );
  }

  getValue("locked","enabled",active);

  if ( (locked && active) ||  // config is already locked by another para
       ( !gMpCustomHandling &&
         strpos(dpSubStr(dpa,DPSUB_DP),"_mp_") != 0 &&
         dynlen(dsDps) > 0 &&
         isPC && !isMotif()
       ) // _mp_dp exists
     )  
  {  
    setMultiValue("ok","enabled",false,  
                  "save","enabled",false,  
                  "locked","visible",true,  
                  "unlocked","visible",false);  
    if (config=="_alert_hdl")  
      setValue("aktiv","enabled",false);  
    else  
    if ( (config=="_address" || config=="_distrib") && globalAddressNew[paMyModuleId()]=="")  
      setMultiValue("p1","enabled",false,  
                    "treiber","enabled",false);  
    else  
    if (config=="_dp_fct" && globalFctNew[paMyModuleId()]=="")
    {
      setValue("p1","enabled", ( !gMpCustomHandling &&
                                 strpos(dpSubStr(dpa,DPSUB_DP),"_mp_") != 0 &&
                                 dynlen(dsDps) > 0
                               )
              );
      setValue("function","enabled",false);  
    }
  }   
  else  
  // locking config if not locked yet  
  if (active)  
  {  
    setMultiValue("ok","enabled",true,  
                  "save","visible",true,  
                  "save","enabled",true,  
                  "locked","visible",false,  
                  "locked","enabled",false,  
                  "unlocked","visible",true);  
    if ( strpos(dpSubStr(dpa,DPSUB_DP),"_mp_") == 0 && isPC && !isMotif() && !gMpCustomHandling )
      setValue("save","visible",false);  
    if ( gMpRightClick && config!="_alert_hdl" && shapeExists("cancel") )
    {
      setValue("cancel","visible",false);  
    }
    if (config=="_alert_hdl")  
      setValue("aktiv","enabled",true);  
    else  
    if ((config=="_address" || config=="_distrib") && globalAddressNew[paMyModuleId()]=="")  
      setMultiValue("p1","enabled",true,  
                    "treiber","enabled",true);  
    else  
    if (config=="_dp_fct" && globalFctNew[paMyModuleId()]=="")  
      setMultiValue("p1","enabled",true,  
                    "function","enabled",true);  

    paErrorHandlingDpSet(  
      dpSetWait(dpa,true),all_right);  
    if ( all_right )
      gMpLastDpLocked = dpa;
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function creates a string from a dyn_string using the separator sep  
// as follows: ds=makeDynString("abc","def","ghi"); sep="|";  
//             Result: "abc|def|ghi"  
//////////////////////////////////////////////////////////////////////////////  
string paJoinString(dyn_string ds,string sep)  
{  
  int    i,len=dynlen(ds);  
  string s="";  
  
  if (len<1)  
    return(s);  
  else  
  if (len==1)  
    return(ds[1]);  
  else  
  for (i=1;i<=len-1;i++)  
    s+=ds[i]+sep;  
  s+=ds[len];  
  return(s);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function results true if the config is locked by actual panel  
//////////////////////////////////////////////////////////////////////////////  
bool paIsLockedByMe()  
{  
  bool lockedByMe;  
  
  getValue("unlocked","visible",lockedByMe);  
  return(lockedByMe);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This functions control the change of the para-panels  
//////////////////////////////////////////////////////////////////////////////  
paDpConnectUi(string dpa1,string OpenConfig,string moduleName)   
{   
  int         i,Id=paMyModuleId(),ok,type,pos;  
  bool        allright=true;  
  string      dpe=dpSubStr(globalOpenConfig[Id],DPSUB_SYS_DP_EL),  
              sTxt=paGetCatStr("para","changepanel"),  
              sTxt2=paGetCatStr("para","changefct"),  
              sYes=paGetCatStr("para","yes"),  
              sNo=paGetCatStr("para","no"),  
              sCancel=paGetCatStr("para","cancel"),  
              config=paGetDpConfig(OpenConfig),  
              configOld=paGetDpConfig(globalOpenConfig[Id]),
              mn;  
  dyn_float   df;  
  dyn_string  ds,sPara=makeDynString(sTxt,sYes,sNo,sCancel),  
              sPara2=makeDynString(sTxt2,sYes,sNo);  
  dyn_anytype DpcOri=paGetGlobalDpc(),DpcAct;
 
  dpGet("_Ui_"+myManNum()+".Para.ModuleName:_original.._value",mn); 
  if (moduleName!=mn)
  return;

  if (OpenConfig=="" && globalOpenConfig[Id]=="")
    return;
  if (OpenConfig!="")  
    OpenConfig=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL)+":"+config;  
  if (Id<1 )  
  {  
    return;  
  }  
  if ( globalOpenConfig[Id]=="" && OpenConfig!="")  
  {   
    paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
    return;  
  } 
  if (config=="_dp_fct" && configOld=="_dp_fct" && globalFctOld[Id]=="" &&
      globalOpenConfig[Id]==OpenConfig && myPanelName()=="dp_function")  
  {  
    dpGet(dpe+":_dp_fct.._type",type);  
    getValue("function","selectedPos",pos);  
    if ( (type==DPCONFIG_DP_FUNCTION && pos==2)  ||  
         (type==DPCONFIG_STAT_FUNCTION && pos==1)  )  
    {  
      paChildPanelOn("vision/MessageInfo",  
                     paGetCatStr("para","warning"),  
                         "","",true,true,-1,-1,sPara2,ok);  
      if (ok==1)  
      {  
        paDeleteGlobals(Id);  
        paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
        return;  
      }  
      else  
        return;  
    }  
  }  
  if ((config=="_address" || config=="_distrib") && globalAddressOld[Id]=="")  
  {  
    paDeleteGlobals(Id);  
    paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
    return;  
  }  
  else  
  if (configOld=="_dp_fct" && config=="" && globalFctOld[Id]=="")  
  {  
    paDeleteGlobals(Id);  
    paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
    return;  
  }  
  else  
  {  
    paReadPanelAllAttributes(globalOpenConfig[Id],DpcAct);  
    if ( paCompAllConfigAttributes(DpcOri,DpcAct) )  
    {  
      paDeleteGlobals(Id);  
      paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
    }  
    else  
    {  
      if (paIsLockedByMe())  
      {  
        if (config=="" && configOld=="_dp_fct")  
        {  
          paChildPanelOn("vision/MessageInfo3",  
                         paGetCatStr("para","warning"),  
                         "","",true,true,-1,-1,sPara,ok);  
//          if (ok==1) ok=2;  
        }  
        else  
        if (config=="" && (configOld=="_address" || configOld=="_distrib"))  
        {  
          paChildPanelOn("vision/MessageInfo3",  
                         paGetCatStr("para","warning"),  
                         "","",true,true,-1,-1,sPara,ok);  
//          if (ok==1) ok=2;  
        }  
        else  
          paChildPanelOn("vision/MessageInfo3",  
                         paGetCatStr("para","warning"),  
                         "","",true,true,-1,-1,sPara,ok);  
        if (ok==1)  
        {  
          paSaveAllAttributes(globalOpenConfig[Id],allright);
          if (allright)  
          {  
            paDeleteGlobals(Id);  
            paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
          }  
        }  
        else  
        if (ok==0)  
        {  
          paDeleteGlobals(Id);  
          paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
        }  
        else  
        if (ok==2)  
        {  
        }  
      }  
      else  
      {  
        paDeleteGlobals(Id);  
        paOpenParaPanel(globalOpenConfig[Id],OpenConfig);  
      }  
    }  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function deletes every global variables of certain panel  
//////////////////////////////////////////////////////////////////////////////  
paDeleteGlobals(int Id)  
{  

/*!!!
  switch (paGetDpConfig(globalOpenConfig[Id]))  
  {  
    case "_cmd_conv":  
    case "_msg_conv": removeGlobal("globalConvDpc"); break;  
    case "_u_range":
                      removeGlobal("globalURangeDpc");  
                      removeGlobal("globalURangeDpcOld"); 
                      break;  
  } 
!!!*/
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads the values from a panel into a dyn_anytype  
// by using the config dependent functions  
//////////////////////////////////////////////////////////////////////////////  
paReadPanelAllAttributes(string dpcActPanel,dyn_anytype &DpcAct)  
{  
  int    error;
  bool   ok=true;
  string config=paGetDpConfig(dpcActPanel),  
         dpe   =dpSubStr(dpcActPanel,DPSUB_SYS_DP_EL);  
  
  switch (config)  
  {  
    case "_original" :  
      if (paIsDpeDyn(dpe))  
        paReadPanelAllOriginalDynAttributes(dpe,DpcAct);  
      else  
        paReadPanelAllOriginalAttributes(dpe,DpcAct);  
      break;  
    case "_default" :  
      if (paIsDpeDyn(dpe))  
        paReadPanelAllDefaultDynAttributes(dpe,DpcAct);  
      else  
        paReadPanelAllDefaultAttributes(dpe,DpcAct);  
      break;  
    case "_lock" :  
      paReadPanelAllLockAttributes(dpe,DpcAct);  
      break;  
    case "_common" :  
      paReadPanelAllCommonAttributes(dpe,DpcAct);  
      break;  
    case "_auth" :  
      paReadPanelAllAuthAttributes(dpe,DpcAct);  
      break;  
    case "_pv_range" :  
      paReadPanelAllPvRangeAttributes(dpe,DpcAct);  
      break;  
    case "_u_range" :  
      paReadPanelAllURangeAttributes(dpe,DpcAct);  
      break;  
    case "_dp_fct" :  
      paReadPanelAllDpFctAttributes(dpe,DpcAct,error);  // TI 17326: error inserted
      break;  
    case "_alert_class" :  
      paReadPanelAllAlertClassAttributes(dpe,DpcAct);  
      break;  
    case "_alert_hdl" :  
      paReadPanelAllAlertHdlAttributes(dpe,DpcAct);  
      break;  
    case "_msg_conv" :  
    case "_cmd_conv" :  
      paReadPanelAllMsgConvAttributes(dpe,DpcAct);  
      break;  
    case "_smooth" :  
      paReadPanelAllSmoothAttributes(dpe,DpcAct);  
      break;  
    case "_archive" :  
      paReadPanelAllArchAttributes(dpe,DpcAct);  
      break; 
    case "_distrib" : 
    case "_address" :  
      paReadPanelAllAddressAttributes(dpe,DpcAct,ok);  
      break;  
  
    default : return;  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function writes the values from a dyn_anytype into a panel  
// by using the config dependent functions  
//////////////////////////////////////////////////////////////////////////////  
paWritePanelAllAttributes(string dpcActPanel,dyn_anytype DpcAct)  
{  
  string config=paGetDpConfig(dpcActPanel),  
         dpe   =dpSubStr(dpcActPanel,DPSUB_SYS_DP_EL);  
  
  switch (config)  
  {  
    case "_original" :  
      if (paIsDpeDyn(dpe))  
        paWritePanelAllOriginalDynAttributes(dpe,DpcAct);  
      else  
        paWritePanelAllOriginalAttributes(dpe,DpcAct);  
      break;  
    case "_default" :  
      if (paIsDpeDyn(dpe))  
        paWritePanelAllDefaultDynAttributes(dpe,DpcAct);  
      else  
        paWritePanelAllDefaultAttributes(dpe,DpcAct);  
      break;  
    case "_lock" :  
      paWritePanelAllLockAttributes(dpe,DpcAct);  
      break;  
    case "_common" :  
      paWritePanelAllCommonAttributes(dpe,DpcAct);  
      break;  
    case "_auth" :  
      paWritePanelAllAuthAttributes(dpe,DpcAct);  
      break;  
    case "_pv_range" :  
      paWritePanelAllPvRangeAttributes(dpe,DpcAct);  
      break;  
    case "_u_range" :  
      paWritePanelAllURangeAttributes(dpe,DpcAct);  
      break;  
    case "_dp_fct" :  
      paWritePanelAllDpFctAttributes(dpe,DpcAct);  
      break;  
    case "_alert_class" :  
      paWritePanelAllAlertClassAttributes(dpe,DpcAct);  
      break;  
    case "_alert_hdl" :  
      paWritePanelAllAlertHdlAttributes(dpe,DpcAct);  
      break;  
    case "_msg_conv" :  
    case "_cmd_conv" :  
      paWritePanelAllMsgConvAttributes(dpe,DpcAct);  
      break;  
    case "_smooth" :  
      paWritePanelAllSmoothAttributes(dpe,DpcAct);  
      break;  
    case "_archive" :  
      paWritePanelAllArchAttributes(dpe,DpcAct);  
      break;  
    case "_distrib" :
    case "_address" :  
      paWritePanelAllAddressAttributes(dpe,DpcAct);  
      break;  
  
    default : return;  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads the attributes of the config from the  
// para-panel and writes them into the dpe and into the global variable  
// by using the config dependent functions  
//////////////////////////////////////////////////////////////////////////////  
paSaveAllAttributes(string dpcActPanel,bool &allright)  
{
  bool        bMp = false, isPC = false;
  string      config=paGetDpConfig(dpcActPanel), sDpe = dpSubStr(dpcActPanel,DPSUB_DP_EL);
  dyn_anytype dpc;  
  dyn_float   dfAnswer;
  dyn_string  dsAnswer, dps = dpNames("*", dpTypeName(dpcActPanel)), dsLeaf;
  dyn_dyn_string ddsRef;
  
  ddsRef = dpGetRefsToDpType(dpTypeName(dpcActPanel));
  
  if ( dpExists("_dt_" + dpTypeName(dpcActPanel)) )
  {
    dpGet("_dt_" + dpTypeName(dpcActPanel) + ".Leaf:_online.._value", dsLeaf);
    if ( strpos(sDpe, ".") < 1 ) sDpe += ".";
    strreplace(sDpe, dpSubStr(sDpe, DPSUB_DP), "_mp_" + dpTypeName(dpcActPanel));
    sDpe += ":" + config;
    isPC = ( dynContains(dsLeaf, sDpe) > 0 );
  }

  if ( strpos(dpSubStr(dpcActPanel,DPSUB_DP),"_mp_") == 0 &&
       config != "_original" &&
       config != "_lock" &&
       gMpPowerConfigPara == false &&
       (dynlen(dps) > 1 || dynlen(ddsRef)>0) &&
       isPC &&
       !isMotif() &&
       !gMpCustomHandling
     )
  {
    bMp = true;
    // Fragen ob wirklich, weil an allen DPs übertragen wird
    ChildPanelOnCentralModalReturn("vision/MessageInfo",
      getCatStr("para","information"),
      makeDynString(getCatStr("da","copyconfigmerge?"),
                    getCatStr("para","yes"),
                    getCatStr("para","no")),
      dfAnswer, dsAnswer);

    if ( dynlen(dfAnswer) < 1 || !dfAnswer[1] ) return;
  }
  
  switch (config)  
  {  
    case "_original" :  
      if (paIsDpeDyn(dpcActPanel))  
        paSaveAllOriginalDynAttributes(dpcActPanel,allright);  
      else  
        paSaveAllOriginalAttributes(dpcActPanel,allright);  
      break;  
    case "_default" :  
      if (paIsDpeDyn(dpcActPanel))  
        paSaveAllDefaultDynAttributes(dpcActPanel,allright);  
      else  
        paSaveAllDefaultAttributes(dpcActPanel,allright);  
      break;  
    case "_lock" :  
      paSaveAllLockAttributes(dpcActPanel,allright);  
      break;  
    case "_common" :  
      paSaveAllCommonAttributes(dpcActPanel,allright);  
      break;  
    case "_auth" :  
      paSaveAllAuthAttributes(dpcActPanel,allright);  
      break;  
    case "_pv_range" :  
      paSaveAllPvRangeAttributes(dpcActPanel,allright);  
      break;  
    case "_u_range" :  
      paSaveAllURangeAttributes(dpcActPanel,allright);  
      break;  
    case "_dp_fct" :  
      paSaveAllDpFctAttributes(dpcActPanel,allright);  
      break;  
    case "_alert_class" :  
      paSaveAllAlertClassAttributes(dpcActPanel,allright);  
      break;  
    case "_alert_hdl" :  
      paSaveAllAlertHdlAttributes(dpcActPanel,allright);  
      break;  
    case "_msg_conv" :  
    case "_cmd_conv" :  
      paSaveAllMsgConvAttributes(dpcActPanel,allright);  
      break;  
    case "_smooth" :  
      paSaveAllSmoothAttributes(dpcActPanel,allright);  
      break;  
    case "_archive" :  
      paSaveAllArchAttributes(dpcActPanel,allright);  
      break; 
    case "_distrib" : 
    case "_address" :  
      paSaveAllAddressAttributes(dpcActPanel,allright);  
      break;  
  
    default : return;  
  }
  
  // not a master datapoint, nothing to do
  if ( !bMp )
    return;
  else
  // error during dpSetWait of a config
  if ( !allright )
  {
    ChildPanelOnCentralModalReturn("vision/MessageWarning",
      getCatStr("para","warning"),
      makeDynString(getCatStr("da","_mp_dpseterror")),
      dfAnswer, dsAnswer);
    // Fehlermeldung: wird doch nicht kopiert,
    // bitte Konfig neu anlegen oder neu parametrieren
    return;
  }
  else
  if ( !isMotif() && !gMpCustomHandling )
  // merging configs to all datapoint of this type
  {
    int        i;
    string     sDp, sDpEl, sDpType = dpTypeName(dpcActPanel),
               sDtDp = "_dt_" + sDpType;
    dyn_string dsDps = dpNames("*", sDpType), daLeaf, daDynAttr;

    dpGet(sDtDp + ".Leaf:_online.._value", daLeaf,
          sDtDp + ".DynamicAttribute:_online.._value", daDynAttr);

    mpCopyConfigsToAllDps( dpSubStr(dpcActPanel,DPSUB_SYS_DP_EL), -1,
                           makeDynString(config), daLeaf, daDynAttr);
/*
    for ( i = 1; i <= dynlen(dsDps); i++ )
    {
      if ( strpos((sDp = dpSubStr(dsDps[i],DPSUB_DP)),"_mp_") == 0 ) continue;
      sDpEl = dpcActPanel;
      strreplace(sDpEl,"_mp_" + sDpType, sDp);
      //dpCopyConfigMerge für alle DPs dieses Types
DebugTN("dpCopyConfigMerge FROM " + dpcActPanel + " TO " + sDpEl);
    }
*/
  }
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads the attributes of a dp  
// by using the config dependent functions  
//////////////////////////////////////////////////////////////////////////////  
paDpGet(string dpcActPanel,anytype &dpc)  
{  
  string config=paGetDpConfig(dpcActPanel),  
         dpe=dpSubStr(dpcActPanel,DPSUB_SYS_DP_EL);  
  
  dpc=globalAnytype;  
  switch (config)  
  {  
    case "_original" :  
      if (paIsDpeDyn(dpe))  
        paDpGetOriginalDyn(dpe,dpc);  
      else  
        paDpGetOriginal(dpe,dpc);  
      break;  
    case "_default" :  
      if (paIsDpeDyn(dpe))  
        paDpGetDefaultDyn(dpe,dpc);  
      else  
        paDpGetDefault(dpe,dpc);  
      break;  
    case "_lock" :  
      paDpGetLock(dpe,dpc);  
      break;  
    case "_common" :  
      paDpGetCommon(dpe,dpc);  
      break;  
    case "_auth" :  
      paDpGetAuth(dpe,dpc);  
      break;  
    case "_pv_range" :  
      paDpGetPvRange(dpe,dpc);  
      break;  
    case "_u_range" :  
      paDpGetURange(dpe,dpc);  
      break;  
    case "_dp_fct" :  
      paDpGetDpFct(dpe,dpc);  
      break;  
    case "_alert_class" :  
      paDpGetAlertClass(dpe,dpc);  
      break;  
    case "_alert_hdl" :  
      paDpGetAlertHdl(dpe,dpc);  
      break;  
    case "_msg_conv" :  
    case "_cmd_conv" :  
      paDpGetMsgConv(dpe,dpc);  
      break;  
    case "_smooth" :  
      paDpGetSmooth(dpe,dpc);  
      break;  
    case "_archive" :  
      paDpGetArch(dpe,dpc);  
      break;  
    case "_distrib" :
    case "_address" :  
      paDpGetAddress(dpe,dpc);  
      break;  
  
    default : return;  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function opens the required para-panel  
//////////////////////////////////////////////////////////////////////////////  
paOpenParaPanel(string dpcActPanel,string dpcNewPanel)  
{  
  int        dpFctType,Id=paMyModuleId();
  bool       all_right, bLckd;  
  string     panelname="address",  
             configAct=paGetDpConfig(dpcActPanel),  
             configNew=paGetDpConfig(dpcNewPanel),  
             dpeAct=dpSubStr(dpcActPanel,DPSUB_SYS_DP_EL),  
             dpeNew=dpSubStr(dpcNewPanel,DPSUB_SYS_DP_EL);  
  dyn_string sPara;  
  
  if (dpeAct!="" && configAct!="_original" && configAct!="_lock")
  {
    dpGet(dpeAct+":_lock."+configAct+"._locked",bLckd);
    if ( paIsLockedByMe() && getSystemName()==dpSubStr(dpeAct,DPSUB_SYS) 
         && bLckd
       )  
    {
      paErrorHandlingDpSet(  
      dpSetWait(dpeAct+":_lock."+configAct+"._locked",false),all_right);  
      gMpLastDpLocked = "";
    }
  }

  switch (configNew)  
  {  
    case "" :  
      if (paIsNative[Id])  
        paRootPanelOnModule("para/dummy.pnl","",myModuleName(),makeDynString(""));  
      else  
      {  
        if ((configAct=="_address" || configAct=="_distrib")) globalAddressOld[Id]="";   
        if (configAct=="_dp_fct") globalFctOld[Id]="";   
        PanelOff();  
      }  
      break;  
    case "_original" :  
      if (paIsDpeDyn(dpeNew))  
        paRootPanelOnModule("para/original_dyn.pnl","",myModuleName(),makeDynString(dpeNew));  
      else  
        paRootPanelOnModule("para/original.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_default" :  
      if (paIsDpeDyn(dpeNew))  
        paRootPanelOnModule("para/default_dyn.pnl","",myModuleName(),makeDynString(dpeNew));  
      else  
        paRootPanelOnModule("para/default.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_lock" :  
      paRootPanelOnModule("para/lock.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_common" :  
      paRootPanelOnModule("para/common.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_auth" :  
      paRootPanelOnModule("para/auth.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_pv_range" :  
      paRootPanelOnModule("para/pv_range.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_u_range" :  
      paRootPanelOnModule("para/u_range.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_dp_fct" :  
      if (globalFctNew[Id]=="" && globalFctOld[Id]=="")  
      {  
        paRootPanelOnModule("para/dp_function.pnl","dp_function",myModuleName(),makeDynString(dpeNew));  
      }  
      else  
      if (globalFctNew[Id]!="" && globalFctOld[Id]=="")  
      {  
        globalFctOld[Id]=globalFctNew[Id];  
        if (globalFctNew[Id]=="DP")  
        {  
          paRootPanelOnModule("para/dp_fct.pnl","dp_fct",myModuleName(),makeDynString(dpeNew));  
        }  
        else  
          paRootPanelOnModule("para/stat_fct.pnl","stat_fct",myModuleName(),makeDynString(dpeNew));  
      }  
      else  
      {  
        if (paIsNative[paMyModuleId()])  
          paRootPanelOnModule("para/dummy.pnl","",myModuleName(),makeDynString(""));  
        else  
        {  
          if (configAct=="_dp_fct") globalFctOld[Id]="";  
          PanelOff();  
        }  
      }  
      break;  
    case "_alert_class" :  
      paRootPanelOnModule("para/alert_class.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_alert_hdl" : 
      if (dpElementType(dpeNew)==DPEL_BOOL ||
//          dpElementType(dpeNew)==DPEL_BOOL_STRUCT ||
          dpElementType(dpeNew)==DPEL_DYN_BOOL //||
//          dpElementType(dpeNew)==DPEL_DYN_BOOL_STRUCT
         )  
        paRootPanelOnModule("para/alert_hdl_bit.pnl","",myModuleName(),makeDynString(dpeNew));  
      else  
      if (dpElementType(dpeNew)==DPEL_UINT ||  
//          dpElementType(dpeNew)==DPEL_UINT_STRUCT ||  
////          dpElementType(dpeNew)==DPEL_DYN_UINT ||  
//          dpElementType(dpeNew)==DPEL_DYN_UINT_STRUCT ||  
          dpElementType(dpeNew)==DPEL_INT ||  
//          dpElementType(dpeNew)==DPEL_INT_STRUCT ||  
////          dpElementType(dpeNew)==DPEL_DYN_INT ||  
//          dpElementType(dpeNew)==DPEL_DYN_INT_STRUCT ||  
          dpElementType(dpeNew)==DPEL_FLOAT // ||
//          dpElementType(dpeNew)==DPEL_FLOAT_STRUCT ||
////          dpElementType(dpeNew)==DPEL_DYN_FLOAT //||
//          dpElementType(dpeNew)==DPEL_DYN_FLOAT_STRUCT
         )  
        paRootPanelOnModule("para/alert_hdl.pnl","",myModuleName(),makeDynString(dpeNew));  
      else  
        paRootPanelOnModule("para/alert_hdl_sum.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_msg_conv" :  
      paRootPanelOnModule("para/msg_conv.pnl",panelname,myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_cmd_conv" :  
      paRootPanelOnModule("para/cmd_conv.pnl",panelname,myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_smooth" :  
      paRootPanelOnModule("para/smooth.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_archive" :  
      paRootPanelOnModule("para/archive.pnl","",myModuleName(),makeDynString(dpeNew));  
      break;  
    case "_distrib" :  
    case "_address" :  
      if (globalAddressNew[Id]=="" && globalAddressOld[Id]=="")  
      {  
        paRootPanelOnModule("para/address.pnl","",myModuleName(),makeDynString(dpeNew));  
      }  
      else  
      if (globalAddressNew[Id]!="" && globalAddressOld[Id]=="")  
      {  
        globalAddressOld[Id]=globalAddressNew[Id];  
        if (globalAddressNew[Id]=="pfm" || globalAddressNew[Id]=="pdp")  
        {  
          panelname+="_"+globalAddressNew[Id];  
          paRootPanelOnModule("para/address_pfm.pnl",panelname,myModuleName(),makeDynString(dpeNew));  
        }  
        else  
          paRootPanelOnModule("para/address_"+globalAddressNew[Id]+".pnl","",myModuleName(),makeDynString(dpeNew));  
      }  
      else  
      {  
        if (paIsNative[paMyModuleId()])  
          paRootPanelOnModule("para/dummy.pnl","",myModuleName(),makeDynString(""));  
        else  
        {  
          if ((configAct=="_address" || configAct=="_distrib")) globalAddressOld[Id]="";  
          PanelOff();  
        }  
      }  
      break;  
  
    default:
      sPara=makeDynString(paGetCatStr("para","nopanel"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
  }
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function reads a language dependent text from a message file in .../msg/XXX/  
// The character "§" will be interpreted as "\n"  
//////////////////////////////////////////////////////////////////////////////  
string paGetCatStr(string catName,string index)  
{  
  string     sTxt=getCatStr(catName,index);  

  sTxt=strrtrim(sTxt);
  strreplace(sTxt,"§","\n");  
  return sTxt;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function results true if the dpe has a type of dyn...  
//////////////////////////////////////////////////////////////////////////////  
bool paIsDpeDyn(string dpe)  
{  
  dyn_int dynTypes=makeDynInt(DPEL_DYN_BOOL,DPEL_DYN_CHAR,DPEL_DYN_BIT32,  
                              DPEL_DYN_UINT,DPEL_DYN_INT,DPEL_DYN_FLOAT,  
                              DPEL_DYN_TIME,DPEL_DYN_LANGSTRING,  
                              DPEL_DYN_STRING,DPEL_DYN_DPID,  
                              DPEL_DYN_BOOL_STRUCT,DPEL_DYN_CHAR_STRUCT,DPEL_DYN_BIT32_STRUCT,  
                              DPEL_DYN_UINT_STRUCT,DPEL_DYN_INT_STRUCT,DPEL_DYN_FLOAT_STRUCT,  
                              DPEL_DYN_TIME_STRUCT,DPEL_DYN_LANGSTRING_STRUCT,  
                              DPEL_DYN_STRING_STRUCT,DPEL_DYN_DPID_STRUCT);  
  
  return (dynContains(dynTypes,dpElementType(dpe))>0);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function converts any language dependent config names into  
// neutral language  
//////////////////////////////////////////////////////////////////////////////  
string paGetDpConfig(string dpc)  
{  
  string config;  
  
  if (dpc=="")  
    config="";  
  else  
  {  
    switch (dpSubStr(dpc,DPSUB_CONF))  
    {  
      case ":original"  :  
      case ":_original" :  
        config="_original";  
        break;  
      case ":ersatz"   :  
      case ":default"  :  
      case ":_default" :  
        config="_default";  
        break;  
      case ":sperre"   :  
      case ":lock"  :  
      case ":_lock" :  
        config="_lock";  
        break;  
      case ":allgemein"   :  
      case ":common"  :  
      case ":_common" :  
        config="_common";  
        break;  
      case ":berecht"   :  
      case ":auth"  :  
      case ":_auth" :  
        config="_auth";  
        break;  
      case ":pv_bereich"   :  
      case ":pv_range"  :  
      case ":_pv_range" :  
        config="_pv_range";  
        break;  
      case ":b_bereich"   :  
      case ":u_range"  :  
      case ":_u_range" :  
        config="_u_range";  
        break;  
      case ":dp_fkt"   :  
      case ":dp_fct"   :  
      case ":_dp_fct"   :  
        config="_dp_fct";  
        break;  
      case ":meld_klass"   :  
      case ":alert_class"   :  
      case ":_alert_class"   :  
        config="_alert_class";  
        break;  
      case ":meld_beh"   :  
      case ":alert_hdl"   :  
      case ":_alert_hdl"   :  
        config="_alert_hdl";  
        break;  
      case ":m_urech"   :  
      case ":msg_conv"   :  
      case ":_msg_conv"   :  
        config="_msg_conv";  
        break;  
      case ":b_urech"   :  
      case ":cmd_conv"   :  
      case ":_cmd_conv"   :  
        config="_cmd_conv";  
        break;  
      case ":glätt"   :  
      case ":smooth"   :  
      case ":_smooth"   :  
        config="_smooth";  
        break;  
      case ":archiv"   :  
      case ":archive"   :  
      case ":_archive"   :  
        config="_archive";  
        break;  
      case ":adresse"   :  
      case ":address"   :  
      case ":_address"   :  
        config="_address";  
        break;  
      case ":verteil"   :  
      case ":distrib"   :  
      case ":_distrib"   :  
        config="_distrib";  
        break;  
  
      default : config="";  
    }  
  }  
  return config;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function opens a para-childpanel  
// Parameters:  
// fileName:   filename of the panel  
// panelName:  name of the panel, empty => own name  
// parentName: name of parent panel, empty => myPanelName()  
// moduleName: name of module, empty => myModuleName()  
// modal:      TRUE/FALSE  
// ret:        TRUE = with return value / FALSE = without return value  
// posX,posY:  panel position (-1 => central)  
// sPara:      parameters / result  
// ok:         1==OK, 2==Cancel, 0=NOK, -1=Error  
//////////////////////////////////////////////////////////////////////////////  
paChildPanelOn(string fileName,  
               string panelName,  
               string parentName,  
               string moduleName,  
               bool modal,  
               bool ret,  
               int posX,int posY,  
               dyn_string &sPara,  
               int &ok)  
{  
  int         x1,y1,x2,y2,dx0,dy0,status;
  bool        all_right;  
  time        t=86400;  
  string      ui;  
  dyn_int     di,dj;  
  dyn_float   df;  
  dyn_string  ds,dpNamesWait,dpNamesReturn;  
  dyn_anytype conditions,result;  
     
  sprintf(ui, "_Ui_%d.", myManNum());  
  dpNamesWait=makeDynString(ui+"PanelOff.PanelName:_original.._value");  
  dpNamesReturn=makeDynString(ui+"ReturnValue.Float:_original.._value",  
                              ui+"ReturnValue.Text:_original.._value");  
  if (panelName=="")
    conditions[1]=fileName;  
  else
    conditions[1]=panelName;  
  
  if (moduleName=="")  
  {  
//    if (paIsNative[paMyModuleId()])  
//      moduleName=globalModuleName;  
//    else  
      moduleName=myModuleName();  
  }  
  if (parentName=="")  
    parentName=rootPanel(moduleName);  
  if (parentName=="") parentName=myPanelName();  
  
  di=_PanelSize(fileName);   
  if (isModuleOpen(moduleName) && !isPanelOpen(panelName,moduleName))   
  {  
    if (paIsNative[paMyModuleId()])  
    {  
      dj=_PanelSize("para.pnl");   
      dx0=dj[1];  
      dy0=dj[2];  
    }  
    else  
      panelSize(parentName,dx0,dy0);  
   
    if (posX>=0 && posY>=0)  
    {  
      x1=posX;y2=posY;  
      if (x1+di[1]<dx0)   
        x2=x1;   
      else   
      if (x1-di[1]-10>=0)   
        x2=x1-di[1]-10;   
      else   
        x2=0;   
   
      if (y1+di[2]+30<dy0)   
        y2=y1;   
      else   
      if (y1-di[2]-30>=0)   
        y2=y1-di[2]-30;   
      else   
        y2=0;   
    }  
    else //Central  
    {  
      di=_PanelSize(fileName);   
      x2=(dx0-di[1])/2;   
      y2=(dy0-di[2]-5)/2;   
      if(x2<0) x2=0;   
      if(y2<0) y2=0;   
    }  
    
    paErrorHandlingDpSet(  
    dpSetWait(ui+"ChildPanelOn.ModuleName:_original.._value",moduleName,  
              ui+"ChildPanelOn.ParentName:_original.._value",parentName,  
              ui+"ChildPanelOn.FileName:_original.._value",fileName,  
              ui+"ChildPanelOn.X:_original.._value",x2,  
              ui+"ChildPanelOn.Y:_original.._value",y2,  
              ui+"ChildPanelOn.Scale:_original.._value",1.0,  
              ui+"ChildPanelOn.ParentScale:_original.._value",0,  
              ui+"ChildPanelOn.PanelName:_original.._value",panelName,  
              ui+"ChildPanelOn.Parameter:_original.._value",sPara,  
              ui+"ChildPanelOn.Modal:_original.._value",modal),all_right);  
  
    status=waitForDpValue(dpNamesWait,conditions,   
                          dpNamesReturn,result,t);   
    paErrorHandlingDpSet(  
    dpSetWait(ui+"PanelOff.PanelName:_original.._value",""),all_right);   
    if (status==-1)   
    {   
      result=makeDynAnytype();   
    }   
    else   
    if (dynlen(getLastError())!=0)   
    {   
      result=makeDynAnytype();   
      DebugTN(getLastError());   
    }   
    else   
    {   
      df=result[1];   
      ds=result[2];   
    }  
    if (ret)  
    {  
      if (dynlen(df)>0 && df[1]==1)  
        sPara=ds;  
      ok=(dynlen(df)>0)?df[1]:0;  
    }  
    else  
      ok=1;  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// RootPanel Îffnen in anderem Modul
//////////////////////////////////////////////////////////////////////////////  
paRootPanelOnModule(string FileName,string PanelName,string ModuleName,
                  dyn_string Parameter)
{
  string dp;

  if (isModuleOpen(ModuleName))
  {
    sprintf(dp, "_Ui_%d.", myManNum());
    dpSet(dp+"RootPanelOrigOn.ModuleName:_original.._value",ModuleName,
          dp+"RootPanelOrigOn.FileName:_original.._value",FileName,
          dp+"RootPanelOrigOn.PanelName:_original.._value",PanelName,
          dp+"RootPanelOrigOn.Parameter:_original.._value",Parameter);
  }
}

//////////////////////////////////////////////////////////////////////////////  
// This function converts a float value (sec.millisec) into time  
//////////////////////////////////////////////////////////////////////////////  
time intervalToTime(float interval)  
{  
  int        sec=interval,mil=1000.0*(interval-sec);  
  time       tPara;  
  
  tPara=setPeriod(tPara,sec,mil);  
  
  return tPara;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function converts a time (sec.millisec) into float value (sec.millisec)  
//////////////////////////////////////////////////////////////////////////////  
float timeToInterval(time tPara)  
{  
  int   sec=period(tPara),mms=milliSecond(tPara);
  float interv=sec,ms=mms;  
  
  interv=interv+ms/1000.0;
  return interv;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function initializes a para-panel:  
// - initializes the global variables  
// - connects to _Ui and to the config lock of the dpe  
// - reads the config values of the dpe  
// - writes this values into the para-panel  
// - sets the global variable globalDpc  
//////////////////////////////////////////////////////////////////////////////  
paInitPanel(string dpe,string config)  
{  
  int         mannum=myManNum();  
  string      s,cc=strltrim(config,":"),sTxt=paGetCatStr("para","novision");  
  dyn_anytype dpc1,dpc2;  

  if (dpe=="")  
  {  
    PanelOff();  
    paRootPanelOnModule("vision/MessageWarning","",myModuleName(),
      makeDynString(sTxt));  
  }  
  
  // initialize global variables   
  paInitGlobals();  
  paInitModuleNames(dpe+config);  
  
  sprintf(s,"%d",mannum);  
  dpConnect("paInitWork",false,"_Ui_"+s+".Para.OpenConfig:_online.._value", 
                               "_Ui_"+s+".Para.ModuleName:_original.._value"); 
  if (cc!="_original" && cc!="_lock" &&
      dpSubStr(dpe,DPSUB_SYS)==getSystemName() )  
    dpConnect("paDpConnectLock",dpe+":_lock."+cc+"._locked");  

  // read config   
  paDpGet(dpe+config,dpc1);
  // write attributes into panel  
  paWritePanelAllAttributes(dpe+config,dpc1);  

  delay(0,500); // TI 6858 (Speedy Gonzales || lahme Schnecke)

  // read attributes from panel  
  paReadPanelAllAttributes(dpe+config,dpc2);  
  // write attributes into global variable  
  paPutGlobalDpc(dpe+config,dpc2);  
  
  if(paDebug) DebugTN("paInitPanel:",dpc2);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This is the CB-workfunction for paInitPanel()  
//////////////////////////////////////////////////////////////////////////////  
paInitWork(string dpUi,string OpenConfig,string dpUi2,string ModuleName)  
{  
  if (ModuleName!=myModuleName()) 
    return; 
  paDpConnectUi(dpUi,OpenConfig,ModuleName);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function controls the error handling of all dpSet-calls  
//////////////////////////////////////////////////////////////////////////////  
paErrorHandlingDpSet(int error,bool &all_right)  
{  
  bool           ok;  
  dyn_string     sPara;  
  dyn_errClass   err;    
  
  err = getLastError();  
  // check if error   
  if(dynlen(err) > 0)    
  {  
    throwError(err);
    errorDialog(err);
    all_right=false;
  }
  else
    all_right=true;
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function results the type of a dpe:  
//   1=numeric, 2=boolean, 0=other  
//////////////////////////////////////////////////////////////////////////////  
int paConvDpType(string dpe)  
{  
  int        type,dpaType=dpElementType(dpe);  
  
  switch (dpaType)  
  {  
    case DPEL_CHAR:  
    case DPEL_UINT:  
    case DPEL_INT:  
    case DPEL_FLOAT:  
    case DPEL_CHAR_STRUCT:  
    case DPEL_UINT_STRUCT:  
    case DPEL_INT_STRUCT:  
    case DPEL_FLOAT_STRUCT:  
    case DPEL_DYN_CHAR:  
    case DPEL_DYN_UINT:  
    case DPEL_DYN_INT:  
    case DPEL_DYN_FLOAT:  
    case DPEL_DYN_CHAR_STRUCT:  
    case DPEL_DYN_UINT_STRUCT:  
    case DPEL_DYN_INT_STRUCT:  
    case DPEL_DYN_FLOAT_STRUCT:  
      type=1;  
    break;  
    case DPEL_BOOL:  
    case DPEL_BOOL_STRUCT:  
    case DPEL_DYN_BOOL:  
    case DPEL_DYN_BOOL_STRUCT:  
      type=2;  
    break;  
    default: type=0;  
  }  
  return (type);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// This function checks if a value corresponds to the dptype  
// message: TRUE=open message panel, FALSE=without message panel  
// ret: return value - 0=OK, -1=NOK  
//  
// NOTICE: at this time the only check is if a uint is less then 0  
//////////////////////////////////////////////////////////////////////////////  
paCheckValue(int dpaType,anytype value,bool message,int &ret)  
{  
  int        ok;  
  dyn_string sPara;  
  
  ret=0;  
  if ((dpaType==DPEL_UINT || dpaType==DPEL_DYN_UINT ||
       dpaType==DPEL_UINT_STRUCT || dpaType==DPEL_DYN_UINT_STRUCT) && value<0)  
  {  
    if (message)  
    {  
      ret=-1;  
      sPara=makeDynString(paGetCatStr("para","negvalue"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
    }  
  }  
  return;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Config-specific functions  
//////////////////////////////////////////////////////////////////////////////  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for original  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetOriginal(string dpe,anytype &dpc)  
{  
  dpc=globalAnytype;  
}  
  
paDpConnectOriginalWork(string dp1,anytype _original___value,  
                        string dp2,anytype _online___value,  
                        string dp3,time _original___stime,  
                        string dp4,time _online___stime,  
                        string dp5,string _original___text,  
                        string dp6,string _online___text,  
                        string dp7,bit32 _original___status)  
{  
  int         dpaType=dpElementType(dp1),  
              i,nol=getNoOfLangs(),dart;  
  anytype     val,val_on;  
  string      form,dpe=dpSubStr(dp1,DPSUB_SYS_DP_EL),unit,  
              st_onl=formatTime("%Y.%m.%d %H:%M:%S",_online___stime,".%03d"),  
              st_ori=formatTime("%Y.%m.%d %H:%M:%S",_original___stime,".%03d");  
  dyn_string  ds;  
  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  switch (dpaType)  
  {  
    case DPEL_DPID:  
                     setValue("pb_select","visible",true);  
                     val=_original___value;val_on=_online___value;  
                     break;  
    case  DPEL_BIT32: val="";  
                     for (i=31;i>=0;i--)  
                     {  
                       if (_original___value[i]) val+="1"; else val+="0";  
                       if (_online___value[i]) val_on+="1"; else val_on+="0";  
                     }  
                     setValue("1_32","visible",true);  
                     break;  
    case   DPEL_TIME: getValue("d_art","number",dart);  
                     setMultiValue("d_art","visible",true,  
                                   "d_art_txt","visible",true);  
                     if (dart==0)  
                     {  
                       val="";val=_original___value;  
                       val_on="";val_on=_online___value;  
                       form="[23s]";  
                     }  
                     else  
                     {  
                       val=0.0;val=timeToInterval(_original___value);  
                       val_on=0.0;val_on=timeToInterval(_online___value);  
                       form="[15.3f]";  
                     }  
                     setMultiValue("_original___value","format",form,  
                                   "_online___value","format",form,  
                                   "pb_calender","visible",(paIsNative[paMyModuleId()] && dart==0),  
                                   "pb_interval","visible",(dart==1),  
                                   "Aufschrift1","visible",(dart==0),  
                                   "Aufschrift2","visible",!(dart==0));  
                     break;  
    case DPEL_LANGSTRING:  
                     ds=_original___value; val=ds[getActiveLang()+1];  
                     if (nol>1)  
                       setMultiValue("langedit","visible",true,  
                                     "_original___value","editable",false,  
                                     "langliste","items",ds);  
                     ds=_online___value; val_on=ds[getActiveLang()+1];  
                     break;  
    default: val=_original___value;  
             val_on=_online___value;  
  }  
  if (dpaType!=DPEL_TIME)
    setMultiValue("_original___value","format",form,  
                  "_online___value","format",form);  
  setMultiValue("_original___value","text",val,  
                "_online___value","text",val_on,  
                "_original___stime","text",st_ori,  
                "_online___stime","text",st_onl,  
                "_original___text","text",_original___text,  
                "_online___text","text",_online___text,  
                "_original___status","text",_original___status,  
                "unit","text",unit,  
                "unit2","text",unit);  
  paSetOriginalBitColor(_original___status,dpe);  
}  
  
//  
// this function sets colors of bit objects in the original-panel  
//  
paSetOriginalBitColor(bit32 _original___status,string dpe)  
{  
  int         default_type,i;
  dyn_string  fore=makeDynString("_3DText","_Window"),back=makeDynString("_3DFace","_ButtonShadow");  
  
  dpGet(dpe+":_default.._type",default_type);
  setMultiValue("_original___active","backCol",back[dpGetStatusBit(_original___status,":_original.._active")+1],  
                "_original___exp_default","enabled",(default_type!=DPCONFIG_NONE),  
                "_original___exp_default","backCol",back[dpGetStatusBit(_original___status,":_original.._exp_default")+1],  
                "_original___exp_inv","backCol",back[dpGetStatusBit(_original___status,":_original.._exp_inv")+1],  
                "_original___user1","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit1")+1],  
                "_original___user2","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit2")+1],  
                "_original___user3","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit3")+1],  
                "_original___user4","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit4")+1],  
                "_original___user5","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit5")+1],  
                "_original___user6","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit6")+1],  
                "_original___user7","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit7")+1],  
                "_original___user8","backCol",back[dpGetStatusBit(_original___status,":_original.._userbit8")+1],  
                "_original___aut_default","backCol",back[dpGetStatusBit(_original___status,":_original.._aut_default")+1],  
                "_original___default","backCol",back[dpGetStatusBit(_original___status,":_original.._default")+1],  
                "_original___out_prange","backCol",back[dpGetStatusBit(_original___status,":_original.._out_prange")+1],  
                "_original___out_range","backCol",back[dpGetStatusBit(_original___status,":_original.._out_range")+1],  
                "_original___aut_inv","backCol",back[dpGetStatusBit(_original___status,":_original.._aut_inv")+1],  
                "_original___invalid","backCol",back[dpGetStatusBit(_original___status,":_original.._invalid")+1],  
                "_original___bad","backCol",back[dpGetStatusBit(_original___status,":_original.._bad")+1],  
                "_original___default_bad","backCol",back[dpGetStatusBit(_original___status,":_original.._default_bad")+1],  
                "_original___online_bad","backCol",back[dpGetStatusBit(_original___status,":_original.._online_bad")+1],  
                "_original___offline_bad","backCol",back[dpGetStatusBit(_original___status,":_original.._offline_bad")+1],  
                "_original___from_GI","backCol",back[dpGetStatusBit(_original___status,":_original.._from_GI")+1],  
                "_original___from_SI","backCol",back[dpGetStatusBit(_original___status,":_original.._from_SI")+1],  
                "_original___stime_inv","backCol",back[dpGetStatusBit(_original___status,":_original.._stime_inv")+1]);  
  setMultiValue("_original___active","foreCol",fore[dpGetStatusBit(_original___status,":_original.._active")+1],  
                "_original___exp_default","foreCol",fore[dpGetStatusBit(_original___status,":_original.._exp_default")+1],  
                "_original___exp_inv","foreCol",fore[dpGetStatusBit(_original___status,":_original.._exp_inv")+1],  
                "_original___user1","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit1")+1],  
                "_original___user2","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit2")+1],  
                "_original___user3","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit3")+1],  
                "_original___user4","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit4")+1],  
                "_original___user5","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit5")+1],  
                "_original___user6","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit6")+1],  
                "_original___user7","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit7")+1],  
                "_original___user8","foreCol",fore[dpGetStatusBit(_original___status,":_original.._userbit8")+1],  
                "_original___aut_default","foreCol",fore[dpGetStatusBit(_original___status,":_original.._aut_default")+1],  
                "_original___default","foreCol",fore[dpGetStatusBit(_original___status,":_original.._default")+1],  
                "_original___out_prange","foreCol",fore[dpGetStatusBit(_original___status,":_original.._out_prange")+1],  
                "_original___out_range","foreCol",fore[dpGetStatusBit(_original___status,":_original.._out_range")+1],  
                "_original___aut_inv","foreCol",fore[dpGetStatusBit(_original___status,":_original.._aut_inv")+1],  
                "_original___invalid","foreCol",fore[dpGetStatusBit(_original___status,":_original.._invalid")+1],  
                "_original___bad","foreCol",fore[dpGetStatusBit(_original___status,":_original.._bad")+1],  
                "_original___default_bad","foreCol",fore[dpGetStatusBit(_original___status,":_original.._default_bad")+1],  
                "_original___online_bad","foreCol",fore[dpGetStatusBit(_original___status,":_original.._online_bad")+1],  
                "_original___offline_bad","foreCol",fore[dpGetStatusBit(_original___status,":_original.._offline_bad")+1],  
                "_original___from_GI","foreCol",fore[dpGetStatusBit(_original___status,":_original.._from_GI")+1],  
                "_original___from_SI","foreCol",fore[dpGetStatusBit(_original___status,":_original.._from_SI")+1],  
                "_original___stime_inv","foreCol",fore[dpGetStatusBit(_original___status,":_original.._stime_inv")+1]);  
  setMultiValue("b1","foreCol",fore[dpGetStatusBit(_original___status,":_original.._aut_default")+1],  
                "b2","foreCol",fore[dpGetStatusBit(_original___status,":_original.._default")+1],  
                "b7","foreCol",fore[dpGetStatusBit(_original___status,":_original.._out_prange")+1],  
                "b8","foreCol",fore[dpGetStatusBit(_original___status,":_original.._out_range")+1],  
                "b12","foreCol",fore[dpGetStatusBit(_original___status,":_original.._aut_inv")+1],  
                "b13","foreCol",fore[dpGetStatusBit(_original___status,":_original.._invalid")+1],  
                "b14","foreCol",fore[dpGetStatusBit(_original___status,":_original.._bad")+1],  
                "b9","foreCol",fore[dpGetStatusBit(_original___status,":_original.._default_bad")+1],  
                "b10","foreCol",fore[dpGetStatusBit(_original___status,":_original.._online_bad")+1],  
                "b11","foreCol",fore[dpGetStatusBit(_original___status,":_original.._offline_bad")+1],  
                "b3","foreCol",fore[dpGetStatusBit(_original___status,":_original.._from_GI")+1],  
                "b4","foreCol",fore[dpGetStatusBit(_original___status,":_original.._from_SI")+1],  
                "b6","foreCol",fore[dpGetStatusBit(_original___status,":_original.._stime_inv")+1]);  
}  
  
paDpSetOriginal(string dpe,bool &all_right)  
{  
  int        i,u,l,h=1,bw=0,nol=getNoOfLangs(),dpaType=dpElementType(dpe),dart,ok;  
  time       t;  
  char       ch;  
  bool       active,exp_default,exp_inv;  
  float      f;  
  anytype    value,_original_value;  
  unsigned   typ=dpElementType(dpe);  
  langString ls;  
  dyn_bool   bits;  
  dyn_string ds=makeDynString("","","","","","","","","","",""),  
             farbe=makeDynString("_3DFace","_ButtonShadow"),  
             sPara=makeDynString(paGetCatStr("para","negvalue"));  
  
  getMultiValue("_original___value","text",_original_value,  
                "_original___active","backCol",ds[9],  
                "_original___exp_default","backCol",ds[10],  
                "_original___exp_inv","backCol",ds[11],  
                "_original___user1","backCol",ds[1],  
                "_original___user2","backCol",ds[2],  
                "_original___user3","backCol",ds[3],  
                "_original___user4","backCol",ds[4],  
                "_original___user5","backCol",ds[5],  
                "_original___user6","backCol",ds[6],  
                "_original___user7","backCol",ds[7],  
                "_original___user8","backCol",ds[8],  
                "d_art","number",dart);  
  
  for (i=1;i<12;i++)  
  {  
    bits[i]=(ds[i]==farbe[2]);  
  }  
  ds=makeDynString();  
  if(paDebug) DebugTN("paDpSetConfig():",dpc);  
  
  if (dpaType==DPEL_CHAR)  
  {  
    ch=_original_value; value=ch;  
  }  
  else  
  if (dpaType==DPEL_UINT)  
  {  
    i=_original_value;  
    paCheckValue(dpaType,i,true,u);  
    {  
      if (u<0) {all_right=false; return;}  
    }  
    value=fabs(i);  
  }  
  else  
  if (dpaType==DPEL_INT)  
  {  
    i=_original_value;  
    value=i;  
  }  
  else  
  if (dpaType==DPEL_FLOAT)  
  {  
    f=_original_value;  
    value=f;  
  }  
  else  
  if (dpaType==DPEL_BIT32)  
  {  
    l=strlen(_original_value);  
    for (i=l;i<32;i++) _original_value+="0";  
    for (i=31;i>=0;i--)  
    {  
      bw+=h*(_original_value[i]!="0" && _original_value[i]!=" "); h<<=1;  
    }  
    value=bw;  
  }  
  else  
  if (dpaType==DPEL_TIME)  
  {  
    if (dart)  
    {  
      getValue("_original___value","text",f);  
      t=intervalToTime(f);  
    }  
    else  
    {  
      getValue("_original___value","text",t);  
    }  
    value=t;  
  }  
  else  
  if (dpaType==DPEL_LANGSTRING)  
  {  
    if (nol>1)  
    {  
      getValue("langliste","items",ds);  
      ls=ds;value=ls;  
    }  
    else  
      value=_original_value;  
  }  
  else  
    value=_original_value;  
  
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_original.._value",value,  
              dpe+":_original.._active",bits[9],  
              dpe+":_original.._exp_default",bits[10],  
              dpe+":_original.._exp_inv",bits[11],  
              dpe+":_original.._userbit1",bits[1],  
              dpe+":_original.._userbit2",bits[2],  
              dpe+":_original.._userbit3",bits[3],  
              dpe+":_original.._userbit4",bits[4],  
              dpe+":_original.._userbit5",bits[5],  
              dpe+":_original.._userbit6",bits[6],  
              dpe+":_original.._userbit7",bits[7],  
              dpe+":_original.._userbit8",bits[8]),all_right);  
}  
  
paDpCopyOriginal(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllOriginalAttributes(string dpe, dyn_anytype dpc)  
{  
}  
  
bool paReadPanelAllOriginalAttributes(string dpe, dyn_anytype &dpc)  
{  
  dpc=globalAnytype;  
  return(true);  
}  
  
paSaveAllOriginalAttributes(string OpenConfig,bool &allright)  
{  
  string dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  
  paDpSetOriginal(dpe,allright);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for original_dyn  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetOriginalDyn(string dpe,anytype &dpc)  
{  
  dpc=globalAnytype;  
}  
  
paDpConnectOriginalDynWork(string dp1,dyn_anytype _original___value,  
                        string dp2,dyn_anytype _online___value,  
                        string dp3,time _original___stime,  
                        string dp4,time _online___stime,  
                        string dp5,string _original___text,  
                        string dp6,string _online___text,  
                        string dp7,bit32 _original___status)  
{  
  int            dpaType=dpElementType(dp1),  
                 i,j,nol=getNoOfLangs(),dart,len;  
  float          f;  
  string         form,dpe=dpSubStr(dp1,DPSUB_SYS_DP_EL),unit,s,  
                 st_onl=formatTime("%Y.%m.%d %H:%M:%S",_online___stime,".%03d"),  
                 st_ori=formatTime("%Y.%m.%d %H:%M:%S",_original___stime,".%03d");  
  anytype        input;  
  dyn_string     ds,farbe=makeDynString("_3DFace","_ButtonShadow");  
  dyn_anytype    val,val_on;  
  dyn_langString dls;  
  
  len=dynlen(_original___value);  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  switch (dpaType)  
  {  
    case DPEL_DYN_DPID:  
                     setValue("pb_select","visible",true);  
                     for (i=1;i<=dynlen(_original___value);i++)  
                       val[i]=_original___value[i];  
                     if (len>0)  
                       input=val[1];  
                     else  
                       input="";  
                     for (i=1;i<=dynlen(_online___value);i++)  
                       val_on[i]=_online___value[i];  
                     break;  
    case  DPEL_DYN_BIT32: val="";  
                     for (i=1;i<=dynlen(_original___value);i++)  
                       for (j=31;j>=0;j--)  
                         if (_original___value[i][j])  
                           val[i]+="1";  
                         else  
                           val[i]+="0";  
                     if (len>0)  
                       input=val[1];  
                     else  
                       input="";  
                     for (i=1;i<=dynlen(_online___value);i++)  
                       for (j=31;j>=0;j--)  
                         if (_online___value[i][j])  
                           val_on[i]+="1";  
                         else  
                           val_on[i]+="0";  
                     setValue("1_32","visible",true);  
                     break;  
    case   DPEL_DYN_TIME: getValue("d_art","number",dart);  
                     form=dart?"[15.3f]":"[23s]";  
                     setMultiValue("d_art","visible",true,  
                                   "d_art_txt","visible",true);  
                     for (i=1;i<=dynlen(_original___value);i++)  
                       if (dart==0)  
                       {  
                         val[i]="";val[i]=_original___value[i];  
                       }  
                       else  
                       {  
                         val[i]="";f=timeToInterval(_original___value[i]);  
                         sprintf(s,"%.3f",f);val[i]=s;  
                       }  
                     for (i=1;i<=dynlen(_online___value);i++)  
                       if (dart==0)  
                       {  
                         val_on[i]="";val_on[i]=_online___value[i];  
                       }  
                       else  
                       {  
                         val_on[i]="";f=timeToInterval(_online___value[i]);  
                         sprintf(s,"%.3f",f);val_on[i]=s;  
                       }  
                     setMultiValue("pb_calender","visible",(paIsNative[paMyModuleId()] && dart==0),  
                                   "pb_interval","visible",(dart==1),  
                                   "Aufschrift1","visible",(dart==0),  
                                   "Aufschrift2","visible",!(dart==0));  
                     break;  
    case DPEL_DYN_LANGSTRING:  
                     dls=_original___value;  
                     if (nol>1)  
                     {  
                       val=dls;   
                       ds=dynLangString2dynString(dls);  
                       setMultiValue("dyn_input","editable",false,  
                                     "langedit","visible",true,  
                                     "langliste","items",ds);  
                     }  
                     else  
                     {  
                       val=_original___value;   
                       setMultiValue("dyn_input","editable",true,  
                                     "langedit","visible",false);  
                     }  
                     dls=_online___value;  
                     if (nol>1)  
                     {  
                       val_on=dls;   
                     }  
                     else  
                     {  
                       val_on=_online___value;   
                     }  
                     if (len>0)  
                       input=val[1];  
                     else  
                       input="";  
                     break;  
    default: for (i=1;i<=dynlen(_original___value);i++)  
               val[i]=_original___value[i];  
             for (i=1;i<=dynlen(_online___value);i++)  
               val_on[i]=_online___value[i];  
             if (len>0)  
               input=val[1];  
             else  
               input="";  
  }  
  if (dpaType==DPEL_DYN_TIME)  
  {  
    if (!dart)  
      input=(len>0)?val[1]:"";  
    else  
    {  
      if (len>0)  
        sscanf(val[1],"%f",f);  
      else  
        f=0.0;  
      input=f;  
    }  
  }  
  getValue("nr_of_records","text",s);
  s=substr(s,0,strpos(s,":")+1)+" "+dynlen(val)+") ";
  setValue("dyn_input","format",form);
  setMultiValue("dyn_input","text",input,  
                "dyn_list","items",val,  
                "nr_of_records","text",s,  
                "_online___value","items",val_on,  
                "_original___stime","text",st_ori,  
                "_online___stime","text",st_onl,  
                "_original___status","text",_original___status,  
                "unit","text",unit,  
                "pb_editor","visible",(paIsNative[paMyModuleId()]));  
  paSetOriginalBitColor(_original___status,dpe);  
  if (dynlen(val_on)>0)  
    setValue("_online___value","selectedPos",1);  
}  
  
paDpSetOriginalDyn(string dpe,bool &all_right)  
{  
  int         i,u,j,l,h=1,bw=0,nol=getNoOfLangs(),  
              dpaType=dpElementType(dpe),dart;  
  time        t;  
  char        ch;  
  bool        active,exp_default,exp_inv;  
  float       f;  
  string      s;
  unsigned    typ=dpElementType(dpe);  
  langString  ls;  
  dyn_bool    bits;  
  dyn_string  ds=makeDynString("","","","","","","","","","",""),  
              farbe=makeDynString("_3DFace","_ButtonShadow"),  
              sPara=makeDynString(paGetCatStr("para","negvalue"));  
  dyn_anytype value,_original_value;  
  dyn_langString dls;
  
  getMultiValue("dyn_list","items",_original_value,  
                "_original___active","backCol",ds[9],  
                "_original___exp_default","backCol",ds[10],  
                "_original___exp_inv","backCol",ds[11],  
                "_original___user1","backCol",ds[1],  
                "_original___user2","backCol",ds[2],  
                "_original___user3","backCol",ds[3],  
                "_original___user4","backCol",ds[4],  
                "_original___user5","backCol",ds[5],  
                "_original___user6","backCol",ds[6],  
                "_original___user7","backCol",ds[7],  
                "_original___user8","backCol",ds[8],  
                "d_art","number",dart);  
  
  for (i=1;i<12;i++)  
  {  
    bits[i]=(ds[i]==farbe[2]);  
  }  
  ds=makeDynString();  
  if(paDebug) DebugTN("paDpSetConfig():",dpc);  
  
  if (dpaType==DPEL_DYN_CHAR)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      ch=_original_value[i];  
      value[i]=ch;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_UINT)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      j=_original_value[i];  
      paCheckValue(dpaType,j,true,u);  
      {  
        if (u<0) {all_right=false; return;}  
      }  
      value[i]=j;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_INT)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      j=_original_value[i];  
      value[i]=j;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_FLOAT)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      f=_original_value[i];  
      value[i]=f;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_BIT32)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      s=_original_value[i];
      l=strlen(s);  
      for (j=l;j<32;j++) s+="0";  
      h=1; bw=0;
      for (j=31;j>=0;j--)  
      {  
        bw+=h*(s[j]!="0" && s[j]!=" "); h<<=1;  
      }  
      value[i]=bw;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_TIME)  
  {  
    for (i=1;i<=dynlen(_original_value);i++)  
    {  
      if (dart)  
      {  
        f=_original_value[i];  
        t=intervalToTime(f);  
      }  
      else  
        t=_original_value[i];  
      value[i]=t;  
    }  
  }  
  else  
  if (dpaType==DPEL_DYN_LANGSTRING)  
  {  
    if (nol>1)  
    {  
      getValue("langliste","items",ds);  
      dls=dynString2dynLangString(ds);value=dls;  
    }  
    else  
      value=_original_value;  
  }  
  else  
    value=_original_value;  

  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_original.._value",value,  
              dpe+":_original.._active",bits[9],  
              dpe+":_original.._exp_default",bits[10],  
              dpe+":_original.._exp_inv",bits[11],  
              dpe+":_original.._userbit1",bits[1],  
              dpe+":_original.._userbit2",bits[2],  
              dpe+":_original.._userbit3",bits[3],  
              dpe+":_original.._userbit4",bits[4],  
              dpe+":_original.._userbit5",bits[5],  
              dpe+":_original.._userbit6",bits[6],  
              dpe+":_original.._userbit7",bits[7],  
              dpe+":_original.._userbit8",bits[8]),all_right);  
}  
  
paDpCopyOriginalDyn(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllOriginalDynAttributes(string dpe, dyn_anytype dpc)  
{  
}  
  
bool paReadPanelAllOriginalDynAttributes(string dpe, dyn_anytype &dpc)  
{  
  dpc=globalAnytype;  
  return(true);  
}  
  
paSaveAllOriginalDynAttributes(string OpenConfig,bool &allright)  
{  
  string dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  
  paDpSetOriginalDyn(dpe,allright);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for auth and lock  
//////////////////////////////////////////////////////////////////////////////  
// Function paGetConfigs reads neutral config-names from database  
//////////////////////////////////////////////////////////////////////////////  
paGetNeutralConfigs(string typ, dyn_string &config)
{
  int        i;
  
  config = dpNames(":_*");
 
  for (i = dynlen(config); i > 0 ; i--)
  {
    config[i] = dpSubStr(config[i],DPSUB_CONF);
    strreplace(config[i], ":", "");
    if (config[i] == "_"+typ    || config[i] == "_online" ||
        config[i] == "_offline" || config[i] == "_start"  ||  
        config[i] == "_common"  || config[i] == ""        ||
        config[i] == "_archiv_class")
    {
      dynRemove(config, i);
    }
  }
}
  
//////////////////////////////////////////////////////////////////////////////  
// Function paGetConfigs reads comments, config-names and neutral config-names
// from teconfig.txt  
//////////////////////////////////////////////////////////////////////////////  
dyn_dyn_string paGetConfigs(string typ)  
{  
  int            i,j,k,l,nl=0,len,pn,an,  
                 pl=getGlobalLangId(getParamLang()),  
                 al=getGlobalLangId(getActiveLang());  
  file           f;  
  string         s,s1,sl,teconfig;  
  dyn_int        di;  
  dyn_string     ds=makeDynString();  
  dyn_dyn_string config;  
  
  teconfig=PVSS_PATH+"/dbdfiles/version_"+VERSION+"/teconfig.txt";  
  if (access(teconfig,R_OK)!=0)  
    return config;  
  
  f=fopen(teconfig,"r");  
  fgets(s,65535,f); fgets(s,65535,f);  
  fgets(s,65535,f); fgets(s,65535,f);  
  nl=s;  
  j=1;  
  while (!feof(f))  
  {  
    ds=makeDynString();  
    di=makeDynInt();  
    for (k=1;k<=nl;k++)  
    {  
      fgets(s,65535,f);  
      sscanf(s,"%s %d %s",sl,len,s1);  
      sl=substr(sl,5,strlen(sl)-5);  
      di[k]=sl;  
      ds[k]=s1;  
    }  
    pn=nl;an=nl;  
    for (l=1;l<nl;l++)  
    {  
      if (di[l]==pl) pn=l;  
      if (di[l]==al) an=l;  
    }  
    if (ds[nl]!="_"+typ    && ds[nl]!="_online" &&  
        ds[nl]!="_offline" && ds[nl]!="_start" &&  
        ds[nl]!="_common"  && ds[nl]!="" &&
        ds[nl]!="_archiv_class")  
    {  
      config[j][1]=ds[an]; // Beschreibung  
      config[j][2]=ds[pn]; // Konfig-Name  
      config[j][3]=ds[nl]; // Neutralsprachlicher Bezeichner
      j++;  
    }  
    fgets(s,65535,f); fgets(s,65535,f);  
  }  
  
  fclose(f);  
  
  return config;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for default  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetDefault(string dpe,anytype &dpc)  
{  
  dpGet(dpe+":_default.._type",dpc[1],   
        dpe+":_default.._set_ibit",dpc[2],  
        dpe+":_default.._set_pvrange",dpc[3],  
        dpe+":_default.._value",dpc[4]);  
}  
  
paDpSetDefault(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int        dpaType=dpElementType(dpe),  
             i,u,l,bw,h=1,nol=getNoOfLangs();  
  char       ch;  
  time       t;  
  bool       error;  
  float      f;  
  anytype    value;  
  unsigned   second,milli;  
  langString ls;  
  dyn_string ds,sPara=makeDynString(paGetCatStr("para","negvalue"));  
  
  if(paDebug) DebugTN("paDpSetConfig():",dpc);  
  
  if (dpaType==DPEL_CHAR || dpaType==DPEL_CHAR_STRUCT)  
  {  
    ch=dpc[4]; value=ch;  
  }  
  else  
  if (dpaType==DPEL_UINT || dpaType==DPEL_UINT_STRUCT)  
  {  
    i=dpc[4];  
    paCheckValue(dpaType,i,true,u);  
    {  
      if (u<0) {all_right=false; return;}  
    }  
    value=fabs(i);  
  }  
  else  
  if (dpaType==DPEL_INT || dpaType==DPEL_INT_STRUCT)  
  {  
    i=dpc[4];  
    value=i;  
  }  
  else  
  if (dpaType==DPEL_FLOAT || dpaType==DPEL_FLOAT_STRUCT)  
  {  
    f=dpc[4];  
    value=f;  
  }  
  else  
  if (dpaType==DPEL_BIT32 || dpaType==DPEL_BIT32_STRUCT)  
  {  
    l=strlen(dpc[4]);  
    for (i=l;i<32;i++) dpc[4]+="0";  
    for (i=31;i>=0;i--)  
    {  
      bw+=h*(dpc[4][i]!="0" && dpc[4][i]!=" "); h<<=1;  
    }  
    value=bw;  
  }  
  else  
  if (dpaType==DPEL_TIME || dpaType==DPEL_TIME_STRUCT)  
  {  
    t=dpc[4];  
    value=t;  
  }  
  else  
  if (dpaType==DPEL_LANGSTRING || dpaType==DPEL_LANGSTRING_STRUCT)  
  {  
    if (nol>1)  
    {  
      getValue("langliste","items",ds);  
      ls=ds;value=ls;  
    }  
    else  
      value=dpc[4];  
  }  
  else  
    value=dpc[4];  

  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_default.._set_ibit",dpc[2],  
              dpe+":_default.._set_pvrange",dpc[3],  
              dpe+":_default.._value",value),all_right);  
}          
  
paDpCopyDefault(string dpe_source, string dpe_destination, bool &all_right)  
{  
  dyn_anytype dpc;  
  
  if(dpElementType(dpe_source) == dpElementType(dpe_destination))  
  {  
    paDpGetDefault(dpe_source,dpc);  
    paDpSetDefault(dpe_destination,dpc,all_right);  
  }  
  else  
    all_right = false;  
}  
  
paWritePanelAllDefaultAttributes(string dpe, dyn_anytype dpc)  
{  
  int         dpaType=dpElementType(dpe),  
              i,nol=getNoOfLangs(),dart;  
  anytype     val;  
  string      form,unit;  
  dyn_string  ds;  
  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  switch (dpaType)  
  {  
    case DPEL_DPID:  
    case DPEL_DPID_STRUCT:  
                     setValue("pb_select","visible",true);  
                     val=dpc[4];  
                     break;  
    case  DPEL_BIT32:
    case  DPEL_BIT32_STRUCT:
                     val="";  
                     for (i=31;i>=0;i--)  
                     {  
                       if (dpc[4][i]) val+="1"; else val+="0";  
                     }  
                     setValue("1_32","visible",true);  
                     break;  
    case   DPEL_TIME:
    case   DPEL_TIME_STRUCT:
                     getValue("d_art","number",dart);  
                     setMultiValue("d_art","visible",true,  
                                   "d_art_txt","visible",true);  
                     if (dart==0)  
                     {  
                       val="";val=dpc[4];form="[23s]";  
                     }  
                     else  
                     {  
                       val=0.0;val=timeToInterval(dpc[4]);form="[15.3f]";  
                     }  
                     setMultiValue("pb_calender","visible",(paIsNative[paMyModuleId()] && dart==0),  
                                   "pb_interval","visible",(dart==1),  
                                   "Aufschrift1","visible",(dart==0),  
                                   "Aufschrift2","visible",!(dart==0));  
                     break;  
    case DPEL_LANGSTRING:  
    case DPEL_LANGSTRING_STRUCT:  
                     ds=dpc[4]; val=ds[getActiveLang()+1];  
                     if (nol>1)  
                       setMultiValue("langedit","visible",true,  
                                     "_default___value","editable",false,  
                                     "langliste","items",ds);  
                     break;  
//    default: val=ValToFormatedString(dpe,dpc[4]);  
    default: val=dpc[4];  
  }  
  
  setValue("_default___value","format",form);
  setMultiValue("_default___type","text",dpc[1],  
                "_default___set_ibit","state",0,dpc[2],  
                "_default___set_pvrange","state",0,dpc[3],  
                "_default___value","text",val,  
                "unit","text",unit);  
}      
  
bool paReadPanelAllDefaultAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        dart;  
  dyn_string ds;  
  langString ls;  
  
  dpc=globalAnytype;  
  getMultiValue("d_art","number",dart,  
                "_default___type","text",dpc[1],  
                "_default___set_ibit","state",0,dpc[2],  
                "_default___set_pvrange","state",0,dpc[3]);  
  if (dpElementType(dpe)==DPEL_LANGSTRING || dpElementType(dpe)==DPEL_LANGSTRING_STRUCT)  
  {  
    if (getNoOfLangs()>1)  
    {  
      getValue("langliste","items",ds);  
      ls=ds;  
      dpc[4]=ls;  
    }  
    else  
      getValue("_default___value","text",dpc[4]);  
  }  
  else  
    getValue("_default___value","text",dpc[4]);  
  if ( (dpElementType(dpe)==DPEL_TIME || dpElementType(dpe)==DPEL_TIME_STRUCT) && dart==1)  
    dpc[4]=intervalToTime(dpc[4]);  
}  
  
paSaveAllDefaultAttributes(string OpenConfig,bool &all_right)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllDefaultAttributes(dpe,dpc);  
  paDpSetDefault(dpe,dpc,all_right);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for default_dyn  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetDefaultDyn(string dpe,anytype &dpc)  
{  
  dpGet(dpe+":_default.._type",dpc[1],   
        dpe+":_default.._set_ibit",dpc[2],  
        dpe+":_default.._set_pvrange",dpc[3],  
        dpe+":_default.._value",dpc[4]);  
}  
  
paDpSetDefaultDyn(string dpe, dyn_anytype dpc,bool &all_right)  
{  
  int            i,u,j,d,dart,dpaType=dpElementType(dpe),nol=getNoOfLangs();  
  char           ch;  
  time           t;  
  float          f;  
  unsigned       bw,h;  
  dyn_string     ds;  
  dyn_anytype    value;  
  dyn_langString dls,sPara=makeDynString(paGetCatStr("para","negvalue"));  
  
  switch (dpaType)  
  {  
  
    case    DPEL_DYN_INT:  
    case   DPEL_DYN_UINT:  
    case   DPEL_DYN_BOOL:
    case    DPEL_DYN_INT_STRUCT:  
    case   DPEL_DYN_UINT_STRUCT:  
    case   DPEL_DYN_BOOL_STRUCT:
                         for (j=1;j<=dynlen(dpc[4]);j++)  
                         {  
                           sscanf(dpc[4][j],"%d",d);  
                           paCheckValue(dpaType,d,true,u);  
                           {  
                             if (u<0) {all_right=false; return;};  
                           }  
                           value[j]=d;  
                         }  
                         break;  
    case   DPEL_DYN_CHAR:
    case   DPEL_DYN_CHAR_STRUCT:
                         for (j=1;j<=dynlen(dpc[4]);j++)  
                         {  
                           sscanf(dpc[4][j],"%c",ch);  
                           value[j]=ch;  
                         }  
                         break;  
    case  DPEL_DYN_BIT32:
    case  DPEL_DYN_BIT32_STRUCT:
                         for (j=1;j<=dynlen(dpc[4]);j++)  
                         {  
                           bw=0;h=1;  
                           for (i=31;i>=0;i--)  
                           {  
                             bw+=h*(dpc[4][j][i]!="0" && dpc[4][j][i]!=" "); h<<=1;  
                           }  
                           value[j]=bw;  
                         }  
                         break;  
    case  DPEL_DYN_FLOAT:
    case  DPEL_DYN_FLOAT_STRUCT:
                         for (j=1;j<=dynlen(dpc[4]);j++)  
                         {  
                           f=dpc[4][j];  
                           value[j]=f;  
                         }  
                         break;  
    case   DPEL_DYN_TIME:
    case   DPEL_DYN_TIME_STRUCT:
                         for (j=1;j<=dynlen(dpc[4]);j++)  
                         {  
                           t=dpc[4][j];  
                           value[j]=t;  
                         }  
                         break;  
    case DPEL_DYN_LANGSTRING:  
    case DPEL_DYN_LANGSTRING_STRUCT:  
                         if (nol>1)  
                         {  
                           getValue("langliste","items",ds);  
                           dls=dynString2dynLangString(ds);  
                           value=dls;  
                         }  
                         else  
                           value=dpc[4];  
                         break;  
                default: value=dpc[4];  
  }  
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_default.._set_ibit",dpc[2],  
              dpe+":_default.._set_pvrange",dpc[3],  
              dpe+":_default.._value",value),all_right);  
}  
  
paDpCopyDefaultDyn(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllDefaultDynAttributes(string dpe, dyn_anytype dpc)  
{  
  int            i,j,pos,len,dart,  
                 dpaType=dpElementType(dpe),  
                 nol=getNoOfLangs();  
  float          fori;  
  string         s,form,unit;  
  anytype        input;  
  dyn_int        di,dj;  
  dyn_string     ori_val,ds;  
  dyn_langString dls=dpc[4];  
  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  len=dynlen(dpc[4]); pos=1;  
  switch (dpaType)  
  {  
    case DPEL_DYN_DPID:  
    case DPEL_DYN_DPID_STRUCT:  
                         ori_val=dpc[4];  
                         if (len>0) input=dpc[4][pos]; else input="";  
                         setValue("pb_select","visible",true);  
                         break;  
    case   DPEL_DYN_BOOL:
    case   DPEL_DYN_BOOL_STRUCT:
                         for (j=1;j<=len;j++)  
                         {  
                           sprintf(s,"%1d",dpc[4][j]);ori_val[j]=s;  
                         }  
                         if (len>0) input=dpc[4][pos]; else ein=0;  
    case   DPEL_DYN_CHAR:
    case   DPEL_DYN_CHAR_STRUCT:
                         for (j=1;j<=len;j++)  
                         {  
                           sprintf(s,"%1s",dpc[4][j]);ori_val[j]=s;  
                         }  
                         if (len>0) input=dpc[4][pos]; else input="";  
                         break;  
    case  DPEL_DYN_BIT32:
    case  DPEL_DYN_BIT32_STRUCT:
                         for (j=1;j<=len;j++)  
                         {  
                           ori_val[j]="";  
                           for (i=31;i>=0;i--)  
                           {  
                             if (dpc[4][j][i]) ori_val[j]+="1"; else ori_val[j]+="0";  
                           }  
                         }  
                         setValue("1_32","visible",true);  
                         if (len>0) input=ori_val[pos]; else input="";  
                         break;  
    case   DPEL_DYN_UINT:  
    case    DPEL_DYN_INT:
    case   DPEL_DYN_UINT_STRUCT:  
    case    DPEL_DYN_INT_STRUCT:
                         for (j=1;j<=len;j++)  
                         {  
                           ori_val[j]=dpc[4][j];  
                         }  
                         if (len>0) input=dpc[4][pos]; else input=0;  
                         break;  
    case  DPEL_DYN_FLOAT:
    case  DPEL_DYN_FLOAT_STRUCT:
                         for (j=1;j<=len;j++)  
                         {  
                           ori_val[j]=dpc[4][j];  
                         }  
                         if (len>0) input=dpc[4][pos]; else input=0.0;  
                         break;  
    case   DPEL_DYN_TIME:
    case   DPEL_DYN_TIME_STRUCT:
                         getValue("d_art","number",dart);  
                         setMultiValue("d_art","visible",true,  
                                       "d_art_txt","visible",true);  
                         for (j=1;j<=len;j++)  
                         {  
                           if (dart==0)  
                             ori_val[j]=dpc[4][j];  
                           else  
                             ori_val[j]=timeToInterval(dpc[4][j]);  
                         }  
                         setMultiValue("pb_calender","visible",(paIsNative[paMyModuleId()] && dart==0),  
                                       "pb_interval","visible",(dart==1),  
                                       "Aufschrift1","visible",(dart==0),  
                                       "Aufschrift2","visible",!(dart==0));  
                         if (len>0)  
                           input=ori_val[pos];  
                         else  
                           input="";  
                         break;  
    case DPEL_DYN_LANGSTRING:  
    case DPEL_DYN_LANGSTRING_STRUCT:  
                         if (len>0) input=dls[pos]; else input="";  
                         if (nol>1)  
                         {  
                           ori_val=dls;   
                           ds=dynLangString2dynString(dls);  
                           setMultiValue("dyn_input","editable",false,  
                                         "langedit","visible",true,  
                                         "langliste","items",ds);  
                         }  
                         else  
                         {  
                           ori_val=dpc[4];   
                           setMultiValue("dyn_input","editable",true,  
                                         "langedit","visible",false);  
                         }  
                         break;  
    case DPEL_DYN_STRING:  
    case DPEL_DYN_STRING_STRUCT:  
                default: ori_val=dpc[4];  
                         if (len>0) input=dpc[4][pos]; else input="";  
  }
  getValue("nr_of_records","text",s);
  s=substr(s,0,strpos(s,":")+1)+" "+dynlen(ori_val)+") ";
  setValue("dyn_input","format",form);
  setMultiValue("dyn_list","items",ori_val,  
                "_default___type","text",dpc[1],  
                "dyn_input","text",input,  
                "nr_of_records","text",s,  
                "selpos","text",pos,  
                "pb_editor","visible",(paIsNative[paMyModuleId()]),  
                "_default___set_ibit","state",0,dpc[2],  
                "_default___set_pvrange","state",0,dpc[3],  
                "unit","text",unit);  
  if (dynlen(ori_val)>0)  
  {  
    setValue("dyn_list","selectedPos",pos);  
    if (dpaType==DPEL_DYN_LANGSTRING || dpaType==DPEL_DYN_LANGSTRING_STRUCT)  
    {  
      ds=dpc[4][pos];  
      setValue("langinput","items",ds);  
    }  
  }  
}  
  
bool paReadPanelAllDefaultDynAttributes(string dpe, dyn_anytype &dpc)  
{  
  int         i,dart;  
  dyn_float   df,empty=makeDynFloat();  
  dyn_string  ds;  
  dyn_anytype da;  
  langString  ls;
  dyn_langString dls;  
  
  dpc=globalAnytype;  
  getMultiValue("d_art","number",dart,  
                "_default___type","text",dpc[1],  
                "_default___set_ibit","state",0,dpc[2],  
                "_default___set_pvrange","state",0,dpc[3]);  
  if (dpElementType(dpe)==DPEL_DYN_LANGSTRING || dpElementType(dpe)==DPEL_DYN_LANGSTRING_STRUCT)  
  {  
    if (getNoOfLangs()>1)  
    {  
      getValue("langliste","items",ds);  
      dls=dynString2dynLangString(ds);  
      dpc[4]=dls;  
    }  
    else  
    {  
      getValue("dyn_list","items",ds);  
      dpc[4]=ds;  
    }  
  }  
  if ( (dpElementType(dpe)==DPEL_DYN_TIME || dpElementType(dpe)==DPEL_DYN_TIME_STRUCT) && dart==1)  
  {  
    dpc[4]=empty;  
    getValue("dyn_list","items",df);  
    for (i=1;i<=dynlen(df);i++)  
      dpc[4][i]=intervalToTime(df[i]);  
  }  
  else  
  {  
    getValue("dyn_list","items",da);  
    dpc[4]=da;  
  }  
}  
  
paSaveAllDefaultDynAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllDefaultDynAttributes(dpe,dpc);  
  paDpSetDefaultDyn(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for common  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetCommon(string dpe,anytype &dpc)  
{  
  bool       elementType=(dpElementType(dpe)!=DPEL_STRUCT);  
  string     s_al=dpNameToAlias(dpe),s;  
  langString ls_lt=dpGetComment(dpe, -2);  
//xxxx  
  bool       dpFromOwnSys;
  
  dpFromOwnSystem(dpe, dpFromOwnSys);
  dpc[6] = dpFromOwnSys;
//xxxx
  dpc[1]=getNoOfLangs();
  dpc[2]=ls_lt;  
  dpc[3]=s_al;  
  if (elementType)  
  {  
    s=dpGetFormat(dpe);  
    if (s!="") s=paCheckFormat(dpe,s);
    dpc[4]=s;  
    s=dpGetUnit(dpe);  
    dpc[5]=s;  
  }  
  else  
  {  
    dpc[4]=" ";  
    dpc[5]="";  
  }  
}  
  
paDpSetCommon(string dpe, dyn_anytype dpc,bool &all_right)  
{
  int        i, j = 0;
  string     s = dpSubStr(dpe, DPSUB_DP_EL);
  langString ls;
  dyn_string ds;
  
  if ( strpos(s, ".") < 1 ) s += ".";
  ls = dpc[2]; ds = ls;
  for (i = 1; i <= dynlen(ds); i++ )
    if ( ds[i] != s ) j++;
  if ( j == 0 ) ls = "";
  paErrorHandlingDpSet(dpSetComment(dpe,ls),all_right);  
  if (all_right)
    paErrorHandlingDpSet(dpSetAlias(dpe,dpc[3]),all_right);  
  if (all_right)
    paErrorHandlingDpSet(dpSetFormat(dpe,dpc[4]),all_right);  
  if (all_right)
  {
    txtBefore.text=dpc[4];
    paErrorHandlingDpSet(dpSetUnit(dpe,dpc[5]),all_right);  
  }
}  
  
paDpCopyCommon(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllCommonAttributes(string dpe, dyn_anytype dpc)  
{  
  int        before=0,after=0,pos,dpaType=dpElementType(dpe);  
  bool       elementType=(dpc[4]!=" "),timeType,boolType;  
  string     s_al=dpc[3],sFormat=dpc[4],komma,dataType="";  
  dyn_string ds_lt=dpc[2],ds;  
  
//xxxx
  bool       dpFromOwnSys = dpc[6];
  string     color;
  
  if( dpFromOwnSys )
    color = "_Window";
  else
    color = "_3DFace";
//xxxx  
  timeType=(dpaType==DPEL_TIME ||  
            dpaType==DPEL_DYN_TIME);
  boolType=(dpaType==DPEL_BOOL ||  
            dpaType==DPEL_DYN_BOOL);

  if (elementType && sFormat!="")  
  {  
    sFormat=strltrim(sFormat,"%");  
    if (strpos(sFormat,".")>0 || strpos(sFormat,",")>0)  
      sscanf(sFormat,"%d%1s%d%1s",before,komma,after,dataType);  
    else  
    if (strlen(sFormat)>1)  
      sscanf(sFormat,"%d%1s",before,dataType);  
    else  
      sscanf(sFormat,"%s",dataType);  
  }  
  setMultiValue("f1","enabled",(dpFromOwnSys && elementType && !timeType && !boolType),  
                "f5","enabled",(dpFromOwnSys && elementType && (dataType=="f" || dataType=="e") && !timeType && !boolType),  
                "f6","enabled",(dpFromOwnSys && elementType && dataType!="" && !timeType && !boolType),  
                "before","enabled",(dpFromOwnSys && elementType && dataType!="" && !timeType && !boolType),  
                "after","enabled",(dpFromOwnSys && elementType && (dataType=="f" || dataType=="e") && !timeType && !boolType),  
                "chbExponential","enabled",(dpFromOwnSys && elementType && (dataType=="f" || dataType=="e") && !timeType && !boolType),  
                "e1","visible",elementType && !timeType,  
                "e2","visible",elementType && !timeType,  
                "unit","visible",elementType && !timeType,  
                "si","visible",elementType && !timeType,  
                "langtextedit","visible",(dpc[1]>1),  
                "f1","state",0,(dpc[4]!=""),  
                "dataType","text",dataType,  
                "before","text",(dataType=="e" && before<2)?2:before,  
                "txtBefore","text",before,  
                "after","text",after,  
                "langtextliste","items",ds_lt,  
                "langtext","text",dpc[2],  
                "alias","text",dpc[3],  
                "unit","text",dpc[5],
                "chbExponential","state",0,(elementType && !timeType && !boolType && dataType=="e"),
                "langtext", "editable", (dpc[1]<2 && dpFromOwnSys),
                "alias", "editable", dpFromOwnSys,
                "unit", "editable", dpFromOwnSys,
                "si", "enabled", dpFromOwnSys,
                "langtextedit", "enabled", dpFromOwnSys,
                "langtext", "backCol",(dpFromOwnSys && dpc[1]<2)?"_Window":"_3DFace",
                "alias", "backCol", color,
                "unit", "backCol", color );
  getValue("dpe_name","items",ds,"selectedPos",pos);  
  if (pos<1) pos=1;  
  ds[2]=dpGetComment(dpe);  
  ds[3]=dpc[3];  
  setValue("dpe_name","items",ds,"text",ds[pos]);  
}  
  
bool paReadPanelAllCommonAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        nol=getNoOfLangs(),before,after;  
  bool       formatExists,float_var,int_var,expo;
 
  string     s_lt,s_al,s_un,dataType;  
  dyn_string ds_lt;  
  langString ls_lt;  
  
  if (nol<2)  
  {  
    getMultiValue("langtext","text",s_lt,  
                  "alias","text",s_al,  
                  "unit","text",s_un,  
                  "f1","state",0,formatExists,  
                  "chbExponential","state",0,expo,
                  "dataType","text",dataType,  
                  "before","text",before,  
                  "after","text",after);  
    ds_lt[1]=s_lt;  
  }  
  else  
  {  
    getMultiValue("langtextliste","items",ds_lt,  
                  "alias","text",s_al,  
                  "unit","text",s_un,  
                  "f1","state",0,formatExists,  
                  "chbExponential","state",0,expo,
                  "dataType","text",dataType,  
                  "before","text",before,  
                  "after","text",after);  
  }  
  ls_lt=ds_lt;  
  dpc[1]=nol;  
  dpc[2]=ls_lt;  
  dpc[3]=s_al;  
  dpc[4]="%";  
  if (formatExists && dataType=="d")  
    dpc[4]+=before+"d";  
  else  
  if (formatExists && (dataType=="f" || dataType=="e"))  
  {
    dpc[4]+=before+"."+after;
    if (expo) dpc[4]+="e"; else dpc[4]+="f";  
  }
  else  
  if (formatExists && dataType=="s" && before>0)  
    dpc[4]+=before+"s";  
  else  
  if (formatExists)  
    dpc[4]+="s";  
  else  
    dpc[4]="";  
  dpc[5]=s_un;  
}  
  
paSaveAllCommonAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllCommonAttributes(dpe,dpc);  
  paDpSetCommon(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for lock  
// The config lock will be connected directly in panel, that's why nothing here  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetLock(string dpe,anytype &dpc)  
{  
}  
  
paDpSetLock(string dpe, dyn_anytype dpc,bool &allright)  
{  
}  
  
 paDpCopyLock(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllLockAttributes(string dpe, dyn_anytype dpc)  
{  
}  
  
bool paReadPanelAllLockAttributes(string dpe, dyn_anytype &dpc)  
{  
  dpc=globalAnytype;  
}  
  
paSaveAllLockAttributes(string OpenConfig,bool &allright)  
{  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for auth  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetAuth(string dpe,anytype &dpc)  
{  
  int            i,ber;  
  char           cber;  
  dyn_int        _write;  
  dyn_string     configs;  
  dyn_dyn_string conf;  
  dyn_string     dsConfigsNeutral;
  
  paGetNeutralConfigs("auth", configs);
  
//  dynSortAsc(configs);  // No dynSort: correspondending field 'conf[i][3]'
  dpc[1]=configs;  
  for (i=1;i<=dynlen(configs);i++)  
  {  
    dpGet(dpe+":_auth."+configs[i]+"._write",cber);  
    ber=cber;  
    _write[i]=ber;
    dsConfigsNeutral[i] = configs[i];
  }  
  dpc[2]=_write;  
  dpc[3]=dsConfigsNeutral;
}  
  
paDpSetAuth(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int  i,Id=paMyModuleId();  
  char cber;  
  
  if(paDebug) DebugTN("paDpSetConfig():",dpc);  
  
  for (i=1;i<=dynlen(dpc[1]);i++)  
  {  
    if (dpc[2][i]!=globalDpc[Id][2][i])  
    {  
      cber=dpc[2][i];  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_auth."+dpc[1][i]+"._write",cber),all_right);  
      if (!all_right) break;
    }  
  }  
}          
  
paDpCopyAuth(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllAuthAttributes(string dpe, dyn_anytype dpc)  
{  
  int     i,len;  
  string  sber;  
  dyn_int _write;  
  
  setValue("_auth___write","deleteAllLines",   
                           "selectColors","_ButtonShadow","_Window",   
                           "tableMode",TABLE_SELECT_BROWSE,   
                           "selectByClick",TABLE_SELECT_LINE,   
                           "sortOnClick",false);   
  len=dynlen(dpc[1]);  
  for (i=1;i<=len;i++)  
  {  
    if (dpc[2][i]==255) sber="x"; else sber=dpc[2][i];  
    setValue("_auth___write","updateLine",1,"konfig",dpc[1][i],         // Parametriesprachlicher Bezeichner
                                            "konfigNeutral", dpc[3][i], // Neutralsprachlicher Bezeichner
                                            "berecht",sber);  
    setValue("_auth___write","cellBackColRC",i-1,"berecht","_Window") ;  
  }  
  setValue("_auth___write","visible",true);  
}  
  
bool paReadPanelAllAuthAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        i,cnt,ber,Id=paMyModuleId();  
  string     sber,cfg;  
  dyn_int    _write;  
  dyn_string configs;  
  
  dpc=globalAnytype;  
  
  getValue("_auth___write","lineCount",cnt);  
  for (i=1;i<=cnt;i++)  
  {  
    getValue("_auth___write","cellValueRC",i-1,"konfig",cfg,  
                             "cellValueRC",i-1,"berecht",sber);  
    configs[i]=cfg;  
    if (sber=="x") ber=255; else ber=sber;  
    _write[i]=ber;  
  }  
  dpc[1]=configs;  
  dpc[2]=_write;  
}  
  
paSaveAllAuthAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllAuthAttributes(dpe,dpc);  
  paDpSetAuth(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for pv_range  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetPvRange(string dpe,anytype &dpc)  
{  
  int         type,pos;  
  bool        neg,ign,min_incl,max_incl;  
  string      match;  
  anytype     min,max;  
  dyn_string  set;  
  
  dpGet(dpe+":_pv_range.._type",type);  
  switch (type)  
  {  
    case DPCONFIG_NONE:  
      break;  
    case DPCONFIG_SET_PVSS_RANGECHECK:  
      dpGet(dpe+":_pv_range.._neg",neg,  
            dpe+":_pv_range.._ignor_inv",ign,  
            dpe+":_pv_range.._set",set);  
      break;  
    case DPCONFIG_MINMAX_PVSS_RANGECHECK:  
      dpGet(dpe+":_pv_range.._neg",neg,  
            dpe+":_pv_range.._ignor_inv",ign,  
            dpe+":_pv_range.._min",min,  
            dpe+":_pv_range.._max",max,  
            dpe+":_pv_range.._incl_min",min_incl,  
            dpe+":_pv_range.._incl_max",max_incl);  
      break;  
    case DPCONFIG_MATCH_PVSS_RANGECHECK:  
      dpGet(dpe+":_pv_range.._neg",neg,  
            dpe+":_pv_range.._ignor_inv",ign,  
            dpe+":_pv_range.._match",match);  
      break;  
  }  
  dpc[1]=type;  
  dpc[2]=neg;  
  dpc[3]=ign;  
  dpc[4]=min;  
  dpc[5]=max;  
  dpc[6]=min_incl;  
  dpc[7]=max_incl;  
  dpc[8]=set;  
  dpc[9]=match;  
}  
  
paDpSetPvRange(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int        ok,u,oldtype,dpaType=dpElementType(dpe);  
  dyn_string sPara=makeDynString(paGetCatStr("para","mingtmax"));  
  
  dpGet(dpe+":_pv_range.._type",oldtype);  
  if (dpc[1]!=oldtype)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_pv_range.._type",dpc[1]),all_right);  
  if (!all_right) {all_right=false; return;}
  switch (dpc[1])  
  {  
    case DPCONFIG_NONE:  
      break;  
    case DPCONFIG_SET_PVSS_RANGECHECK:  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_pv_range.._neg",dpc[2],  
                  dpe+":_pv_range.._ignor_inv",dpc[3],  
                  dpe+":_pv_range.._set",dpc[8]),all_right);  
      break;  
    case DPCONFIG_MINMAX_PVSS_RANGECHECK:  
      if (dpc[4]>dpc[5])  
      {  
        paChildPanelOn("vision/MessageWarning",  
                       paGetCatStr("para","warning"),  
                       "","",true,false,-1,-1,sPara,ok);  
        all_right=false; return;  
      }  
      paCheckValue(dpaType,dpc[4],true,u);  
      {  
        if (u<0) {all_right=false; return;}  
      }  
      paCheckValue(dpaType,dpc[5],true,u);  
      {  
        if (u<0) {all_right=false; return;}  
      }  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_pv_range.._neg",dpc[2],  
                  dpe+":_pv_range.._ignor_inv",dpc[3],  
                  dpe+":_pv_range.._min",dpc[4],  
                  dpe+":_pv_range.._max",dpc[5],  
                  dpe+":_pv_range.._incl_min",dpc[6],  
                  dpe+":_pv_range.._incl_max",dpc[7]),all_right);  
      break;  
    case DPCONFIG_MATCH_PVSS_RANGECHECK:  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_pv_range.._neg",dpc[2],  
                  dpe+":_pv_range.._ignor_inv",dpc[3],  
                  dpe+":_pv_range.._match",dpc[9]),all_right);  
      break;  
  }  
}  
  
paDpCopyPvRange(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllPvRangeAttributes(string dpe, dyn_anytype dpc)  
{  
  int        type,pos; 
  bool       all_right;
  string     s,form,unit,  
             s_minmax=paGetCatStr("para","minmax_range"),  
             s_match=paGetCatStr("para","match_range"),  
             s_set=paGetCatStr("para","set_range");  
  dyn_string ds;  
  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  switch (dpElementType(dpe))  
  {  
    case DPEL_CHAR:  
    case DPEL_INT:
    case DPEL_CHAR_STRUCT:  
    case DPEL_INT_STRUCT:
      ds=makeDynString(s_minmax,s_set);  
      break;  
    case DPEL_UINT:
    case DPEL_UINT_STRUCT:
      ds=makeDynString(s_minmax,s_set,s_match);  
      break;  
    case DPEL_FLOAT:
    case DPEL_FLOAT_STRUCT:
      ds=makeDynString(s_minmax,s_set);  
      break;  
    case DPEL_BIT32:  
    case DPEL_STRING:
    case DPEL_BIT32_STRUCT:  
    case DPEL_STRING_STRUCT:
      ds=makeDynString(s_set,s_match);
      break;  
    default: ds=makeDynString(s_set);  
  }  
  setValue("type","items",ds);  
  switch (dpc[1])  
  {  
    case DPCONFIG_NONE: s=s_set;  
      paErrorHandlingDpSet(  
      dpSetWait(dpe+":_pv_range.._type",DPCONFIG_SET_PVSS_RANGECHECK),all_right);  
      break;  
    case DPCONFIG_SET_PVSS_RANGECHECK: s=s_set;break;  
    case DPCONFIG_MINMAX_PVSS_RANGECHECK: s=s_minmax;break;  
    case DPCONFIG_MATCH_PVSS_RANGECHECK: s=s_match;break;  
    default: s="";  
  }  
  pos=dynContains(ds,s);  
  if (pos>0)  
    setValue("type","selectedPos",pos,"text",ds[pos]);  
  setMultiValue("dyn_input","format",form,  
                "min","format",form,  
                "max","format",form);
  setMultiValue("match","visible",(s==s_match),  
                "match","text",dpc[9],  
                "match1","visible",(s==s_match),  
                "match2","visible",(s==s_match),  
                "set","visible",(s==s_set),  
                "unit_set","visible",(s==s_set),  
                "dyn_list","items",dpc[8],  
                "set1","visible",(s==s_set),  
                "set2","visible",(s==s_set),  
                "min","visible",(s==s_minmax),  
                "unit_min","visible",(s==s_minmax),  
                "min","text",dpc[4],  
                "min1","visible",(s==s_minmax),  
                "min2","visible",(s==s_minmax),  
                "min_incl","visible",(s==s_minmax),  
                "min_incl","state",0,dpc[6],  
                "max","visible",(s==s_minmax),  
                "unit_max","visible",(s==s_minmax),  
                "max","text",dpc[5],  
                "max1","visible",(s==s_minmax),  
                "max2","visible",(s==s_minmax),  
                "max_incl","visible",(s==s_minmax),  
                "max_incl","state",0,dpc[7],  
                "neg","state",0,dpc[2],  
                "ign","state",0,dpc[3],  
                "pb_editor","visible",((s==s_set) && (paIsNative[paMyModuleId()])),  
                "pb_select","visible",(dpElementType(dpe)==DPEL_DPID),  
                "unit_set","text",unit,  
                "unit_min","text",unit,  
                "unit_max","text",unit);  
}  
  
bool paReadPanelAllPvRangeAttributes(string dpe, dyn_anytype &dpc)  
{  
  bool       neg,ign,min_incl,max_incl;  
  string     type,match,sMin,sMax;  
  anytype    min,max;  
  dyn_string set;  

  if (dpElementType(dpe)==DPEL_CHAR || dpElementType(dpe)==DPEL_CHAR_STRUCT)
  { min=" ";max=" "; }
  else
  { min=0.0; max=0.0; }
  dpc=globalAnytype;  
  getMultiValue("type","text",type,  
                "match","text",match,  
                "dyn_list","items",set,  
                "min","text",sMin,  
                "min","text",min,  
                "min_incl","state",0,min_incl,  
                "max","text",sMax,  
                "max","text",max,  
                "max_incl","state",0,max_incl,  
                "neg","state",0,neg,  
                "ign","state",0,ign);  
  
  switch (type)  
  {  
    case paGetCatStr("para","set_range"):    dpc[1]=DPCONFIG_SET_PVSS_RANGECHECK;break;  
    case paGetCatStr("para","minmax_range"): dpc[1]=DPCONFIG_MINMAX_PVSS_RANGECHECK;break;  
    case paGetCatStr("para","match_range"):  dpc[1]=DPCONFIG_MATCH_PVSS_RANGECHECK;break;  
    default:                                 dpc[1]=DPCONFIG_NONE;  
  }  
  dpc[2]=neg;  
  dpc[3]=ign;
  if (dpElementType(dpe)==DPEL_UINT)
  {
    dpc[4]=(strpos(sMin,"*")<0)?min:minUINT();  
    dpc[5]=(strpos(sMax,"*")<0)?max:maxUINT();
  }
  else
  if (dpElementType(dpe)==DPEL_INT)
  {
    dpc[4]=(strpos(sMin,"*")<0)?min:minINT();  
    dpc[5]=(strpos(sMax,"*")<0)?max:maxINT();
  }
  else
  if (dpElementType(dpe)==DPEL_FLOAT)
  {
    dpc[4]=(strpos(sMin,"*")<0)?min:minFLOAT();  
    dpc[5]=(strpos(sMax,"*")<0)?max:maxFLOAT();
  }
  else
  {
    dpc[4]=min;  
    dpc[5]=max;
  }
  dpc[6]=min_incl;  
  dpc[7]=max_incl;  
  dpc[8]=set;  
  dpc[9]=match;  
}  
  
paSaveAllPvRangeAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllPvRangeAttributes(dpe,dpc);  
  paDpSetPvRange(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for u_range  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetURange(string dpe,anytype &dpc)  
{  
  int            i,pos;  
  anytype        empty;  
  dyn_int        type,list;  
  dyn_bool       neg,min_incl,max_incl;  
  dyn_string     match;  
  dyn_anytype    min,max,da;  
  dyn_dyn_string set;  
  
  dpc=da;  
  dpGet(dpe+":_u_range.._list_auth",list);  
  for (i=1;i<33;i++)  
  {  
    type[i]=DPDETAIL_RANGETYPE_NONE;  
    neg[i]=false;  
    if (dpElementType(dpe)==DPEL_CHAR || dpElementType(dpe)==DPEL_CHAR_STRUCT)
    { min[i]=" ";max[i]=" "; }
    else
    { min[i]=0.0; max[i]=0.0; }
    min_incl[i]=true;  
    max_incl[i]=true; 
    dpc[i]=da;
    set[i]=makeDynString();  
    match[i]="";  
    if (dynContains(list,i)>0)  
    {  
      dpGet(dpe+":_u_range."+i+"._type",type[i]);  
      switch (type[i])  
      {  
        case DPDETAIL_RANGETYPE_NONE:  
        case DPDETAIL_RANGETYPE_RANGE_ALL:  
          break;  
        case DPDETAIL_RANGETYPE_SET:  
          dpGet(dpe+":_u_range."+i+"._neg",neg[i],  
                dpe+":_u_range."+i+"._set",set[i]);  
          break;  
        case DPDETAIL_RANGETYPE_MINMAX:  
          dpGet(dpe+":_u_range."+i+"._neg",neg[i],  
                dpe+":_u_range."+i+"._min",min[i],  
                dpe+":_u_range."+i+"._max",max[i],  
                dpe+":_u_range."+i+"._incl_min",min_incl[i],  
                dpe+":_u_range."+i+"._incl_max",max_incl[i]);  
          break;  
        case DPDETAIL_RANGETYPE_MATCH:  
          dpGet(dpe+":_u_range."+i+"._neg",neg[i],  
                dpe+":_u_range."+i+"._match",match[i]);  
          break;  
      }  
    }  
    dpc[i][1]=type[i];  
    dpc[i][2]=neg[i];  
    dpc[i][3]=0;  
    dpc[i][4]=min[i];  
    dpc[i][5]=max[i];  
    dpc[i][6]=min_incl[i];  
    dpc[i][7]=max_incl[i];  
    dpc[i][8]=set[i];  
    dpc[i][9]=match[i];  
  }  
  globalURangeDpc=dpc;  
  globalURangeDpcOld=dpc;  
}  
  
paDpSetURange(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int        i,u,ok,dpaType=dpElementType(dpe);  
  dyn_string sPara;  
  
  for (i=1;i<33;i++)  
  {  
    if (dpc[i][1]!=DPDETAIL_RANGETYPE_NONE ||  
//        globalURangeDpcOld[i][1]!=DPDETAIL_RANGETYPE_NONE)  
        globalURangeDpc[i][1]!=DPDETAIL_RANGETYPE_NONE)  
    {  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_u_range."+i+"._type",dpc[i][1]),all_right);  
      if (!all_right) break;
      switch (dpc[i][1])  
      {  
        case DPDETAIL_RANGETYPE_NONE:  
        case DPDETAIL_RANGETYPE_RANGE_ALL:  
          break;  
        case DPDETAIL_RANGETYPE_SET:  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_u_range."+i+"._neg",dpc[i][2],  
                      dpe+":_u_range."+i+"._set",dpc[i][8]),all_right);  
          break;  
        case DPDETAIL_RANGETYPE_MINMAX:  
          if (dpc[i][4]>dpc[i][5])  
          {  
            sPara=makeDynString(paGetCatStr("para","mingtmax"));  
            paChildPanelOn("vision/MessageWarning",  
                           paGetCatStr("para","warning"),  
                           "","",true,false,-1,-1,sPara,ok);  
            setValue("_list_auth","text",i);  
            all_right=false; break;  
          }  
          paCheckValue(dpaType,dpc[i][4],true,u);  
          {  
            if (u<0) {all_right=false; break;}  
            setValue("_list_auth","text",i);  
          }  
          paCheckValue(dpaType,dpc[i][5],true,u);  
          {  
            if (u<0) {all_right=false; break;}  
            setValue("_list_auth","text",i);  
          }  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_u_range."+i+"._neg",dpc[i][2],  
                      dpe+":_u_range."+i+"._min",dpc[i][4],  
                      dpe+":_u_range."+i+"._max",dpc[i][5],  
                      dpe+":_u_range."+i+"._incl_min",dpc[i][6],  
                      dpe+":_u_range."+i+"._incl_max",dpc[i][7]),all_right);  
          break;  
        case DPDETAIL_RANGETYPE_MATCH:  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_u_range."+i+"._neg",dpc[i][2],  
                      dpe+":_u_range."+i+"._match",dpc[i][9]),all_right);  
          break;  
      }
      if (!all_right) break;
    }  
    if (!all_right) break;
  }  
}  
  
paDpCopyURange(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllURangeAttributes(string dpe, dyn_anytype dpc)  
{  
  int        type,pos,detail;  
  string     s,form,unit,  
             s_none=paGetCatStr("para","none_range"),  
             s_minmax=paGetCatStr("para","minmax_range"),  
             s_match=paGetCatStr("para","match_range"),  
             s_set=paGetCatStr("para","set_range"),  
             s_all=paGetCatStr("para","all_range");  
  dyn_string ds;  
  
  getValue("_list_auth","text",detail);  
  dpValueFieldFormat(dpe,form);  
  paSetUnit(dpe,unit);  
  switch (dpElementType(dpe))  
  {  
    case DPEL_INT: ds=makeDynString(s_none,s_minmax,s_set,s_all); break;  
    case DPEL_UINT: ds=makeDynString(s_none,s_minmax,s_set,s_match,s_all); break;  
    case DPEL_FLOAT: ds=makeDynString(s_none,s_minmax,s_set,s_all); break;  
    case DPEL_BIT32: ds=makeDynString(s_none,s_set,s_match,s_all); break;  
    case DPEL_STRING: ds=makeDynString(s_none,s_set,s_match,s_all); break;  
    case DPEL_INT_STRUCT: ds=makeDynString(s_none,s_minmax,s_set,s_all); break;  
    case DPEL_UINT_STRUCT: ds=makeDynString(s_none,s_minmax,s_set,s_match,s_all); break;  
    case DPEL_FLOAT_STRUCT: ds=makeDynString(s_none,s_minmax,s_set,s_all); break;  
    case DPEL_BIT32_STRUCT: ds=makeDynString(s_none,s_set,s_match,s_all); break;  
    case DPEL_STRING_STRUCT: ds=makeDynString(s_none,s_set,s_match,s_all); break;  
    default: ds=makeDynString(s_none,s_set,s_all);  
  }  
  setValue("type","items",ds);  
  switch (dpc[detail][1])  
  {  
    case DPDETAIL_RANGETYPE_NONE: s=s_none;break;  
    case DPDETAIL_RANGETYPE_SET: s=s_set;break;  
    case DPDETAIL_RANGETYPE_MINMAX: s=s_minmax;break;  
    case DPDETAIL_RANGETYPE_MATCH: s=s_match;break;  
    case DPDETAIL_RANGETYPE_RANGE_ALL: s=s_all;break;  
    default: s="";  
  }  
  pos=dynContains(ds,s);  
  if (pos>0)  
    setValue("type","selectedPos",pos,"text",ds[pos]);  
  setMultiValue("dyn_input","format",form,
                "max","format",form,  
                "min","format",form);
  setMultiValue("act_detail","text",detail,  
                "_list_auth","text",detail,  
                "match","visible",(s==s_match),  
                "match","text",dpc[detail][9],  
                "match1","visible",(s==s_match),  
                "match2","visible",(s==s_match),  
                "set","visible",(s==s_set),  
                "unit_set","visible",(s==s_set),  
                "dyn_list","items",dpc[detail][8],  
                "set1","visible",(s==s_set),  
                "set2","visible",(s==s_set),  
                "unit_min","visible",(s==s_minmax),  
                "min","visible",(s==s_minmax),  
                "min","text",dpc[detail][4],  
                "min0","visible",(s==s_minmax),  
                "min1","visible",(s==s_minmax),  
                "min2","visible",(s==s_minmax),  
                "min_incl","visible",(s==s_minmax),  
                "min_incl","state",0,dpc[detail][6],  
                "unit_max","visible",(s==s_minmax),  
                "max","visible",(s==s_minmax),  
                "max","text",dpc[detail][5],  
                "max1","visible",(s==s_minmax),  
                "max_incl","visible",(s==s_minmax),  
                "max_incl","state",0,dpc[detail][7],  
                "neg","visible",(s!=s_none && s!=s_all),   
                "neg","state",0,dpc[detail][2],  
                "bits1","visible",(s!=paGetCatStr("para","none_range") && s!=s_all),   
                "bits2","visible",(s!=paGetCatStr("para","none_range") && s!=s_all),   
                "pb_editor","visible",((s==s_set) && (paIsNative[paMyModuleId()])),  
                "pb_select","visible",(dpElementType(dpe)==DPEL_DPID),  
                "unit_set","text",unit,  
                "unit_min","text",unit,  
                "unit_max","text",unit);  
}  
  
bool paReadPanelAllURangeAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        act;  
  bool       neg,min_incl,max_incl;  
  string     s,match,form;  
  anytype    min,max;  
  dyn_string set;  
  
  if (dpElementType(dpe)==DPEL_CHAR || dpElementType(dpe)==DPEL_CHAR_STRUCT)
  { min=" ";max=" "; }
  else
  { min=0.0; max=0.0; }
  dpc=globalAnytype;  
  getMultiValue("act_detail","text",act,  
                "type","text",s,  
                "match","text",match,   
                "dyn_list","items",set,   
                "min","text",min,   
                "min_incl","state",0,min_incl,   
                "max","text",max,   
                "max_incl","state",0,max_incl,   
                "neg","state",0,neg);   
  switch (s)   
  {   
    case paGetCatStr("para","none_range"):  
      globalURangeDpc[act][1]=DPDETAIL_RANGETYPE_NONE;  
      break;   
    case paGetCatStr("para","set_range"):  
      globalURangeDpc[act][1]=DPDETAIL_RANGETYPE_SET;  
      globalURangeDpc[act][8]=set;   
      globalURangeDpc[act][2]=neg;   
      break;   
    case paGetCatStr("para","minmax_range"):  
      globalURangeDpc[act][1]=DPDETAIL_RANGETYPE_MINMAX;  
      globalURangeDpc[act][4]=min;   
      globalURangeDpc[act][5]=max;   
      globalURangeDpc[act][6]=min_incl;   
      globalURangeDpc[act][7]=max_incl;   
      globalURangeDpc[act][2]=neg;   
      break;   
    case paGetCatStr("para","match_range"):  
      globalURangeDpc[act][1]=DPDETAIL_RANGETYPE_MATCH;  
      globalURangeDpc[act][9]=match;   
      globalURangeDpc[act][2]=neg;   
      break;   
    case paGetCatStr("para","all_range"):  
      globalURangeDpc[act][1]=DPDETAIL_RANGETYPE_RANGE_ALL;  
      break;   
  }   
  dpc=globalURangeDpc;  
}  
  
paSaveAllURangeAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  

  paReadPanelAllURangeAttributes(dpe,dpc);  
  paDpSetURange(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for dp_function  
// The global variables globalFctNew, globalFctOld, globalFctTypes  
// will be defined in dp_function.pnl (panel attributes - Meldescript)  
// and in para.pnl (events),  
// they will be deleted in paDeleteGlobals.  
// Values in globalFctTypes:  ("DP","STAT")  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetDpFct(string dpe,anytype &dpc)  
{
  unsigned   de;
  int        i,type,in,ti,dw,da,mo, 
             fi,fd,li,ld,zw,zy,  
             f1,f2,f3,f4,f5,f6,f7,f8,l1,l2,l3,l4,l5,l6,l7,l8;  
  bool       ra;  
  string     fct;  
  dyn_int    st;  
  dyn_string param,globals;  
  
  dpc=globalAnytype;  
  switch (globalFctOld[paMyModuleId()])  
  {  
    case "":  
      dpGet(dpe+":_dp_fct.._type",type);  
      dpc[1]=type;  
    break;  
    case "DP":  
      dpGet(dpe+":_dp_fct.._param",param,  
            dpe+":_dp_fct.._global",globals,  
            dpe+":_dp_fct.._fct",fct);  
      for (i=1;i<=dynlen(param);i++)  
      {  
        param[i]="p"+i+"="+dpSubStr(param[i],DPSUB_DP_EL_CONF_DET_ATT);  
      }  
      for (i=1;i<=dynlen(globals);i++)  
      {  
        globals[i]="g"+i+"="+dpSubStr(globals[i],DPSUB_DP_EL_CONF_DET_ATT);  
      }  
      dpc[1]=DPCONFIG_DP_FUNCTION;  
      dpc[2]=param;  
      dpc[3]=globals;  
      dpc[4]=fct;  
    break;  
    case "STAT":  
      dpGet(dpe+":_dp_fct.._param",param,  
            dpe+":_dp_fct.._global",globals,  
            dpe+":_dp_fct.._fct",fct,  
            dpe+":_dp_fct.._stat_type",st,  
            dpe+":_dp_fct.._interval",in,  
            dpe+":_dp_fct.._time",ti,  
            dpe+":_dp_fct.._day_of_week",dw,  
            dpe+":_dp_fct.._day",da,  
            dpe+":_dp_fct.._month",mo,  
            dpe+":_dp_fct.._delay",de,  
            dpe+":_dp_fct.._read_archive",ra,  
            dpe+":_dp_fct.._inv_func",fi,  
            dpe+":_dp_fct.._inv_limit",li,  
            dpe+":_dp_fct.._def_func",fd,  
            dpe+":_dp_fct.._def_limit",ld,  
            dpe+":_dp_fct.._user1_func",f1,  
            dpe+":_dp_fct.._user1_limit",l1,  
            dpe+":_dp_fct.._user2_func",f2,  
            dpe+":_dp_fct.._user2_limit",l2,  
            dpe+":_dp_fct.._user3_func",f3,  
            dpe+":_dp_fct.._user3_limit",l3,  
            dpe+":_dp_fct.._user4_func",f4,  
            dpe+":_dp_fct.._user4_limit",l4,  
            dpe+":_dp_fct.._user5_func",f5,  
            dpe+":_dp_fct.._user5_limit",l5,  
            dpe+":_dp_fct.._user6_func",f6,  
            dpe+":_dp_fct.._user6_limit",l6,  
            dpe+":_dp_fct.._user7_func",f7,  
            dpe+":_dp_fct.._user7_limit",l7,  
            dpe+":_dp_fct.._user8_func",f8,  
            dpe+":_dp_fct.._user8_limit",l8,  
            dpe+":_dp_fct.._interm_res",zw,  
            dpe+":_dp_fct.._interm_res_cyc",zy);  
  
      for (i=1;i<=dynlen(param);i++)  
      {  
        param[i]="p"+i+"="+dpSubStr(param[i],DPSUB_DP_EL_CONF_DET_ATT);  
      }  
      for (i=1;i<=dynlen(globals);i++)  
      {  
        globals[i]="g"+i+"="+dpSubStr(globals[i],DPSUB_DP_EL_CONF_DET_ATT);  
      }  
      dpc[1]=DPCONFIG_STAT_FUNCTION;  
      dpc[2]=param;  
      dpc[3]=globals;  
      dpc[4]=fct;  
      dpc[5]=st;dpc[6]=in;dpc[7]=ti;dpc[8]=dw;dpc[9]=da;dpc[10]=mo;dpc[11]=de;dpc[12]=ra;  
      dpc[13]=fi;dpc[14]=li;  
      dpc[15]=fd;dpc[16]=ld;  
      dpc[17]=f1;dpc[18]=l1;dpc[19]=f2;dpc[20]=l2;  
      dpc[21]=f3;dpc[22]=l3;dpc[23]=f4;dpc[24]=l4;  
      dpc[25]=f5;dpc[26]=l5;dpc[27]=f6;dpc[28]=l6;  
      dpc[29]=f7;dpc[30]=l7;dpc[31]=f8;dpc[32]=l8;  
      dpc[33]=zw;dpc[34]=zy; 
      
      // begin TI 17326 
      if ( dynlen(dpc[5]) > 0 && dpc[5][i] > 63 ) // floating calc?
      {
        dpc[35] = TRUE; // yes
        for ( i = 1; i <= dynlen(dpc[5]); i++ )
        {
          if ( dpc[5][i] > 63 ) dpc[5][i] -= 64;
        }
      }
      else
      {
        dpc[35] = FALSE; // no
      }
      // end TI 17326 

    break;  
  }  
}  
  
paDpSetDpFct(string dpe, dyn_anytype dpc,bool &ok)  
{  
  int        type,i,x,fu=0;  
  bool       bit_ok=true,f_ok,all_right;  
  string     fct2,s1;
  unsigned   uNull=0;
  dyn_string sPara;  
  
  if (globalFctOld[paMyModuleId()]=="")  
    return;  
  
  fct2=dpc[4];  
  for (i=1;i<=dynlen(dpc[2]);i++)  
  {  
    dpc[2][i]=strsplit(dpc[2][i],"=")[2];  
    if (dpSubStr(dpc[2][i],DPSUB_DP_EL)==dpSubStr(dpe,DPSUB_DP_EL))  
    {  
      sPara=makeDynString(paGetCatStr("para","paracycle")+"\n(p"+i+")");  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
      break;  
    }  
    else  
    if (!dpExists(dpSubStr(dpc[2][i],DPSUB_DP)))  
    {  
      sPara=makeDynString(paGetCatStr("para","dpnotexists")+"\n(p"+i+")");  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
      break;  
    }  
    else  
    if (strpos(dpc[2][i],':')<0)  
      dpc[2][i]+=":_original.._value";  
  }  
  if (ok)  
  {  
    for (i=1;i<=dynlen(dpc[3]);i++)  
    {  
      dpc[3][i]=strsplit(dpc[3][i],"=")[2];  
      if (!dpExists(dpSubStr(dpc[3][i],DPSUB_DP)))  
      {  
        sPara=makeDynString(paGetCatStr("para","dpnotexists")+"\n(g"+i+")");  
        paChildPanelOn("vision/MessageWarning",  
                       paGetCatStr("para","warning"),  
                       "","",true,false,-1,-1,sPara,ok);  
        ok=false;  
        break;  
      }  
      else  
      if (strpos(dpc[3][i],':')<0)  
        dpc[3][i]+=":_original.._value";  
    }  
  }  
  if (ok)  
  {  
    if (strltrim(strrtrim(dpc[4]))=="" && (dynlen(dpc[2])>0 || dynlen(dpc[3])>0))  
    {  
      sPara=makeDynString(paGetCatStr("para","wrongfunction"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
    }  
  }  
  if (ok)  
  {  
    while (strlen(dpc[4])>0 && strpos(dpc[4],"p")>=0)  
    {  
      dpc[4]=substr(dpc[4],strpos(dpc[4],"p")+1,strlen(dpc[4])-strpos(dpc[4],"p")-1);  
      if (dpc[4][0]>="1" && dpc[4][0]<="9")  
      {  
        i=0; s1="";x=0;  
        while (i<=strlen(dpc[4]) && dpc[4][i]>="0" && dpc[4][i]<="9")  
        {  
          s1+=dpc[4][i]; i++;  
        }  
        sscanf(s1,"%d",x);  
        if (x>dynlen(dpc[2]) || x==0)  
        {  
          sPara=makeDynString("p-"+paGetCatStr("para","adjustparam"));  
          paChildPanelOn("vision/MessageWarning",  
                         paGetCatStr("para","warning"),  
                         "","",true,false,-1,-1,sPara,ok);  
          ok=false;  
          break;  
        }  
      }  
    }  
  }  
  if (ok)  
  {  
    dpc[4]=fct2;  
    while (strlen(dpc[4])>0 && strpos(dpc[4],"g")>=0)  
    {  
      dpc[4]=substr(dpc[4],strpos(dpc[4],"g")+1,strlen(dpc[4])-strpos(dpc[4],"g")-1);  
      if (dpc[4][0]>="1" && dpc[4][0]<="9")  
      {  
        i=0; s1="";x=0;  
        while (i<=strlen(dpc[4]) && dpc[4][i]>="0" && dpc[4][i]<="9")  
        {  
          s1+=dpc[4][i]; i++;  
        }  
        sscanf(s1,"%d",x);  
        if (x>dynlen(dpc[3]) || x==0)  
        {  
          sPara=makeDynString("g-"+paGetCatStr("para","adjustparam"));  
          paChildPanelOn("vision/MessageWarning",  
                         paGetCatStr("para","warning"),  
                         "","",true,false,-1,-1,sPara,ok);  
          ok=false;  
          break;  
        }  
      }  
    }  
  }  
  if (ok)  
  {  
    dpc[4]=fct2;  
    if (dpc[1]==DPCONFIG_DP_FUNCTION)
    {  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":_dp_fct.._type",dpc[1],
                  dpe+":_dp_fct.._param",dpc[2],  
                  dpe+":_dp_fct.._global",dpc[3],  
                  dpe+":_dp_fct.._fct",fct2),all_right);  
      ok=all_right;
    }
  }  
  
  if (ok && dpc[1]==DPCONFIG_STAT_FUNCTION)  
  {  
    for (i=0;i<10;i++)  
    {  
      if (dpc[i*2+13]<0 || dpc[i*2+13]>2)  
      {  
        sPara=makeDynString(paGetCatStr("para","wrongignorefct"));  
        paChildPanelOn("vision/MessageWarning",  
                       paGetCatStr("para","warning"),  
                       "","",true,false,-1,-1,sPara,ok);  
        ok=false;  
        break;  
      }  
      if (dpc[i*2+14]<-1 || dpc[i*2+14]>100)  
      {  
        sPara=makeDynString(paGetCatStr("para","wronglimitfct"));  
        paChildPanelOn("vision/MessageWarning",  
                       paGetCatStr("para","warning"),  
                       "","",true,false,-1,-1,sPara,ok);  
        ok=false;  
        break;  
      }  
      if (fu==0) fu=dpc[i*2+13];  
      bit_ok=(bit_ok && (dpc[i*2+13]==0 || dpc[i*2+13]==fu));  
    }  
    if (ok && !bit_ok)  
    {  
      sPara=makeDynString(paGetCatStr("para","wrongfunctionality"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
    }  
    if (ok && dpc[33]>0 && dpc[34]>=dpc[6])  
    {  
      sPara=makeDynString(paGetCatStr("para","wronginterval"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
    }  
    if (ok && (dpc[6]<1 || dpc[7]<0 || dpc[11]<uNull))  
    {  
      sPara=makeDynString(paGetCatStr("para","wrongsync"));  
      paChildPanelOn("vision/MessageWarning",  
                     paGetCatStr("para","warning"),  
                     "","",true,false,-1,-1,sPara,ok);  
      ok=false;  
    }  
    if (ok)  
    {  
      for (i=1;i<=dynlen(dpc[2]);i++)  
      {  
        switch (dpElementType(dpSubStr(dpc[2][i],DPSUB_DP_EL)))  
        {  
          case DPEL_UINT: case DPEL_INT: case DPEL_FLOAT:  
            f_ok=(dpc[5][i]==SF_MIN ||  
                  dpc[5][i]==SF_MAX ||  
                  dpc[5][i]==SF_MIN_TIME ||  
                  dpc[5][i]==SF_MAX_TIME ||  
                  dpc[5][i]==SF_NUMBER ||  
                  dpc[5][i]==SF_SUM ||  
                  dpc[5][i]==SF_INTEGRAL0 ||  
                  dpc[5][i]==SF_INTEGRAL1 ||  
                  dpc[5][i]==SF_AVG ||  
                  dpc[5][i]==SF_AVG_WT0 ||  
                  dpc[5][i]==SF_AVG_WT1 ||
                  dpc[5][i]==SF_SAMPLE ||
                  dpc[5][i]==SF_ENDVALUE ||
                  dpc[5][i]==SF_DIFF
                  );  
            break;  
          case DPEL_BOOL:  
            f_ok=(dpc[5][i]==SF_NUMBER ||  
                  dpc[5][i]==SF_TIME0 ||  
                  dpc[5][i]==SF_TIME1 ||  
                  dpc[5][i]==SF_CHANGES ||  
                  dpc[5][i]==SF_CHANGES01 ||  
                  dpc[5][i]==SF_CHANGES10);  
            break;  
          default:   
            f_ok=(dpc[5][i]==SF_NUMBER);   
        }  
        if (!f_ok)  
        {  
          sPara=makeDynString(paGetCatStr("para","wrongstatfunc")+"\n(p"+i+")");  
          paChildPanelOn("vision/MessageWarning",  
                         paGetCatStr("para","warning"),  
                         "","",true,false,-1,-1,sPara,ok);  
          ok=false;  
          break;  
        }  
      }  
    }  
  
    if (ok)  
    {  
      // begin TI 17326 
      if ( dpc[35] ) // floating calc
      {
        for ( i = 1; i <= dynlen(dpc[5]); i++ )
        {
          if ( dpc[5][i] < 64 ) dpc[5][i] += 64;
        }
      }
      // end TI 17326 

      paErrorHandlingDpSet(  
      dpSetWait(dpe+":_dp_fct.._type",dpc[1],
                dpe+":_dp_fct.._param",dpc[2],  
                dpe+":_dp_fct.._global",dpc[3],  
                dpe+":_dp_fct.._fct",fct2,  
                dpe+":_dp_fct.._stat_type",dpc[5],  
                dpe+":_dp_fct.._interval",dpc[6],  
                dpe+":_dp_fct.._time",dpc[7],  
                dpe+":_dp_fct.._day_of_week",dpc[8],  
                dpe+":_dp_fct.._day",dpc[9],  
                dpe+":_dp_fct.._month",dpc[10],  
                dpe+":_dp_fct.._delay",dpc[11],  
                dpe+":_dp_fct.._read_archive",dpc[12],  
                dpe+":_dp_fct.._inv_func",dpc[13],  
                dpe+":_dp_fct.._inv_limit",dpc[14],  
                dpe+":_dp_fct.._def_func",dpc[15],  
                dpe+":_dp_fct.._def_limit",dpc[16],  
                dpe+":_dp_fct.._user1_func",dpc[17],  
                dpe+":_dp_fct.._user1_limit",dpc[18],  
                dpe+":_dp_fct.._user2_func",dpc[19],  
                dpe+":_dp_fct.._user2_limit",dpc[20],  
                dpe+":_dp_fct.._user3_func",dpc[21],  
                dpe+":_dp_fct.._user3_limit",dpc[22],  
                dpe+":_dp_fct.._user4_func",dpc[23],  
                dpe+":_dp_fct.._user4_limit",dpc[24],  
                dpe+":_dp_fct.._user5_func",dpc[25],  
                dpe+":_dp_fct.._user5_limit",dpc[26],  
                dpe+":_dp_fct.._user6_func",dpc[27],  
                dpe+":_dp_fct.._user6_limit",dpc[28],  
                dpe+":_dp_fct.._user7_func",dpc[29],  
                dpe+":_dp_fct.._user7_limit",dpc[30],  
                dpe+":_dp_fct.._user8_func",dpc[31],  
                dpe+":_dp_fct.._user8_limit",dpc[32],  
                dpe+":_dp_fct.._interm_res",dpc[33],  
                dpe+":_dp_fct.._interm_res_cyc",dpc[34]),all_right);  
    }  
  }  
  ok=all_right;
}  
  
paDpCopyDpFct(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllDpFctAttributes(string dpe, dyn_anytype dpc)  
{  
  int        i,j=1,pos,funr,hour,min,sec;  
  string     s,futx;  
  dyn_int    stat_konst=makeDynInt(SF_MIN,SF_MAX,SF_MIN_TIME,SF_MAX_TIME,  
                                   SF_NUMBER,SF_SUM,SF_INTEGRAL0,SF_INTEGRAL1,  
                                   SF_AVG,SF_AVG_WT0,SF_AVG_WT1,SF_TIME0,SF_TIME1,  
                                   SF_CHANGES,SF_CHANGES01,SF_CHANGES10,
                                   SF_SAMPLE,SF_ENDVALUE,SF_DIFF);  
  dyn_string stat_name,stat,txt,ds,  
             wtag,d_zw=makeDynString(paGetCatStr("para","no"),paGetCatStr("para","yes"));  
  
  if (globalFctOld[paMyModuleId()]=="")  
  {  
    if (dpc[1]==DPCONFIG_DP_FUNCTION)  
      setValue("function", "selectedPos",1);  
    else  
      setValue("function", "selectedPos",2);  
    return;  
  }  
  
  for (i=1;i<8;i++)  
  {  
    wtag[i]=paGetCatStr("para","weekday"+i);  
  }  
  setMultiValue("fct_type","text",dpc[1],  
                "dyn_list_global","items",dpc[3],  
                "fct","text",dpc[4],  
                "pb_editor_global","visible",paIsNative[paMyModuleId()]);  
  if (dpc[1]!=DPCONFIG_STAT_FUNCTION)  
    setValue("dyn_list_param","items",dpc[2]);  
  
  if (dpc[1]==DPCONFIG_STAT_FUNCTION)  
  {  
    setValue("wochentag","items",wtag);  
    hour=dpc[7]/3600;min=(dpc[7]-hour*3600)/60;sec=dpc[7]-hour*3600-min*60;  
    setValue("tab","deleteAllLines",   
                   "selectColors","Dunkelgrau","_Window",   
                   "tableMode",TABLE_SELECT_BROWSE,   
                   "selectByClick",TABLE_SELECT_LINE,   
                   "sortOnClick",false);   
    getValue("TB_Eintrag3","items",stat_name);  
    for (i=1;i<=dynlen(dpc[5]);i++)  
    {  
      pos=dynContains(stat_konst,dpc[5][i]);  
      if (pos>0)  
      {  
        ds=strsplit(dpc[2][i],"=");  
        txt[j]="p"+i+"="+stat_name[pos]+"("+ds[2]+")";  
        stat[j++]="f"+i+"="+stat_name[pos];  
      }  
    }  
    if (dpc[8]<0) dpc[8]=0;  
    if (dpc[9]<0) dpc[9]=0;  
    if (dpc[10]<0) dpc[10]=0;  
    setMultiValue("stat_typ","items",dpc[5],  
                  "intervall","text",dpc[6],  
                  "hour","text",hour,  
                  "minute","text",min,  
                  "second","text",sec,  
                  "wt_switch","state",0,(dpc[8]>0),  
                  "wochentag","enabled",(dpc[8]>0),  
                  "wochentag","selectedPos",(dpc[8]>0)?dpc[8]:1,  
                  "wochentag","text",(dpc[8]>0)?wtag[dpc[8]]:wtag[1],  
                  "ta_switch","state",0,(dpc[9]>0),  
                  "tag","enabled",(dpc[9]>0),  
                  "tag","text",(dpc[9]>0)?dpc[9]:1,  
                  "mo_switch","state",0,(dpc[10]>0),  
                  "monat","enabled",(dpc[10]>0),  
                  "monat","text",(dpc[10]>0)?dpc[10]:1,  
                  "verzoegerung","text",(dpc[11]==maxUINT())?0:dpc[11],
                  "verzoegerung","visible",!(dpc[11]==maxUINT()),
                  "txtVerzoegerung","visible",!(dpc[11]==maxUINT()),
                  "chkDelay","state",0,(dpc[11]==maxUINT()),
                  "archivLesen","state",0,dpc[12]);  

    // begin TI 17326 

    floatCalc.state(0) = dpc[35];
    zw.state(0) = !dpc[35];
    zw.visible = !dpc[35];
    zw_intervall.enabled = (dpc[35])?true:(zw.state(0));
    txtFloatCalc.visible = dpc[35];
    // end TI 17326 

    for (i=1;i<=dynlen(stat);i++)  
      setValue("tab","appendLine","tab_fct",stat[i],  
                                  "tab_dpe",dpc[2][i],  
                                  "tab_txt",txt[i]);  
    funr=0;futx=funk(0);  
    for (i=0;i<10;i++)  
    {  
      setMultiValue("bits","state",i,(dpc[13+2*i]>0),  
                    "l"+i,"enabled",(dpc[13+2*i]>0),  
                    "l"+i,"text",(dpc[13+2*i]>0)?dpc[14+2*i]:-1);  
      if (dpc[13+2*i]>0) {funr=dpc[13+2*i];futx=funk(dpc[13+2*i]);}  
    }  
    setMultiValue("bitfct","selectedPos",funr+1,  
                  "bitfct","text",futx,  
                  "dyn_input_param","text","",  
                  "zw","state",0,dpc[33],  
                  "zw_intervall","enabled",(dpc[33] || dpc[35]),  
                  "zw_intervall","text",dpc[34]);  
  }  
}  
  
string funk(int f)  
{  
  dyn_string df=makeDynString(paGetCatStr("para","none"),  
                              paGetCatStr("para","value"),  
                              paGetCatStr("para","interval"));  
  return df[f+1];  
}  
  
//----------------------------------------------------------------------------  
  
paReadPanelAllDpFctAttributes(string dpe, dyn_anytype &dpc, int &error)  
{
  unsigned   de;
  int        i,type,in,ti,wt,da,mo,count,bitfct,  
             fi,fd,li,ld,zw,zy,ff,ll,Id=paMyModuleId(),  
             hour,min,sec;  
  bool       ra,wt_sw,ta_sw,mo_sw,bDelay,bFloatCalc;  
  string     fct,s;  
  dyn_int    st;  
  dyn_string param,globals,wtag,ds;  
  
  error = 0;
  dpc=globalAnytype;  
  
  if (globalFctOld[paMyModuleId()]=="" && myPanelName()=="dp_function")  
  {  
    getValue("function","selectedPos",type);  
    if (type==1) dpc[1]=DPCONFIG_DP_FUNCTION;  
    else dpc[1]=DPCONFIG_STAT_FUNCTION;  
    return;  
  }  
  
  getMultiValue("fct_type","text",type,  
                "dyn_list_global","items",globals,  
                "fct","text",fct);  
  if (type!=DPCONFIG_STAT_FUNCTION)  
  {  
    getValue("dyn_list_param","items",param);  
    dpc[2]=param;  
  }  
  dpc[1]=type;  
  dpc[3]=globals;  
  dpc[4]=fct;  
  
  if (dpc[1]==DPCONFIG_STAT_FUNCTION)  
  {  
    getMultiValue("tab","lineCount",count,  
                  "bitfct","selectedPos",bitfct,  
                  "stat_typ","items",st,  
                  "intervall","text",in,  
                  "hour","text",hour,  
                  "minute","text",min,  
                  "second","text",sec,  
                  "wt_switch","state",0,wt_sw,  
                  "wochentag","selectedPos",wt,  
                  "ta_switch","state",0,ta_sw,  
                  "tag","text",da,  
                  "mo_switch","state",0,mo_sw,  
                  "monat","text",mo,  
                  "verzoegerung","text",de,  
                  "chkDelay","state",0,bDelay, 
                  "archivLesen","state",0,ra,  
                  "zw","state",0,zw,  
                  "zw_intervall","text",zy);  

    for (i=1;i<=count;i++)  
    {  
      getValue("tab","cellValueRC",i-1,"tab_dpe",s);  
      ds[i]=s;  
    }  
    dpc[2]=ds;  
    dpc[5]=st;dpc[6]=in;dpc[7]=hour*3600+min*60+sec;  
    dpc[8]=(wt_sw)?wt:-1;  
    dpc[9]=(ta_sw)?da:-1;  
    dpc[10]=(mo_sw)?mo:-1;  
    dpc[11]=(bDelay)?maxUINT():de;
    dpc[12]=ra;  
    for (i=0;i<10;i++)  
    {  
      getMultiValue("bits","state",i,ff,  
                    "l"+i,"text",ll);  
      dpc[i*2+13]=ff?bitfct-1:0;dpc[i*2+14]=ll;  
    }  
    dpc[33]=zw;  

    // begin TI 17326 
    dpc[35] = (floatCalc.state(0));
    if ( dpc[35] )
    {
      float fzy = zy, fin = in;

      if ( fzy == 0 ) error = 1;
      else
      if ( fmod(fin, fzy) !=0 ) error = 2;
      if ( error != 0 )
      {
        return;
      }
    }
    // end TI 17326 

    if (!zw /* TI 17326 */ && !dpc[35] ) zy=0;  
    dpc[34]=zy;  
  }  
}  
  
paSaveAllDpFctAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  int error = 0;
  // begin TI 17326 
//  paReadPanelAllDpFctAttributes(dpe,dpc);
  paReadPanelAllDpFctAttributes(dpe,dpc,error);
  if ( error )
  {
    dyn_float  dfR;
    dyn_string dsR;
    ChildPanelOnCentralModalReturn("vision/MessageWarning",
      getCatStr("para","warning"),
      makeDynString(getCatStr("para","floatcalc_error"+error)),
      dfR,dsR);
    return;
  }
  // end TI 17326 
  paDpSetDpFct(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//  
// This function numbers throw the parameters and functions in the table  
//  
paSetFctNumber()  
{  
  int         i,count;  
  dyn_string  ds,dss,dsss;  
  dyn_anytype da;  
  
  getValue("tab","lineCount",count);  
  for (i=1;i<=count;i++)  
  {  
    getValue("tab","getLineN",i-1,da);  
    ds=strsplit(da[1],"=");  
    dss=strsplit(da[2],"=");  
    dsss=strsplit(da[3],"=");  
    setValue("tab","cellValueRC",i-1,"tab_fct","f"+i+"="+ds[2],  
                   "cellValueRC",i-1,"tab_dpe","p"+i+"="+dss[2],  
                   "cellValueRC",i-1,"tab_txt","p"+i+"="+dsss[2]);  
  }  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for alert_class  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetAlertClass(string dpe,anytype &dpc)  
{  
  int        type,ackType,prior,perm;  
  bool       arch,del,sAck,iAck,all_right;  
  time       archTime;  
  langString abbr;  
  dyn_string colors=makeDynString("","","","",""),  
             scripts=makeDynString("","","","",""),  
             argList;  
  
  dpc=globalAnytype;  
  dpGet(dpe+":_alert_class.._ack_type",type,  
        dpe+":_alert_class.._prior",prior,  
        dpe+":_alert_class.._abbr",abbr,  
        dpe+":_alert_class.._archive_time",archTime,  
        dpe+":_alert_class.._perm",perm,  
        dpe+":_alert_class.._delete",del,  
        dpe+":_alert_class.._archive",arch,  
        dpe+":_alert_class.._ack_type",ackType,  
        dpe+":_alert_class.._single_ack",sAck,  
        dpe+":_alert_class.._inact_ack",iAck,  
        dpe+":_alert_class.._color_none",colors[1],  
        dpe+":_alert_class.._color_c_nack",colors[2],  
        dpe+":_alert_class.._color_c_ack",colors[3],  
        dpe+":_alert_class.._color_g_nack",colors[4],  
        dpe+":_alert_class.._color_c_g_nack",colors[5],  
        dpe+":_alert_class.._ctrl_none",scripts[1],  
        dpe+":_alert_class.._ctrl_c_nack",scripts[2],  
        dpe+":_alert_class.._ctrl_c_ack",scripts[3],  
        dpe+":_alert_class.._ctrl_g_nack",scripts[4],  
        dpe+":_alert_class.._ctrl_c_g_nack",scripts[5],  
        dpe+":_alert_class.._arg_list",argList);  
  
  dpc[1]=type; dpc[2]=prior; dpc[3]=abbr;    dpc[4]=archTime;  
  dpc[5]=perm; dpc[6]=del;   dpc[7]=arch;    dpc[8]=ackType;  
  dpc[9]=sAck; dpc[10]=iAck; dpc[11]=colors; dpc[12]=scripts; dpc[13]=argList;  
}  
  
paDpSetAlertClass(string dpe, dyn_anytype dpc,bool &all_right)  
{  
  paErrorHandlingDpSet(  
  dpSetWait(dpe+":_alert_class.._prior",dpc[2],  
            dpe+":_alert_class.._abbr",dpc[3],  
            dpe+":_alert_class.._archive_time",dpc[4],  
            dpe+":_alert_class.._perm",dpc[5],  
            dpe+":_alert_class.._delete",dpc[6],  
            dpe+":_alert_class.._archive",dpc[7],  
            dpe+":_alert_class.._ack_type",dpc[8],  
            dpe+":_alert_class.._single_ack",dpc[9],  
            dpe+":_alert_class.._inact_ack",dpc[10],  
            dpe+":_alert_class.._color_none",dpc[11][1],  
            dpe+":_alert_class.._color_c_nack",dpc[11][2],  
            dpe+":_alert_class.._color_c_ack",dpc[11][3],  
            dpe+":_alert_class.._color_g_nack",dpc[11][4],  
            dpe+":_alert_class.._color_c_g_nack",dpc[11][5],  
            dpe+":_alert_class.._ctrl_none",dpc[12][1],  
            dpe+":_alert_class.._ctrl_c_nack",dpc[12][2],  
            dpe+":_alert_class.._ctrl_c_ack",dpc[12][3],  
            dpe+":_alert_class.._ctrl_g_nack",dpc[12][4],  
            dpe+":_alert_class.._ctrl_c_g_nack",dpc[12][5],  
            dpe+":_alert_class.._arg_list",dpc[13]),all_right);  
}  
  
paDpCopyAlertClass(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllAlertClassAttributes(string dpe, dyn_anytype dpc)  
{  
  int        i,nol=getNoOfLangs(),  
             ackType=dpc[8]+1;  
  dyn_bool   db=makeDynBool(true,true,true,true,true);  
  dyn_string ds=dpc[3];
  
//some of the following lines deaktivated by mhaslop 13.10.99 (TI 3352)
//int archTime;

  setMultiValue("Kurzzeichen","text",dpc[3],  
                "Kurzzeichen","editable",(nol<2),  
                "langliste","items",ds,  
                "langedit","visible",(nol>1));  
  switch(ackType)  
  {  
    case 1:  db[3]=false;db[4]=false;db[5]=false;break;  
    case 2:  db[2]=false;db[4]=false;db[5]=false;break;  
    case 3:  db[4]=false;db[5]=false;break;  
    case 4:  db[5]=false;break;  
    default: break;  
  }  
  
//  if (dpc[7]) archTime=period(dpc[4])/86400;  
//  else archTime=0;  
  setMultiValue("type","text",dpc[1],  
                "Meldeprioritaet","text",dpc[2],  
//                "speich_dauer","text",archTime,  
//                "speich_dauer","visible",dpc[7],  
//                "speich_dauer_txt","visible",dpc[7],  
//                "löschen","visible",dpc[7],  
                "qber","state",0,(dpc[5]>0),  
                "Berechtigung","enabled",(dpc[5]>0),  
                "Berechtigung","text",dpc[5],  
//                "löschen","selectedPos",dpc[6]+1,  
                "speich","state",0,dpc[7],  
                "quitt_ein","state",0,dpc[9],  
                "quitt_alt","state",0,dpc[10],  
                "Quittierart","selectedPos",ackType,  
                "dyn_list","items",dpc[13],  
                "pb_editor","visible",paIsNative[paMyModuleId()]);  
  for(i=1;i<6;i++)  
  {  
    if(dpc[11][i]=="")  
      setValue("Meldefarbe"+i,"text",paGetCatStr("para","originalcolor"),"visible",db[i]);  
    else  
      setValue("Meldefarbe"+i,"text",dpc[11][i],"visible",db[i]);  
    setMultiValue("Meldezustand"+i,"foreCol",db[i]?"_3DText":"_ButtonShadow",  
                  "Meldeaktion"+i,"visible",db[i],  
                  "Meldeaktion"+i,"text",dpc[12][i],  
                  "Farbselektor"+i,"visible",db[i],  
                  "Scripteditor"+i,"visible",db[i]);  
  }  
}  
  
bool paReadPanelAllAlertClassAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        i,type,ackType,nol=getNoOfLangs(),prior,perm;  
  bool       arch,sAck,iAck,qber;  
  string     s;  
  langString abbr;  
  dyn_string colors=makeDynString("","","","",""),  
             scripts=makeDynString("","","","",""),  
             argList,ds;  

//some of the following lines deaktivated by mhaslop on 13.10.99 (TI 3352)
//int aTime, del;
//time archTime;  

  
  dpc=globalAnytype;  
  getMultiValue("type","text",type,  
                "Kurzzeichen","text",s,  
                "langliste","items",ds,  
                "Meldeprioritaet","text",prior,  
//                "speich_dauer","text",aTime,  
                "qber","state",0,qber,  
                "Berechtigung","text",perm,  
//                "löschen","selectedPos",del,  
                "speich","state",0,arch,  
                "quitt_ein","state",0,sAck,  
                "quitt_alt","state",0,iAck,  
                "Quittierart","selectedPos",ackType,  
                "dyn_list","items",argList);  
  if (!qber) perm=0;  
  
  if (nol>1) abbr=ds; else abbr=s;  
//  if (arch) aTime*=86400;  
//  else aTime=0;  
//  setPeriod(archTime,aTime);  
//  del--;
  ackType--;  
  for(i=1;i<6;i++) {  
    getMultiValue("Meldefarbe"+i,"text",colors[i],  
                  "Meldeaktion"+i,"text",scripts[i]);  
    if(colors[i]==paGetCatStr("para","originalcolor")) colors[i]="";  
  }  
  dpc[1]=type; dpc[2]=prior; dpc[3]=abbr; dpc[4] = "";  //dpc[4]=archTime;  
  dpc[5]=perm; dpc[7]=arch;  dpc[6] = ""; dpc[8]=ackType;  //dpc[6]=del;
  dpc[9]=sAck; dpc[10]=iAck; dpc[11]=colors; dpc[12]=scripts; dpc[13]=argList;  
}  
  
paSaveAllAlertClassAttributes(string OpenConfig,bool &allright)  
{
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllAlertClassAttributes(dpe,dpc);  
  paDpSetAlertClass(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for alert_hdl  
// NOTICE: the attributes of alert_hdl will be connected in the panel,  
// that's why almost nothing here.  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetAlertHdl(string dpe,anytype &dpc)  
{  
}  
  
paDpSetAlertHdl(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  return;     
}  
  
paDpCopyAlertHdl(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllAlertHdlAttributes(string dpe, dyn_anytype dpc)  
{  
}  
  
bool paReadPanelAllAlertHdlAttributes(string dpe, dyn_anytype &dpc)  
{  
  dpc=globalAnytype;  
}  
  
paSaveAllAlertHdlAttributes(string OpenConfig,bool &allright)  
{  
  int            h1,h2,h3,h4,h5,i1,i2,i3,i4,i5,j1,j2,j3,j4,i,  
                 bw,x,hint,nol=getNoOfLangs(),a,min_prio,ranges;  
  bool           ok, bActivate;  
  string         s,panel,hstr,hstr2,hilfe,
                 dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL),sysname=dpSubStr(dpe,DPSUB_SYS);  
  anytype        f,ho1,hu2,ho2,hu3,ho3,hu4,ho4,hu5;  
  langString     ls_lt;
  dyn_int        b;  
  dyn_string     t,tt,k,param,d_incl=makeDynString("<","<="),sPara,ds_lt;  
  dyn_anytype    g;  
  dyn_langString l;  
  dyn_errClass   err;    
  
  if (dpElementType(dpe)==DPEL_BOOL)// || dpElementType(dpe)==DPEL_BOOL_STRUCT)  
  {  
    paSaveBitAlertHdlAttributes(OpenConfig,allright);  
    return;  
  }  
  else  
  if (dpElementType(dpe)!=DPEL_UINT &&  
      dpElementType(dpe)!=DPEL_INT &&  
      dpElementType(dpe)!=DPEL_FLOAT //&&  
//      dpElementType(dpe)!=DPEL_UINT_STRUCT &&  
//      dpElementType(dpe)!=DPEL_INT_STRUCT &&  
//      dpElementType(dpe)!=DPEL_FLOAT_STRUCT
     )  
  {  
    paSaveSumAlertHdlAttributes(OpenConfig,allright);  
    return;  
  }  
  
  getMultiValue("RB_Bereiche","selectedPos",ranges,  
                "TB_Panel","text",panel,  
                "dyn_list","items",param,  
                "min_prio","text",min_prio,  
                "h1","state",0,h1,  
                "h2","state",0,h2,  
                "h3","state",0,h3,  
                "h4","state",0,h4,  
                "h5","state",0,h5,  
                "ho1","text",ho1,  
                "hu2","text",hu2,  
                "ho2","text",ho2,  
                "hu3","text",hu3,  
                "ho3","text",ho3,  
                "hu4","text",hu4,  
                "ho4","text",ho4,  
                "hu5","text",hu5,
                "aktiv","state",0,bActivate);
  if (nol<2)   
  {   
    getValue("hilfe","text",hilfe);   
    ds_lt[1]=hilfe;   
  }   
  else   
  {   
    getValue("langtextliste","items",ds_lt);   
  }   
  ls_lt=ds_lt;   
  ranges++;  
  for(x=1;x<ranges;x++) {  
    sprintf(hstr,"%d",x);  
    getValue("g"+hstr,"text",f);  
    g[x+1]=f;  
    getValue("b"+hstr,"text",s);hint=dynContains(d_incl,s)-1;  
    if (hint<0 || hint >1) hint=0;  
    b[x+1]=hint;  
    if (nol>1)  
    {  
      getValue("langliste"+hstr,"items",t);  
      l[x]=t;  
    }  
    else  
    {  
      getValue("t"+hstr,"text",tt[1]);  
      l[x]=tt;  
    }  
    getValue("k"+hstr,"text",hstr2);  
    k[x]=(strlen(hstr2)<5)?"":substr(hstr2,4,strlen(hstr2)-4);        
  }  
  sprintf(hstr,"%d",x);  
  if (nol>1)  
  {  
    getValue("langliste"+hstr,"items",t);  
    l[x]=t;  
  }  
  else  
  {  
    getValue("t"+hstr,"text",tt[1]);  
    l[x]=tt;  
  }  
  getValue("k"+hstr,"text",hstr2);  
  k[x]=(strlen(hstr2)<5)?"":substr(hstr2,4,strlen(hstr2)-4);        

  getValue("CB_ori","selectedPos",bw);  
  bw--; 

  for (i=1;i<=ranges;i++)
    if (k[i]!="") k[i]=sysname+k[i];

  if (ranges>4)  
  {  
    if (b[5]==0){ i5=1; j4=0;}  
    else      { i5=0; j4=1;}  
    if (b[4]==0){ i4=1; j3=0;}  
    else      { i4=0; j3=1;}  
    if (b[3]==0){ i3=1; j2=0;}  
    else      { i3=0; j2=1;}  
    if (b[2]==0){ i2=1; j1=0;}  
    else      { i2=0; j1=1;}  
    dpSetWait(dpe+":_alert_hdl.1._type",(ranges>0)?4:0,   
              dpe+":_alert_hdl.2._type",(ranges>1)?4:0,   
              dpe+":_alert_hdl.3._type",(ranges>2)?4:0,   
              dpe+":_alert_hdl.4._type",(ranges>3)?4:0,   
              dpe+":_alert_hdl.5._type",(ranges>4)?4:0,   
              dpe+":_alert_hdl.._panel",panel,   
              dpe+":_alert_hdl.._panel_param",param,   
              dpe+":_alert_hdl.._help",ls_lt,   
              dpe+":_alert_hdl.._min_prio",min_prio,   
              dpe+":_alert_hdl.1._hyst_type",(h1 && ranges>0),   
              dpe+":_alert_hdl.2._hyst_type",(h2 && ranges>1),   
              dpe+":_alert_hdl.3._hyst_type",(h3 && ranges>2),   
              dpe+":_alert_hdl.4._hyst_type",(h4 && ranges>3),   
              dpe+":_alert_hdl.5._hyst_type",(h5 && ranges>4),   
              dpe+":_alert_hdl.5._l_limit",g[5],   
              dpe+":_alert_hdl.4._u_limit",g[5],   
              dpe+":_alert_hdl.4._l_limit",g[4],   
              dpe+":_alert_hdl.3._u_limit",g[4],   
              dpe+":_alert_hdl.3._l_limit",g[3],   
              dpe+":_alert_hdl.2._u_limit",g[3],   
              dpe+":_alert_hdl.2._l_limit",g[2],   
              dpe+":_alert_hdl.1._u_limit",g[2],   
              dpe+":_alert_hdl.5._text",l[5],   
              dpe+":_alert_hdl.4._text",l[4],   
              dpe+":_alert_hdl.3._text",l[3],   
              dpe+":_alert_hdl.2._text",l[2],   
              dpe+":_alert_hdl.1._text",l[1],   
              dpe+":_alert_hdl.5._class",k[5],   
              dpe+":_alert_hdl.4._class",k[4],   
              dpe+":_alert_hdl.3._class",k[3],   
              dpe+":_alert_hdl.2._class",k[2],   
              dpe+":_alert_hdl.1._class",k[1],   
              dpe+":_alert_hdl.5._u_incl",true,   
              dpe+":_alert_hdl.5._l_incl",i5,   
              dpe+":_alert_hdl.4._u_incl",j4,   
              dpe+":_alert_hdl.4._l_incl",i4,   
              dpe+":_alert_hdl.3._u_incl",j3,   
              dpe+":_alert_hdl.3._l_incl",i3,   
              dpe+":_alert_hdl.2._u_incl",j2,   
              dpe+":_alert_hdl.2._l_incl",i2,   
              dpe+":_alert_hdl.1._u_incl",j1,   
              dpe+":_alert_hdl.1._l_incl",true,   
              dpe+":_alert_hdl.._orig_hdl",bw);  
  }  
  else  
  if (ranges>3)  
  {  
    if (b[4]==0){ i4=1; j3=0;}  
    else      { i4=0; j3=1;}  
    if (b[3]==0){ i3=1; j2=0;}  
    else      { i3=0; j2=1;}  
    if (b[2]==0){ i2=1; j1=0;}  
    else      { i2=0; j1=1;}  
    dpSetWait(dpe+":_alert_hdl.1._type",(ranges>0)?4:0,   
              dpe+":_alert_hdl.2._type",(ranges>1)?4:0,   
              dpe+":_alert_hdl.3._type",(ranges>2)?4:0,   
              dpe+":_alert_hdl.4._type",(ranges>3)?4:0,   
              dpe+":_alert_hdl.5._type",(ranges>4)?4:0,   
              dpe+":_alert_hdl.._panel",panel,   
              dpe+":_alert_hdl.._panel_param",param,   
              dpe+":_alert_hdl.._help",ls_lt,   
              dpe+":_alert_hdl.._min_prio",min_prio,   
              dpe+":_alert_hdl.1._hyst_type",(h1 && ranges>0),   
              dpe+":_alert_hdl.2._hyst_type",(h2 && ranges>1),   
              dpe+":_alert_hdl.3._hyst_type",(h3 && ranges>2),   
              dpe+":_alert_hdl.4._hyst_type",(h4 && ranges>3),   
              dpe+":_alert_hdl.4._l_limit",g[4],   
              dpe+":_alert_hdl.3._u_limit",g[4],   
              dpe+":_alert_hdl.3._l_limit",g[3],   
              dpe+":_alert_hdl.2._u_limit",g[3],   
              dpe+":_alert_hdl.2._l_limit",g[2],   
              dpe+":_alert_hdl.1._u_limit",g[2],   
              dpe+":_alert_hdl.4._text",l[4],   
              dpe+":_alert_hdl.3._text",l[3],   
              dpe+":_alert_hdl.2._text",l[2],   
              dpe+":_alert_hdl.1._text",l[1],   
              dpe+":_alert_hdl.4._class",k[4],   
              dpe+":_alert_hdl.3._class",k[3],   
              dpe+":_alert_hdl.2._class",k[2],   
              dpe+":_alert_hdl.1._class",k[1],   
              dpe+":_alert_hdl.4._l_incl",i4,   
              dpe+":_alert_hdl.3._u_incl",j3,   
              dpe+":_alert_hdl.3._l_incl",i3,   
              dpe+":_alert_hdl.2._u_incl",j2,   
              dpe+":_alert_hdl.2._l_incl",i2,   
              dpe+":_alert_hdl.1._u_incl",j1,   
              dpe+":_alert_hdl.1._l_incl",true,   
              dpe+":_alert_hdl.._orig_hdl",bw);   
  }  
  else  
  if (ranges>2)  
  {  
    if (b[3]==0){ i3=1; j2=0;}  
    else      { i3=0; j2=1;}  
    if (b[2]==0){ i2=1; j1=0;}  
    else      { i2=0; j1=1;}  
    dpSetWait(dpe+":_alert_hdl.1._type",(ranges>0)?4:0,   
              dpe+":_alert_hdl.2._type",(ranges>1)?4:0,   
              dpe+":_alert_hdl.3._type",(ranges>2)?4:0,   
              dpe+":_alert_hdl.4._type",(ranges>3)?4:0,   
              dpe+":_alert_hdl.5._type",(ranges>4)?4:0,   
              dpe+":_alert_hdl.._panel",panel,   
              dpe+":_alert_hdl.._panel_param",param,   
              dpe+":_alert_hdl.._help",ls_lt,   
              dpe+":_alert_hdl.._min_prio",min_prio,   
              dpe+":_alert_hdl.1._hyst_type",(h1 && ranges>0),   
              dpe+":_alert_hdl.2._hyst_type",(h2 && ranges>1),   
              dpe+":_alert_hdl.3._hyst_type",(h3 && ranges>2),   
              dpe+":_alert_hdl.3._l_limit",g[3],   
              dpe+":_alert_hdl.2._u_limit",g[3],   
              dpe+":_alert_hdl.2._l_limit",g[2],   
              dpe+":_alert_hdl.1._u_limit",g[2],   
              dpe+":_alert_hdl.3._text",l[3],   
              dpe+":_alert_hdl.2._text",l[2],   
              dpe+":_alert_hdl.1._text",l[1],   
              dpe+":_alert_hdl.3._class",k[3],   
              dpe+":_alert_hdl.2._class",k[2],   
              dpe+":_alert_hdl.1._class",k[1],   
              dpe+":_alert_hdl.3._l_incl",i3,   
              dpe+":_alert_hdl.2._u_incl",j2,   
              dpe+":_alert_hdl.2._l_incl",i2,   
              dpe+":_alert_hdl.1._u_incl",j1,   
              dpe+":_alert_hdl.1._l_incl",true,   
              dpe+":_alert_hdl.._orig_hdl",bw);   
  }  
  else  
  if (ranges>1)  
  {  
    if (b[2]==0){ i2=1; j1=0;}  
    else      { i2=0; j1=1;}  
    dpSetWait(dpe+":_alert_hdl.1._type",(ranges>0)?4:0,   
              dpe+":_alert_hdl.2._type",(ranges>1)?4:0,   
              dpe+":_alert_hdl.3._type",(ranges>2)?4:0,   
              dpe+":_alert_hdl.4._type",(ranges>3)?4:0,   
              dpe+":_alert_hdl.5._type",(ranges>4)?4:0,   
              dpe+":_alert_hdl.._panel",panel,   
              dpe+":_alert_hdl.._panel_param",param,   
              dpe+":_alert_hdl.._help",ls_lt,   
              dpe+":_alert_hdl.._min_prio",min_prio,   
              dpe+":_alert_hdl.1._hyst_type",(h1 && ranges>0),   
              dpe+":_alert_hdl.2._hyst_type",(h2 && ranges>1),   
              dpe+":_alert_hdl.2._l_limit",g[2],   
              dpe+":_alert_hdl.1._u_limit",g[2],   
              dpe+":_alert_hdl.2._text",l[2],   
              dpe+":_alert_hdl.1._text",l[1],   
              dpe+":_alert_hdl.2._class",k[2],   
              dpe+":_alert_hdl.1._class",k[1],   
              dpe+":_alert_hdl.2._l_incl",i2,   
              dpe+":_alert_hdl.1._u_incl",j1,   
              dpe+":_alert_hdl.1._l_incl",true,   
              dpe+":_alert_hdl.._orig_hdl",bw);   
  }  
  
  err = getLastError(); //testen ob ohne Fehler    
  if(dynlen(err) > 0)    
  {  
    allright=false;  
    throwError(err);  
    sPara=makeDynString(paGetCatStr("para","wrongalert"));  
    paChildPanelOn("vision/MessageWarning",  
                   paGetCatStr("para","warning"),  
                   "","",true,false,-1,-1,sPara,ok);  
    errorDialog(err);  
  }   
  else
    allright=true; 
  if (h1 && ranges>0 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.1._u_hyst_limit",ho1),allright);  
  if (h2 && ranges>1 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.2._l_hyst_limit",hu2),allright);  
  if (h2 && ranges>2 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.2._u_hyst_limit",ho2),allright);  
  if (h3 && ranges>2 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.3._l_hyst_limit",hu3),allright);  
  if (h3 && ranges>3 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.3._u_hyst_limit",ho3),allright);  
  if (h4 && ranges>3 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.4._l_hyst_limit",hu4),allright);  
  if (h4 && ranges>4 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.4._u_hyst_limit",ho4),allright);  
  if (h5 && ranges>4 && allright)  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":_alert_hdl.5._l_hyst_limit",hu5),allright);  
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_alert_hdl.._active",bActivate),allright);
}  
  
paSetAlertHysterese()  
{  
  int      h,ranges=0;  
  string   name;  
  dyn_bool hh=makeDynBool(0,0,0,0,0),hv=makeDynBool(0,0,0,0,0);  
  
  getMultiValue("h1","visible",hv[1],  
                "h2","visible",hv[2],  
                "h3","visible",hv[3],  
                "h4","visible",hv[4],  
                "h5","visible",hv[5],  
                "h1","state",0,hh[1],  
                "h2","state",0,hh[2],  
                "h3","state",0,hh[3],  
                "h4","state",0,hh[4],  
                "h5","state",0,hh[5],  
                "","name",name);  
  ranges=hv[1]+hv[2]+hv[3]+hv[4]+hv[5];  
  h=substr(name,1,1);  
  if (h==1)  
    setMultiValue("o"+h+"t","visible",(hh[h] && ranges>h),  
                  "ho"+h,"visible",(hh[h] && ranges>h));  
  else  
  if (h==5)  
    setMultiValue("u"+h+"t","visible",(hh[h]),  
                  "hu"+h,"visible",(hh[h]));  
  else  
    setMultiValue("u"+h+"t","visible",hh[h],  
                  "o"+h+"t","visible",(hh[h] && ranges>h),  
                  "hu"+h,"visible",hh[h],  
                  "ho"+h,"visible",(hh[h] && ranges>h));  
}  
  
paSaveBitAlertHdlAttributes(string OpenConfig,bool &all_right)  
{  
  int        nol=getNoOfLangs(),ok_ber,orig_beh,min_prio;
  bool       bActivate;
  string     alertClass;
  string     t1,t0,k1,panel,hilfe,
             dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL),sysname=dpSubStr(dpe,DPSUB_SYS);  
  dyn_string ds1,ds0,panel_param,ds_lt;  
  langString l1,l0,ls_lt;  
  
  getMultiValue("t1","text",t1,  
                "t0","text",t0,  
                "langliste1","items",ds1,  
                "langliste0","items",ds0,  
                "k1","text",k1,  
                "TB_Panel","text",panel,  
                "dyn_list","items",panel_param,  
                "RB_GutBer","number",ok_ber,  
                "CB_ori","selectedPos",orig_beh,  
                "min_prio","text",min_prio,
                "aktiv","state",0,bActivate);  
  k1=(strlen(k1)<5)?"":substr(k1,4,strlen(k1)-4);        
  if (nol<2)   
  {   
    getValue("hilfe","text",hilfe);   
    ds_lt[1]=hilfe;   
    l1=t1; l0=t0;  
  }   
  else   
  {   
    getValue("langtextliste","items",ds_lt);   
    l1=ds1; l0=ds0;  
  }   
  ls_lt=ds_lt;   
  
  alertClass = "";
  if (strlen(k1) > 0) alertClass = sysname + k1;
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_alert_hdl.._text1",l1,  
              dpe+":_alert_hdl.._text0",l0,  
              dpe+":_alert_hdl.._class",alertClass,  
              dpe+":_alert_hdl.._panel",panel,  
              dpe+":_alert_hdl.._help",ls_lt,  
              dpe+":_alert_hdl.._panel_param",panel_param,  
              dpe+":_alert_hdl.._ok_range",!ok_ber,  
              dpe+":_alert_hdl.._orig_hdl",orig_beh-1,  
              dpe+":_alert_hdl.._min_prio",min_prio),all_right);  

  dpSetWait(dpe+":_alert_hdl.._active",bActivate);
}  
  
paSaveSumAlertHdlAttributes(string OpenConfig,bool &all_right)  
{  
  int        i,p,l,q,r,nol=getNoOfLangs();  
  bool       ql,nq,kq,pq,bq,ok, bActivate;
  string     alertClass;
  string     k,dp,pr,ku,panel,hilfe,txt1,txt0,
             dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL),sysname=dpSubStr(dpe,DPSUB_SYS);  
  dyn_string t1,t0,ds,dx,param,ds_lt,
             sPara=makeDynString(paGetCatStr("para","nosumdps"));  
  langString l1,l0,ls_lt;  
  
  getMultiValue("langliste1","items",t1,  
                "langliste0","items",t0,  
                "t1","text",txt1,  
                "t0","text",txt0,  
                "k1","text",k,  
                "quitt_hat_prio","selectedPos",q,  
                "reihung","selectedPos",r,  
                "CB_Liste","state",0,l,  
                "LB_Eintraege","items",ds,  
                "dp_str","text",dp,  
                "prio_str","text",pr,  
                "kurzz_str","text",ku,  
                "qu_art","state",0,ql,  
                "qu_art","state",1,nq,  
                "qu_art","state",2,kq,  
                "qu_art","state",3,pq,  
                "qu_art","state",4,bq,  
                "TB_Panel","text",panel,  
                "dyn_list","items",param,
                "aktiv","state",0,bActivate);  
  k=(strlen(k)<5)?"":substr(k,4,strlen(k)-4);        
  if (l)  
    dp="";  
  else  
    ds=dx;  
  if (dp=="" && dynlen(ds)<1)  
  {  
    paChildPanelOn("vision/MessageWarning",  
                   paGetCatStr("para","warning"),  
                   "","",true,false,-1,-1,sPara,ok);  
    all_right=false;
    return;
  }
  if (nol<2)   
  {   
    getValue("hilfe","text",hilfe);   
    ds_lt[1]=hilfe;   
    l1=txt1; l0=txt0;  
  }   
  else   
  {   
    getValue("langtextliste","items",ds_lt);   
    l1=t1; l0=t0;  
  }   
  ls_lt=ds_lt;   

  alertClass = "";
  if (strlen(k) > 0) alertClass = sysname + k;
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":_alert_hdl.._text1",l1,  
              dpe+":_alert_hdl.._text0",l0,  
              dpe+":_alert_hdl.._class",alertClass,  
              dpe+":_alert_hdl.._ack_has_prio",q-1,  
              dpe+":_alert_hdl.._order",r-1,  
              dpe+":_alert_hdl.._dp_list",ds,  
              dpe+":_alert_hdl.._dp_pattern",dp,  
              dpe+":_alert_hdl.._prio_pattern",pr,  
              dpe+":_alert_hdl.._abbr_pattern",ku,  
              dpe+":_alert_hdl.._ack_deletes",ql,  
              dpe+":_alert_hdl.._non_ack",nq,  
              dpe+":_alert_hdl.._came_ack",kq,  
              dpe+":_alert_hdl.._pair_ack",pq,  
              dpe+":_alert_hdl.._both_ack",bq,  
              dpe+":_alert_hdl.._panel",panel,  
              dpe+":_alert_hdl.._panel_param",param,  
              dpe+":_alert_hdl.._help",ls_lt),all_right);  

    dpSetWait(dpe+":_alert_hdl.._active",bActivate);
}  
  
//////////////////////////////////////////////////////////////////////////////  
// 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);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for smooth  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetSmooth(string dpe,anytype &dpc)  
{  
  int    i,art,std_type,Id=paMyModuleId(),dpaType=dpElementType(dpe);  
  bool   old_new;  
  time   std_time,deriv_time,flut_time;  
  float  std_tol,deriv_tol1,deriv_tol2,deriv_limit;  
  string config=paGetDpConfig(globalOpenConfig[Id]);  
  
  dpc=globalAnytype;  
  dpGet(dpe+":"+config+".._type",art);  
  dpc[1]=dpaType;  
  dpc[2]=art;  
  switch (dpaType)  
  {  
    case DPEL_BOOL:  
    case DPEL_BOOL_STRUCT:  
      switch (art)  
      {  
        case DPCONFIG_NONE:  
          dpc[3]=-1;  
          break;  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          dpGet(dpe+":"+config+".._std_type",std_type,  
                dpe+":"+config+".._std_time",std_time);  
          dpc[3]=std_type;  
          dpc[4]=std_time;  
          break;  
        case DPCONFIG_SMOOTH_FLUTTER_MAIN:  
          dpGet(dpe+":"+config+".._flut_time",flut_time,  
                dpe+":"+config+".._old_new",old_new);  
          dpc[3]=flut_time;  
          dpc[4]=old_new;  
          break;  
      }  
      break;  
    case DPEL_CHAR: case DPEL_UINT: case DPEL_INT: case DPEL_FLOAT:  
    case DPEL_CHAR_STRUCT: case DPEL_UINT_STRUCT: case DPEL_INT_STRUCT: case DPEL_FLOAT_STRUCT:  
      switch (art)  
      {  
        case DPCONFIG_NONE:  
          dpc[3]=-1;  
          break;  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          dpGet(dpe+":"+config+".._std_type",std_type,  
                dpe+":"+config+".._std_tol",std_tol,  
                dpe+":"+config+".._std_time",std_time);  
          dpc[3]=std_type;  
          dpc[4]=std_tol;  
          dpc[5]=std_time;  
          break;  
        case DPCONFIG_SMOOTH_DERIV_MAIN:  
          dpGet(dpe+":"+config+".._deriv_tol1",deriv_tol1,  
                dpe+":"+config+".._deriv_tol2",deriv_tol2,  
                dpe+":"+config+".._deriv_limit",deriv_limit,  
                dpe+":"+config+".._deriv_time",deriv_time);  
          dpc[3]=deriv_tol1;  
          dpc[4]=deriv_tol2;  
          dpc[5]=deriv_limit;  
          dpc[6]=deriv_time;  
          break;  
      }  
      break;  
    default:  
      switch (art)  
      {  
        case DPCONFIG_NONE:  
          dpc[3]=-1;  
          break;  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          dpGet(dpe+":"+config+".._std_type",std_type,  
                dpe+":"+config+".._std_tol",std_tol,  
                dpe+":"+config+".._std_time",std_time);  
          dpc[3]=std_type;  
          dpc[4]=std_tol;  
          dpc[5]=std_time;  
          break;  
      }  
  }  
}  
  
paDpSetSmooth(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int    i,u,Id=paMyModuleId(),dpaType=dpElementType(dpe); 
  string config=paGetDpConfig(globalOpenConfig[Id]);  
  
  paErrorHandlingDpSet(  
    dpSetWait(dpe+":"+config+".._type",dpc[2]),all_right);  
  switch (dpc[1])  
  {  
    case DPEL_BOOL:  
    case DPEL_BOOL_STRUCT:  
      switch (dpc[2])  
      {  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":"+config+".._std_type",dpc[3],  
                      dpe+":"+config+".._std_time",dpc[4]),all_right);  
          break;  
        case DPCONFIG_SMOOTH_FLUTTER_MAIN:  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":"+config+".._flut_time",dpc[3],  
                      dpe+":"+config+".._old_new",dpc[4]),all_right);  
          break;  
      }  
      break;  
    case DPEL_CHAR: case DPEL_UINT: case DPEL_INT: case DPEL_FLOAT:  
    case DPEL_CHAR_STRUCT: case DPEL_UINT_STRUCT: case DPEL_INT_STRUCT: case DPEL_FLOAT_STRUCT:  
      switch (dpc[2])  
      {  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          paCheckValue(dpaType,dpc[4],true,u);  
          {  
            if (u<0) {all_right=false; return;}  
          }  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":"+config+".._std_type",dpc[3],  
                      dpe+":"+config+".._std_tol",dpc[4],  
                      dpe+":"+config+".._std_time",dpc[5]),all_right);  
          break;  
        case DPCONFIG_SMOOTH_DERIV_MAIN:  
          paCheckValue(dpaType,dpc[3],true,u);  
          {  
            if (u<0) {all_right=false; return;}  
          }  
          paCheckValue(dpaType,dpc[4],true,u);  
          {  
            if (u<0) {all_right=false; return;}  
          }  
          paCheckValue(dpaType,dpc[5],true,u);  
          {  
            if (u<0) {all_right=false; return;}  
          }  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":"+config+".._deriv_tol1",dpc[3],  
                      dpe+":"+config+".._deriv_tol2",dpc[4],  
                      dpe+":"+config+".._deriv_limit",dpc[5],  
                      dpe+":"+config+".._deriv_time",dpc[6]),all_right);  
          break;  
      }  
      break;  
    default:  
      switch (dpc[2])  
      {  
        case DPCONFIG_NONE:  
          break;  
        case DPCONFIG_SMOOTH_SIMPLE_MAIN:  
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":"+config+".._std_type",dpc[3],  
                      dpe+":"+config+".._std_tol",dpc[4],  
                      dpe+":"+config+".._std_time",dpc[5]),all_right);  
          break;  
      }  
  }  
}          
  
paDpCopySmooth(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllSmoothAttributes(string dpe, dyn_anytype dpc)  
{  
  int        number,dpaType=dpElementType(dpe), Id=paMyModuleId(),
             art,sec,ms;  
  bool       bFixed;
  string     form,unit, config = paGetDpConfig(globalOpenConfig[Id]);
  dyn_string ds;  
  dyn_string dsDps = dpNames("_mp_*",dpTypeName(dpe));
  
  daIsPcFixed( dpe+":"+config, bFixed);
  setMultiValue("art", "enabled", (bFixed || dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling),
                "tol_typ", "enabled", (bFixed || dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling),
//!!!                "old_new", "enabled", (bFixed || dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling));
                "old_new", "enabled", (bFixed || dpc[1] == DPEL_BOOL || dpc[1] == DPEL_BOOL_STRUCT ||
                                       dynlen(dsDps) < 1 || isMotif() || gMpCustomHandling));

  paSetUnit(dpe,unit);  
  dpValueFieldFormat(dpe,form);  
  setMultiValue("unit0","text",unit,  
                "unit1","text",unit,  
                "unit2","text",unit,  
                "unit3","text",unit,  
                "sec","text",0,  
                "ms","text",0,  
                "tol","text",0,  
                "tol1","text",0,  
                "tol2","text",0,  
                "limit","text",0);  
  art=dpc[2];  
  switch (dpc[1])  
  {  
    case DPEL_BOOL:  
    case DPEL_BOOL_STRUCT:  
      ds=makeDynString(paGetCatStr("para","no_smooth"),  
                       paGetCatStr("para","tol1"),  
                       paGetCatStr("para","flut"));  
      number=dpc[3];  
      if (art==DPCONFIG_SMOOTH_SIMPLE_MAIN) art=1;  
      if (art==DPCONFIG_SMOOTH_FLUTTER_MAIN) art=2;  
      if (number>0) number-=3; else number-=1;  
      setMultiValue("dpaType","text",dpc[1],  
                    "art","items",ds,  
                    "art","selectedPos",art+1,  
                    "border1","visible",false,  
                    "border2","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                         (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "border3","visible",false,  
                    "border4","visible",(art>0),  
                    "tol_typ_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "tol_typ_bit","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "pb_interval","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                          (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                           (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "time_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                          (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                           (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "sec_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                         (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "ms_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                        (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                         (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "sec","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                     (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                      (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                       dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                       dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "ms","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN ||  
                                    (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "tol_typ","visible",false,  
                    "tol_txt","visible",false,  
                    "tol1_txt","visible",false,  
                    "tol2_txt","visible",false,  
                    "tol3_txt","visible",false,  
                    "limit_txt","visible",false,  
                    "unit0","visible",false,  
                    "unit1","visible",false,  
                    "unit2","visible",false,  
                    "unit3","visible",false,  
                    "unitrel","visible",false,  
                    "rel","visible",false,  
                    "tol","visible",false,  
                    "tol1","visible",false,  
                    "tol2","visible",false,  
                    "limit","visible",false,  
                    "old_new","visible",(dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN));  
  
      if (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN)  
      {  
        sec=period(dpc[4]);  
        ms=milliSecond(dpc[4]);  
        setMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol_typ_bit","number",number);  
      }  
      else  
      if (dpc[2]==DPCONFIG_SMOOTH_FLUTTER_MAIN)  
      {  
        sec=period(dpc[3]);  
        ms=milliSecond(dpc[3]);  
        setMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "old_new","state",0,dpc[4]);  
      }  
      break;  
  
    case DPEL_CHAR: case DPEL_UINT: case DPEL_INT: case DPEL_FLOAT:  
    case DPEL_CHAR_STRUCT: case DPEL_UINT_STRUCT: case DPEL_INT_STRUCT: case DPEL_FLOAT_STRUCT:  
      ds=makeDynString(paGetCatStr("para","no_smooth"),  
                       paGetCatStr("para","tol2"),  
                       paGetCatStr("para","deriv"));  
      number=dpc[3];  
      if (art==DPCONFIG_SMOOTH_SIMPLE_MAIN) art=1;  
      if (art==DPCONFIG_SMOOTH_DERIV_MAIN) art=2;  

      setMultiValue("tol","format",form,  
                    "tol1","format",form,  
                    "tol2","format",form,  
                    "limit","format",form);

      setMultiValue("dpaType","text",dpc[1],  
                    "art","items",ds,  
                    "art","selectedPos",art+1,  
                    "border1","visible",(art>0),  
                    "border2","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                         (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                           dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "border3","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||
                                      dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                    "border4","visible",false,  
                    "tol_typ_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "tol_typ","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "tol_typ_bit","visible",false,  
                    "pb_interval","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                          (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                           (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                            dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "time_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                          (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                           (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                            dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                            dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "sec_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                         (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                           dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "ms_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                        (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                         (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                          dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "sec","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                     (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                      (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                       dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                       dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                       dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                       dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "ms","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN ||  
                                    (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH))),  
                    "tol_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||
                                      dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                    "tol","format",form,  
                    "unit0","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                       (dpc[3]==DPATTR_VALUE_SMOOTH ||  
                                        dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                        dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH)),  
                    "unitrel","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                         (dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                          dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                          dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                    "rel","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||
                                      dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                    "rel","state",0,(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                    "unit1","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "unit2","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "unit3","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "tol","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_SMOOTH ||
                                      dpc[3]==DPATTR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                      dpc[3]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
  
                    "tol1_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "tol2_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "tol3_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "limit_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "tol1","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "tol2","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "limit","visible",(dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN),  
                    "old_new","visible",false);  
  
      if (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN)  
      {  
        bool rel = (number >= DPATTR_VALUE_REL_SMOOTH);
        
        if ( rel )
        {
          if ( number == DPATTR_VALUE_REL_SMOOTH ) number = DPATTR_VALUE_SMOOTH;
          else
          if ( number == DPATTR_TIME_AND_VALUE_REL_SMOOTH ) number = DPATTR_TIME_AND_VALUE_SMOOTH;
          else
          if ( number == DPATTR_TIME_OR_VALUE_REL_SMOOTH ) number = DPATTR_TIME_OR_VALUE_SMOOTH;
        }
        sec=period(dpc[5]);  
        ms=milliSecond(dpc[5]);  
        setMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol","text",dpc[4],  
                      "tol_typ","number",number,  
                      "rel","state",0,rel);  
      }  
      else  
      if (dpc[2]==DPCONFIG_SMOOTH_DERIV_MAIN)  
      {  
        sec=period(dpc[6]);  
        ms=milliSecond(dpc[6]);  
        setMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol1","text",dpc[3],  
                      "tol2","text",dpc[4],  
                      "limit","text",dpc[5]);  
      }  
      break;  
    default:  
      ds=makeDynString(paGetCatStr("para","no_smooth"),  
                       paGetCatStr("para","tol1"));  
      number=dpc[3];  
      if (art==DPCONFIG_SMOOTH_SIMPLE_MAIN) art=1;  
      if (number>0) number-=3; else number-=1;  
      setMultiValue("dpaType","text",dpc[1],  
                    "art","items",ds,  
                    "art","selectedPos",art+1,  
                    "border1","visible",false,  
                    "border2","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                         (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "border3","visible",false,  
                    "border4","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "tol_typ_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "tol_typ_bit","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN),  
                    "pb_interval","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "time_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                          (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                           dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "sec_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                         (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                          dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "ms_txt","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                        (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                         dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                         dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "sec","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                     (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                      dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "ms","visible",(dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN &&  
                                    (dpc[3]==DPATTR_TIME_SMOOTH ||  
                                     dpc[3]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                                     dpc[3]==DPATTR_OLD_NEW_OR_TIME_SMOOTH)),  
                    "tol_typ","visible",false,  
                    "tol_txt","visible",false,  
                    "tol1_txt","visible",false,  
                    "tol2_txt","visible",false,  
                    "tol3_txt","visible",false,  
                    "limit_txt","visible",false,  
                    "unit0","visible",false,  
                    "unit1","visible",false,  
                    "unit2","visible",false,  
                    "unit3","visible",false,  
                    "unitrel","visible",false,  
                    "rel","visible",false,  
                    "tol","visible",false,  
                    "tol1","visible",false,  
                    "tol2","visible",false,  
                    "limit","visible",false,  
                    "old_new","visible",false);  
  
      if (dpc[2]==DPCONFIG_SMOOTH_SIMPLE_MAIN)  
      {  
        sec=period(dpc[5]);  
        ms=milliSecond(dpc[5]);  
        setMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol_typ_bit","number",number);  
      }  
      break;  
  }  
}  
  
bool paReadPanelAllSmoothAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        number,dpaType=dpElementType(dpe),  
             art,sec,ms;  
  bool       old_new, rel;  
  time       t;  
  float      tol,tol1,tol2,limit;  
  
  dpc=globalAnytype;  
  dpc[1]=dpaType;  
  getValue("art","selectedPos",art); art--;  
  switch (dpaType)  
  {  
    case DPEL_BOOL:  
    case DPEL_BOOL_STRUCT:  
      if (art==1)  
      {  
        dpc[2]=DPCONFIG_SMOOTH_SIMPLE_MAIN;  
        getMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol_typ_bit","number",number);  
        if (number>0) number+=3; else number++;  
        dpc[3]=number;  
        setPeriod(t,sec,ms);  
        dpc[4]=t;  
      }  
      else  
      if (art==2)  
      {  
        dpc[2]=DPCONFIG_SMOOTH_FLUTTER_MAIN;  
        getMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "old_new","state",0,old_new);  
        setPeriod(t,sec,ms);  
        dpc[3]=t;  
        dpc[4]=old_new;  
      }  
      else  
      {  
        dpc[2]=art;  
      }  
      break;  
    case DPEL_CHAR: case DPEL_UINT: case DPEL_INT: case DPEL_FLOAT:  
    case DPEL_CHAR_STRUCT: case DPEL_UINT_STRUCT: case DPEL_INT_STRUCT: case DPEL_FLOAT_STRUCT:  
      if (art==1)  
      {  
        dpc[2]=DPCONFIG_SMOOTH_SIMPLE_MAIN;  
        getMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol_typ","number",number,  
                      "tol","text",tol,
                      "rel","state",0,rel);  
        dpc[3]=number;
        if ( rel )
        {
          if ( dpc[3] == DPATTR_VALUE_SMOOTH ) dpc[3] = DPATTR_VALUE_REL_SMOOTH;
          else
          if ( dpc[3] == DPATTR_TIME_AND_VALUE_SMOOTH ) dpc[3] = DPATTR_TIME_AND_VALUE_REL_SMOOTH;
          else
          if ( dpc[3] == DPATTR_TIME_OR_VALUE_SMOOTH ) dpc[3] = DPATTR_TIME_OR_VALUE_REL_SMOOTH;
        }
        dpc[4]=tol;  
        setPeriod(t,sec,ms);  
        dpc[5]=t;  
      }  
      else  
      if (art==2)  
      {  
        dpc[2]=DPCONFIG_SMOOTH_DERIV_MAIN;  
        getMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol1","text",tol1,  
                      "tol2","text",tol2,  
                      "limit","text",limit);  
        setPeriod(t,sec,ms);  
        dpc[3]=tol1;  
        dpc[4]=tol2;  
        dpc[5]=limit;  
        dpc[6]=t;  
      }  
      else  
      {  
        dpc[2]=art;  
      }  
      break;  
    default:  
      if (art==1)  
      {  
        dpc[2]=DPCONFIG_SMOOTH_SIMPLE_MAIN;  
        getMultiValue("sec","text",sec,  
                      "ms","text",ms,  
                      "tol_typ_bit","number",number,  
                      "tol","text",tol,
                      "rel","state",0,rel);  
        if (number>0) number+=3; else number++;  
        dpc[3]=number;
        if ( rel )
        {
          if ( dpc[3] == DPATTR_VALUE_SMOOTH ) dpc[3] = DPATTR_VALUE_REL_SMOOTH;
          else
          if ( dpc[3] == DPATTR_TIME_AND_VALUE_SMOOTH ) dpc[3] = DPATTR_TIME_AND_VALUE_REL_SMOOTH;
          else
          if ( dpc[3] == DPATTR_TIME_OR_VALUE_SMOOTH ) dpc[3] = DPATTR_TIME_OR_VALUE_REL_SMOOTH;
        }
        dpc[4]=tol;  
        setPeriod(t,sec,ms);  
        dpc[5]=t;  
      }  
      else  
      {  
        dpc[2]=art;  
      }  
      break;  
  }  
}  
  
paSaveAllSmoothAttributes(string OpenConfig,bool &allright)  
{  
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllSmoothAttributes(dpe,dpc);  
  paDpSetSmooth(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for archive  
//////////////////////////////////////////////////////////////////////////////  
  
paDpGetArch(string dpe,anytype &dpc)  
{  
  int         i,archive,type,std_type,Id=paMyModuleId(),num_proc,  
              dpaType=dpElementType(dpe);  
  time        std_time;  
  float       std_tol;  
  string      config=paGetDpConfig(globalOpenConfig[Id]),class;  
  
  dpc=globalAnytype;  
  dpGet(dpe+":"+config+".._archive",archive,  
        dpe+":"+config+".._num_proc",num_proc);  
  if (num_proc>0)  
    dpGet(dpe+":"+config+".1._type",type);  
  else  
    type=DPATTR_ARCH_PROC_NONE;  
  dpc[1]=dpaType;  
  dpc[2]=archive;  
  dpc[3]=type; 
  dpc[7]=""; 
  if (type==DPATTR_ARCH_PROC_NONE || type == DPATTR_ARCH_PROC_VALARCH )  
  {  
    dpc[4]=DPCONFIG_NONE;  
  }  
  else if ( type==DPATTR_ARCH_PROC_VALARCH)
     dpc[4]=DPCONFIG_NONE;  
  else 
  {  
    dpGet(dpe+":"+config+".1._class",class,  
          dpe+":"+config+".1._std_type",std_type,  
          dpe+":"+config+".1._std_time",std_time,  
          dpe+":"+config+".1._std_tol",std_tol);  
    dpc[4]=std_type;  
    dpc[5]=std_time;  
    if (dpaType==DPEL_CHAR || dpaType==DPEL_UINT || dpaType==DPEL_INT || dpaType==DPEL_FLOAT ||  
        dpaType==DPEL_CHAR_STRUCT || dpaType==DPEL_UINT_STRUCT ||
        dpaType==DPEL_INT_STRUCT || dpaType==DPEL_FLOAT_STRUCT)  
      dpc[6]=std_tol;
    dpc[7]=class;  
  }  
}  
  
paDpSetArch(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int    i,u,Id=paMyModuleId(),dpaType=dpElementType(dpe);
  string config=paGetDpConfig(globalOpenConfig[Id]);  
  
  if (dpc[3]==DPATTR_ARCH_PROC_NONE)  
  {  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":"+config+".._archive",dpc[2],  
                dpe+":"+config+".1._type",dpc[3]),all_right);  
  }  
  else if ( dpc[3]== DPATTR_ARCH_PROC_VALARCH )
  {

    paErrorHandlingDpSet(  
      dpSetWait(dpe+":"+config+".._archive",dpc[2],  
                dpe+":"+config+".1._type",dpc[3],
                dpe+":"+config+".1._class",dpc[7]),all_right);  
  }
  else
  if (dpc[1]==DPEL_CHAR || dpc[1]==DPEL_UINT || dpc[1]==DPEL_INT || dpc[1]==DPEL_FLOAT ||  
      dpc[1]==DPEL_CHAR_STRUCT || dpc[1]==DPEL_UINT_STRUCT ||
      dpc[1]==DPEL_INT_STRUCT || dpc[1]==DPEL_FLOAT_STRUCT)  
  {  
    paCheckValue(dpaType,dpc[6],true,u);  
    {  
      if (u<0) {all_right=false; return;};  
    }  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":"+config+".._archive",dpc[2],  
                dpe+":"+config+".1._class",dpc[7],  
                dpe+":"+config+".1._proc",dpc[3],  
                dpe+":"+config+".1._type",dpc[3],  
                dpe+":"+config+".1._std_type",dpc[4],  
                dpe+":"+config+".1._std_time",dpc[5],  
                dpe+":"+config+".1._std_tol",dpc[6]),all_right);  
  }  
  else  
    paErrorHandlingDpSet(  
      dpSetWait(dpe+":"+config+".._archive",dpc[2],  
                dpe+":"+config+".1._class",dpc[7],  
                dpe+":"+config+".1._proc",dpc[3],  
                dpe+":"+config+".1._type",dpc[3],  
                dpe+":"+config+".1._std_type",dpc[4],  
                dpe+":"+config+".1._std_time",dpc[5]),all_right);  
}          
  
paDpCopyArch(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllArchAttributes(string dpe, dyn_anytype dpc)  
{  
  int        number,dpaType=dpElementType(dpe),  
             sec,ms;  
  bool       time_visible,tol_visible, bFixed, rel;  
  string     form,unit;  
  dyn_string ds;  
  
  daIsPcFixed( dpe+":_archive", bFixed);
  paSetUnit(dpe,unit);  
  dpValueFieldFormat(dpe,form);  
  setMultiValue("glaett","state",0,(dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH),  
                "dpaType","text",dpc[1],  
                "arch","state",0,dpc[2],
                "arch","enabled",!(dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH),
                "glaett","visible",(dpc[2] && (bFixed || strpos(dpSubStr(dpe,DPSUB_DP),"_mp_")!=0)) );  
  number=dpc[4];  
  rel = (number >= DPATTR_VALUE_REL_SMOOTH);
  if ( rel )
  {
    if ( number == DPATTR_VALUE_REL_SMOOTH ) number = DPATTR_VALUE_SMOOTH;
    else
    if ( number == DPATTR_TIME_AND_VALUE_REL_SMOOTH ) number = DPATTR_TIME_AND_VALUE_SMOOTH;
    else
    if ( number == DPATTR_TIME_OR_VALUE_REL_SMOOTH ) number = DPATTR_TIME_OR_VALUE_SMOOTH;
  }

  if (dpc[1]==DPEL_CHAR || dpc[1]==DPEL_UINT || dpc[1]==DPEL_INT || dpc[1]==DPEL_FLOAT ||  
      dpc[1]==DPEL_CHAR_STRUCT || dpc[1]==DPEL_UINT_STRUCT ||
      dpc[1]==DPEL_INT_STRUCT || dpc[1]==DPEL_FLOAT_STRUCT)  
  {  
    time_visible=((dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH)&&  
                  (dpc[4]==DPATTR_TIME_SMOOTH ||  
                   dpc[4]==DPATTR_TIME_AND_VALUE_SMOOTH ||  
                   dpc[4]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                   dpc[4]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                   dpc[4]==DPATTR_OLD_NEW_OR_TIME_SMOOTH));  
    tol_visible=((dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH)&&  
                 (dpc[4]==DPATTR_VALUE_SMOOTH ||  
                  dpc[4]==DPATTR_VALUE_REL_SMOOTH ||  
                  dpc[4]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                  dpc[4]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                  dpc[4]==DPATTR_TIME_AND_VALUE_SMOOTH || 
                  dpc[4]==DPATTR_TIME_AND_VALUE_REL_SMOOTH));  
    setValue("tol","format",form);
    setMultiValue("border1","visible",(dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH),  
                  "border2","visible",time_visible,  
                  "border3","visible",tol_visible,  
                  "border4","visible",false,  
                  "tol_typ","visible",(dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH),  
                  "tol_typ_bit","visible",false,  
                  "pb_interval","visible",time_visible,  
                  "time_txt","visible",time_visible,  
                  "sec_txt","visible",time_visible,  
                  "ms_txt","visible",time_visible,  
                  "sec","visible",time_visible,  
                  "ms","visible",time_visible,  
                  "tol_txt","visible",tol_visible,  
                  "tol","visible",tol_visible,  
                  "unit","text",unit,  
                  "unit","visible",(tol_visible &&
                                    (dpc[4]==DPATTR_VALUE_SMOOTH ||  
                                     dpc[4]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                     dpc[4]==DPATTR_TIME_AND_VALUE_SMOOTH)),  
                  "unitrel","visible",(tol_visible &&
                                       (dpc[4]==DPATTR_VALUE_REL_SMOOTH ||  
                                        dpc[4]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                        dpc[4]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                  "rel","visible",(tol_visible &&
                                   (dpc[4]==DPATTR_VALUE_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_OR_VALUE_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_AND_VALUE_SMOOTH ||
                                    dpc[4]==DPATTR_VALUE_REL_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),
                  "rel","state",0,(tol_visible &&
                                   (dpc[4]==DPATTR_VALUE_REL_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_OR_VALUE_REL_SMOOTH ||  
                                    dpc[4]==DPATTR_TIME_AND_VALUE_REL_SMOOTH)),  
                  "tol_typ","number",number);  
  
    if (dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] != DPATTR_ARCH_PROC_VALARCH)  
    {  
      sec=period(dpc[5]);  
      ms=milliSecond(dpc[5]);  
      setMultiValue("sec","text",sec,  
                    "ms","text",ms,  
                    "tol","text",dpc[6]);  
    }  
  }  
  else  
  {  
    if (number>0) number-=3; else number-=1;  
    time_visible=((dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] !=DPATTR_ARCH_PROC_VALARCH) &&
                  (dpc[4]==DPATTR_TIME_SMOOTH ||  
                   dpc[4]==DPATTR_OLD_NEW_AND_TIME_SMOOTH ||  
                   dpc[4]==DPATTR_OLD_NEW_OR_TIME_SMOOTH));  
    setMultiValue("border1","visible",false,  
                  "border2","visible",time_visible,  
                  "border3","visible",false,  
                  "border4","visible",(dpc[3]!=DPATTR_ARCH_PROC_NONE&& dpc[3] !=DPATTR_ARCH_PROC_VALARCH),  
                  "tol_typ_bit","visible",(dpc[3]!=DPATTR_ARCH_PROC_NONE&& dpc[3] !=DPATTR_ARCH_PROC_VALARCH),  
                  "pb_interval","visible",time_visible,  
                  "time_txt","visible",time_visible,  
                  "sec_txt","visible",time_visible,  
                  "ms_txt","visible",time_visible,  
                  "sec","visible",time_visible,  
                  "ms","visible",time_visible,  
                  "tol_typ","visible",false,  
                  "tol_txt","visible",false,  
                  "tol","visible",false,  
                  "tol_typ_bit","number",number);  
  
    if (dpc[3]!=DPATTR_ARCH_PROC_NONE && dpc[3] != DPATTR_ARCH_PROC_VALARCH)  
    {  
      sec=period(dpc[5]);  
      ms=milliSecond(dpc[5]);  
      setMultiValue("sec","text",sec,  
                    "ms","text",ms);  
    }  
  }  
}  
  
bool paReadPanelAllArchAttributes(string dpe, dyn_anytype &dpc)  
{  
  int        number,dpaType=dpElementType(dpe),  
             sec,ms,std_type,type;  
  bool       old_new,archive,bNewDB, rel;  
  time       t;  
  float      tol,tol1,tol2,limit;  
  string     class;
  
  dpc=globalAnytype;  
  getMultiValue("archiveClassDp","text",class,  
                "arch","state",0,archive,  
                "glaett","state",0,type);  
  dpGet("_DataManager.UseValueArchive:_online.._value",bNewDB);
  if (bNewDB)
  {
    dpc[7]=class;
  }
  else
    dpc[7]="";

  if (type>0 && type != DPATTR_ARCH_PROC_VALARCH)  
    type=DPATTR_ARCH_PROC_SIMPLESM;  
  else  
    if (bNewDB)     // Sonderfall Glättung nicht aktiv und neue Glättung
      type = DPATTR_ARCH_PROC_VALARCH;
    else
      type = DPATTR_ARCH_PROC_NONE;  
  dpc[1]=dpaType;  
  dpc[2]=archive;  
  dpc[3]=type;  
  if (dpc[1]==DPEL_CHAR || dpc[1]==DPEL_UINT || dpc[1]==DPEL_INT || dpc[1]==DPEL_FLOAT ||  
      dpc[1]==DPEL_CHAR_STRUCT || dpc[1]==DPEL_UINT_STRUCT ||
      dpc[1]==DPEL_INT_STRUCT || dpc[1]==DPEL_FLOAT_STRUCT)  
  {  
    if (type!=DPATTR_ARCH_PROC_NONE && type!=DPATTR_ARCH_PROC_VALARCH)  
    {  
      getMultiValue("sec","text",sec,  
                    "ms","text",ms,  
                    "tol_typ","number",number,  
                    "tol","text",tol,
                    "rel","state",0,rel);  

      dpc[4]=number;
      if ( rel )
      {
        if ( dpc[4] == DPATTR_VALUE_SMOOTH ) dpc[4] = DPATTR_VALUE_REL_SMOOTH;
        else
        if ( dpc[4] == DPATTR_TIME_AND_VALUE_SMOOTH ) dpc[4] = DPATTR_TIME_AND_VALUE_REL_SMOOTH;
        else
        if ( dpc[4] == DPATTR_TIME_OR_VALUE_SMOOTH ) dpc[4] = DPATTR_TIME_OR_VALUE_REL_SMOOTH;
      }
      setPeriod(t,sec,ms);  
      dpc[5]=t;  
      dpc[6]=tol;  
    }  
  }  
  else  
  {  
    if (type!=DPATTR_ARCH_PROC_NONE && type!=DPATTR_ARCH_PROC_VALARCH)  
    {  
      getMultiValue("sec","text",sec,  
                    "ms","text",ms,  
                    "tol_typ_bit","number",number);  
      if (number>0) number+=3; else number++;  
      dpc[4]=number;  
      setPeriod(t,sec,ms);  
      dpc[5]=t;  
    }  
  }  
}  
  
paSaveAllArchAttributes(string OpenConfig,bool &allright)  
{
  bool        bNewDB;
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);  
  dyn_anytype dpc;  
  
  paReadPanelAllArchAttributes(dpe,dpc);  
  dpGet("_DataManager.UseValueArchive:_online.._value",bNewDB);
  if (bNewDB && dpc[7] == "")
  {
    ChildPanelOnCentralModal("vision/MessageWarning",
      getCatStr("para","warning"),
      makeDynString(getCatStr("ac", "noarchive")));
    allright = false;
    return;
  }
  paDpSetArch(dpe,dpc,allright);  
  paPutGlobalDpc(OpenConfig,dpc);  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for address  
//////////////////////////////////////////////////////////////////////////////  
// The global variables globalAddressNew, globalAddressOld,  
// globalAddressTypes, globalAddressDrives, globalUserDefinedDrivers 
// will be defined in address.pnl (panel attribute-Meldescript)  
// and in para.pnl (events),  
// they will be deleted in paDeleteGlobals.  
// Values of globalAddressTypes:  type marks ("pfm","pdp","ssi",...)  
// Values of globalAddressDrives: drv_ident  ("PRFMS","PRDP","SSI",...)  
//////////////////////////////////////////////////////////////////////////////  

//////////////////////////////////////////////////////////////////////////////
// How to define an own driver?
//==============================
//  
// Used terms:
// types:   for creating panel name and for selecting in the case-statements
// drivers: for seting _address.._drv_ident
// names:   texts for diplaying in the combobox in address.pnl to select a driver type
//
// If you want to install a new driver:
//
// 1. In scripts/userDrivers.ctl
//    add new item to types, drivers and names respectively
//
// 2. New panel(s) in panels/para
//    copy and change address_skeleton.pnl to create a new para-panel for
//    a new driver.
//
//    IMPORTANT: The name of the new panel must be address_newdrv.pnl,
//               where newdrv is the type of the new driver (see 1.)
//               (in our example address_tstdrv1.pnl)
//
//    NOTE: don't change the script in the panel-attributes and the buttons!
//
// 3. In scripts/userPara.ctl
//    add new case selection (in our example case "tstdrv1":)
//    into the next four functions:
//      upDpGetAddress
//      upDpSetAddress
//      upWritePanelAllAddressAttributes
//      upReadPanelAllAddressAttributes
//    and write the appropriate commands
//
// Notice:
//    global variable used for the _address.. -attributes is
//      anytype dpc;
//        dpc[1]=reference;  
//        dpc[2]=subindex;  
//        dpc[3]=mode;  
//        dpc[4]=start;  
//        dpc[5]=interval;  
//        dpc[6]=reply;  
//        dpc[7]=datatype;  
//        dpc[8]=drv_ident;  
//        dpc[9]=driver; 
//    use only the necessary ones, you don't have to set all of them!
//////////////////////////////////////////////////////////////////////////////  
// paGetAddressTypes(dyn_string &types,dyn_string &drivers)   moved -> da.ctl TI 17025 
// paGetAddressNames(dyn_string &names)                       moved -> da.ctl TI 17025 
// paSetUnit(string dpe,string &unit)                         moved -> da.ctl 
// string paDpGetFormat(string dpe)                           moved -> da.ctl
// string paCheckFormat(string dpe,string format)             moved -> da.ctl
//---------------------------------------------------------------------------  
string upGetScriptName(string drvName)
{
  int    i;
  string sScript="";
 
  for (i=1;i<=dynlen(globalUserDefinedDrivers);i++)
  {
    if (dynContains(globalUserDefinedDrivers[i],drvName)>0)
    {
      if (!fileToString(getPath(SCRIPTS_REL_PATH,"userPara.ctl",0,i),sScript))
      {
        sScript="";
      }
      break;
    }
  }
  return (sScript);
} 
//////////////////////////////////////////////////////////////////////////////  

paDpGetAddress(string dpe,anytype &dpc)  
{  
  int         Id=paMyModuleId(),datatype,driver,i,distrib_type;
  bool        all_right=true,active;  
  char        mode;  
  time        start,interval,reply;  
  string      drv_ident,reference,config=paGetDpConfig(globalOpenConfig[Id]),  
              dpn=dpSubStr(dpe,DPSUB_DP)+".",tel_nr,ser_nr,sScript;  
  unsigned    subindex,offset;  
  
  if (globalAddressOld[Id]!="")  
  {  
    dpGet(dpe+":_distrib.._type",distrib_type);  
    if (distrib_type!=DPCONFIG_DISTRIBUTION_INFO)  
      paErrorHandlingDpSet(  
      dpSetWait(dpe+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO),all_right);  
  }  
  
  dpc=globalAnytype;  
  switch (globalAddressOld[Id])  
  {  
    case "":  
        dpGet(dpe+":"+config+".._drv_ident",drv_ident);  
        dpc[8]=drv_ident;  
      break;  
    case "pfm": case "pdp": case "rk5":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._start",start,  
              dpe+":"+config+".._interval",interval,  
              dpe+":"+config+".._reply",reply,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[4]=start;  
        dpc[5]=interval;  
        dpc[6]=reply;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "ssi":  
    case "iec":
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "sim":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._reply",reply,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[6]=reply;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "abb":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[3]=mode;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "seb":  
      dpGet(dpe+":_logger.._type",i);  
      if (i!=57)  
        paErrorHandlingDpSet(  
        dpSetWait(dpe+":_logger.._type",57),all_right);  
      dpGet(dpe+":"+config+".._active",active,  
            dpe+":"+config+".._reference",reference,  
            dpe+":"+config+".._mode",mode,  
            dpe+":"+config+".._start",start,  
            dpe+":"+config+".._interval",interval,  
            dpe+":"+config+".._reply",reply,  
            dpe+":"+config+".._drv_ident",drv_ident,  
            dpe+":_distrib.._driver",driver,  
            dpe+":_logger.._tel_nr",tel_nr,  
            dpe+":_logger.._ser_nr",ser_nr);  
      dpc[1]=reference;  
      dpc[3]=mode;  
      dpc[4]=start;  
      dpc[5]=interval;  
      dpc[6]=reply;  
      dpc[8]=drv_ident;  
      if (driver<1) driver=1;  
      dpc[9]=driver;  
      dpc[10]=tel_nr;  
      dpc[11]=ser_nr;  
      dpc[12]=active;  
      break;  
    case "ads":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._drv_ident",drv_ident);  
        dpc[8]=drv_ident;  
        dpc[12]=active;  
      break;  
    case "mue":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "opc":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);
        if (strpos(reference,"$")<0) reference="$$"; 
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "abb_arc":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,  
              dpe+":"+config+".._subindex",subindex,  
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference;  
        dpc[2]=subindex;  
        dpc[3]=mode;  
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "modbus":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,
              dpe+":"+config+".._subindex",subindex,
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._start",start,  
              dpe+":"+config+".._interval",interval,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        if ( strrtrim(strltrim(reference)) == "" ||
             strrtrim(strltrim(reference)) == "0"  )
          reference = "M.0.5.0";
        dpc[1]=reference; 
        dpc[2]=subindex;
        dpc[3]=mode;  
        dpc[4]=start;
        i = interval;  
        dpc[5]=i * 1000 + milliSecond(interval);
        if ( dpc[5] > 0 && dpc[5] < 100) dpc[5] = 100;
        if ( dpc[5] > 864000000) dpc[5] = 864000000;
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "apc":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,
              dpe+":"+config+".._subindex",subindex,
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._start",start,  
              dpe+":"+config+".._interval",interval,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        if ( strrtrim(strltrim(reference)) == "" )
          reference = ".";
        dpc[1]=reference; 
        dpc[2]=subindex;
        dpc[3]=mode;  
        dpc[4]=start;
        i = interval;  
        dpc[5]=i * 1000 + milliSecond(interval);
        if ( dpc[5] > 0 && dpc[5] < 100) dpc[5] = 100;
        if ( dpc[5] > 864000000) dpc[5] = 864000000;
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    case "tls":  
        dpGet(dpe+":"+config+".._active",active,  
              dpe+":"+config+".._reference",reference,
              dpe+":"+config+".._subindex",subindex,
              dpe+":"+config+".._mode",mode,  
              dpe+":"+config+".._start",start,  
              dpe+":"+config+".._interval",interval,  
              dpe+":"+config+".._datatype",datatype,  
              dpe+":"+config+".._drv_ident",drv_ident,  
              dpe+":_distrib.._driver",driver);  
        dpc[1]=reference; 
        dpc[2]=subindex;
        dpc[3]=mode;  
        dpc[4]=start;
        i = interval;  
        dpc[5]=i * 1000 + milliSecond(interval); if ( dpc[5] < 100) dpc[5] = 100;
        dpc[7]=datatype;  
        dpc[8]=drv_ident;  
        if (driver<1) driver=1;  
        dpc[9]=driver;  
        dpc[12]=active;  
      break;  
    default:
      sScript=upGetScriptName(globalAddressOld[Id]);
      if (sScript!="")
        evalScript(dpc, sScript, makeDynString(), dpe, Id, dpc, 1);
      break;  
  }  
}  
 
paDpSetAddress(string dpe, dyn_anytype dpc, bool &all_right)  
{  
  int        Id=paMyModuleId(); 
  bool       ok;
  string     config=paGetDpConfig(globalOpenConfig[Id]),dpn=dpSubStr(dpe,DPSUB_DP)+".",sScript;  
  dyn_int    drivers, drivers_2; 
  dyn_string sPara;
  time iv;
  int tempDriver, iError;
  
/*
  if (globalAddressOld[Id]!="")
  {
    dpGet("_Connections.Driver.ManNums:_online.._value",drivers);//,
//          "_Connections_2.Driver.ManNums:_online.._value",drivers_2);
    if (!dynContains(drivers,dpc[9]))
    {
      sPara=makeDynString(paGetCatStr("para","nodriver"));  
      paChildPanelOn("vision/MessageWarning",  
                   paGetCatStr("para","warning"),  
                   "","",true,false,-1,-1,sPara,ok);  
      all_right=false;
      return;
    }
  }
*/

// dpc[9] == driver number !!

dpGet( dpe+":_distrib.._driver", tempDriver);
if ( tempDriver != dpc[9])
{

  dpCopyBufferClear();
  dpCopyConfig(dpe,dpSubStr(dpe, DPSUB_DP_EL), makeDynString("_distrib", "_address", "_smooth", "_cmd_conv", "_msg_conv"), iError, dpc[9]);

}

  switch (globalAddressOld[Id])  
  {  
    case "":  
      break;  
    case "pfm": case "pdp": case "rk5":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._start",dpc[4],  
                      dpe+":"+config+".._interval",dpc[5],  
                      dpe+":"+config+".._reply",dpc[6],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "ssi":  
    case "iec":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "sim":  
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._reply",dpc[6],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "abb":  
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "seb":  
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._start",dpc[4],  
                      dpe+":"+config+".._interval",dpc[5],  
                      dpe+":"+config+".._reply",dpc[6],  
                      dpe+":"+config+".._drv_ident",dpc[8],  
                      dpe+":_logger.._tel_nr",dpc[10],  
                      dpe+":_logger.._ser_nr",dpc[11]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "ads":  
      paErrorHandlingDpSet(  
        dpSetWait(dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
      if (all_right)
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "mue":  
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "opc":  
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "abb_arc":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
    case "modbus":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._start",dpc[4],  
                      dpe+":"+config+".._interval",dpc[5]/1000.0,  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "apc":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._start",dpc[4],  
                      dpe+":"+config+".._interval",dpc[5]/1000.0,  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    case "tls":
        paErrorHandlingDpSet(  
          dpSetWait(dpe+":_distrib.._driver",dpc[9]),all_right); 
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._type", DPCONFIG_PERIPH_ADDR_MAIN,
                      dpe+":"+config+".._reference",dpc[1],  
                      dpe+":"+config+".._subindex",dpc[2],  
                      dpe+":"+config+".._mode",dpc[3],  
                      dpe+":"+config+".._start",dpc[4],  
                      dpe+":"+config+".._interval",dpc[5]/1000.0,  
                      dpe+":"+config+".._reply",dpc[6],  
                      dpe+":"+config+".._datatype",dpc[7],  
                      dpe+":"+config+".._drv_ident",dpc[8]),all_right);  
        if (all_right)
          paErrorHandlingDpSet(  
            dpSetWait(dpe+":_address.._active",dpc[12]),all_right); 
      break;  
    default:
      sScript=upGetScriptName(globalAddressOld[Id]); all_right=true;
      if (sScript!="")
        evalScript(dpc, sScript, makeDynString(), dpe, Id, dpc, 2);
      all_right=(dynlen(dpc)>=99)?dpc[99]:false;
      break;  
  }  
}          
  
paDpCopyAddress(string dpe_source, string dpe_destination, bool &all_right)  
{  
}  
  
paWritePanelAllAddressAttributes(string dpe, dyn_anytype dpc)  
{  
  int        i,j=0,pos=1,trafoPos,
             ta,st,mi,wert,lowlevel,intern,OF_MONTH=2678400,OF_WEEK=604800,OF_DAY=86400,  
             plc=0,comp=0,rack=0,slot=0,mode=0,  
             cbase=0,cfactor=1,ctime,  
             ibase=0,ifactor=0,icommand,  
             smooth=0,flutter=1,Id=paMyModuleId(),  
             art, df=0, m, m13, p, q;  
  bool       all_right=true,err=false;  
  float      itime;  
  string     s,ss,text,reference,sScript;  
  dyn_int    typ;  
  dyn_string ds,dss,gdsEqu;
  string     server;
  
  switch (globalAddressOld[Id])  
  {  
    case "":  
      pos=dynContains(globalAddressDrivers,dpc[8]);  
      if (pos>0)  
        setValue("treiber", "selectedPos", pos/*!!!,  
                            "enabled",false!!!*/);  
      else  
        setValue("treiber", "selectedPos", 1/*!!!,  
                            "enabled",true!!!*/);  
      break;  
    case "pfm": case "pdp":  
      if (dpc[7]==39) dpc[7]=0;   
      if (dpc[7]==38) dpc[7]=15;   
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}    
      if (dpc[3]>=32) { dpc[3]-=32; intern=1;}   
      if (dpc[3]<=0) dpc[3]=1;   
      paSetPollingValues(dpc[3],dpc[4],lowlevel,intern);  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],   
                    "subindex","text",dpc[2],   
                    "timeout","text",period(dpc[6]),   
                    "poll_zeit","text",period(dpc[5]),   
                    "trans_art","selectedPos",dpc[7]+1,   
                    "Treiber","text",dpc[9]);   
      break;  
    case "iec": 
      if (dpc[3]>=64)  
      {  
        dpc[3]-=64; lowlevel=1;  
      }  
      if ( dpc[3]<=0  )  
      {  
        m=1; m13 = 1;//m13=5;  
      }  
      else  
      {  
        m=dpc[3]; m13=dpc[3];  
      }  
      if (m13==1)  
        setValue("einaus13","number",0);  
      else  
      if (m13==2)  
        setValue("einaus13","number",2);  
      else  
        setValue("einaus13","number",1);  
      setMultiValue("cboAddressActive","state",0,dpc[12], 
                    "einaus13","visible",true,   
                    "Treiber","text",dpc[9]);  
      paShowReference_iec(dpc[1]);  
      setValue("subindex", "text", dpc[2]);    
      break;  
    case "ssi":  
      sscanf(dpc[1],"%d",art);  
      dpGet("_SSI_DaDf_Table.Da_"+art+":_online.._value",df);  
      if (dpc[3]>=64)  
      {  
        dpc[3]-=64; lowlevel=1;  
      }  
      if ( dpc[3]<=0  )  
      {  
        m=1; m13=5;  
      }  
      else  
      {  
        m=dpc[3]; m13=dpc[3];  
      }  
      setValue("einaus","number",m-1);  
      if (m13==1)  
        setValue("einaus13","number",0);  
      else  
      if (m13==2)  
        setValue("einaus13","number",2);  
      else  
        setValue("einaus13","number",1);  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "einaus","visible",!((df==13) || (df==113)),  
                    "einaus13","visible",((df==13) || (df==113)),   
                    "Treiber","text",dpc[9]);  
      paShowReference(dpc[1]);  
      setValue("subindex", "text", dpc[2]);    
      _ssi_zeige_subindex();    
      break;  
    case "rk5":  
      if (dpc[7]==39) dpc[7]=0;   
      if (dpc[7]==38) dpc[7]=15;   
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}    
      if (dpc[3]>=32) { dpc[3]-=32;}   
      if (dpc[3]<=0) dpc[3]=1;   
      paSetPollingValues(dpc[3],dpc[4],lowlevel,0);  
      reference=paSetAddressValues(dpc[1]);   // evaluating PA  
      paSetupTrafo();                         // possible values in trafo  
      trafoPos = paSelectTrafo(dpc[7]);       // selecting trafo  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],   
                    "subindex","text",dpc[2],   
                    "timeout","text",period(dpc[6]),   
                    "poll_zeit","text",period(dpc[5]),   
                    "trans_art","selectedPos",trafoPos,   
                    "Treiber","text",dpc[9]);  
      break;  
    case "sim":  
      if (dpc[7]==39) dpc[7]=0;  
      if (dpc[7]==38) dpc[7] = 15;  
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}   
      if (dpc[3]>=32) { dpc[3]-=32;}  
      if (dpc[3]<=0) dpc[3]=1;  
      if (dpc[3]==1 ||dpc[3]==5)  
      {  
        setMultiValue("lowlevel","visible",false,  
                      "lowlevel", "state", 0,lowlevel);  
        if (dpc[3]==1)  
          setValue("einaus","number",0);  
        else  
          setValue("einaus","number",1);  
      }  
      else  
      {  
        setMultiValue("einaus","number",2,  
                      "lowlevel","visible",true,  
                      "lowlevel", "state", 0,lowlevel);  
      }  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],  
                    "subindex","text",dpc[2],  
                    "timeout","text",period(dpc[6]),  
                    "trans_art","selectedPos",dpc[7]+1,  
                    "Treiber","text",dpc[9]);   
      break;  
    case "abb":  
      if (dpc[3]==66) { dpc[3]=2; lowlevel=1;}   // Eingang Spontan + LLV
      else            lowlevel=0;
      if (dpc[3]<=0) dpc[3]=1;                   // Ausgang Gruppe
      if (dpc[3]>2)  dpc[3]=2;                   // Eingang Spontan
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],   
                    "einaus","number",(dpc[3]==1 ? 1 : 0),   
                    "lowlevel","visible",(dpc[3]==2),   
                    "lowlevel","state",0,lowlevel,   
                    "Treiber","text",dpc[9]);   
      break;  
    case "seb":  
      if (dpc[3]<=0) dpc[3]=1;  
      setMultiValue("modus","number",dpc[3]>1?dpc[3]-2:0,  
                    "einaus","number",(dpc[3]>1),  
                    "modus","visible",(dpc[3]!=1),  
                    "tm","visible",(dpc[3]!=1),  
                    "border1","visible",(dpc[3]!=1),  
                    "txtstz", "visible",(dpc[3]==4),  
                    "stastu", "visible",(dpc[3]==4),  
                    "stamin", "visible",(dpc[3]==4),  
                    "poll_zeit","visible",(dpc[3]==4),  
                    "border2","visible",(dpc[3]==4),  
                    "border3","visible",(dpc[3]==4),  
                    "tp","visible",(dpc[3]==4));  
      st=period(dpc[4]);  
      if (st>=2678400) st-=2678400;  
      else  
      if (st>=604800) st-=604800;  
      else  
      if (st>=86400) st-=86400;  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],   
                    "timeout","text",period(dpc[6]),   
                    "poll_zeit","text",period(dpc[5]),   
                    "stastu", "text", (st/3600),  
                    "stamin", "text", (st%3600/60),  
                    "Treiber","text",dpc[9],  
                    "tel_nr","text",dpc[10],  
                    "ser_nr","text",dpc[11]);  
      break;  
    case "mue":  
      switch (dpc[3])   
      {   
        case 0 :    
          mode = 0; break;   
        case 1 :    
        case 5 :   
          mode = 3; break;   
        case 2 :   
          mode = 2; break;   
        case 4 :   
          mode = 1; break;   
        default :   
          mode = 2; break;   
      }   
      if ( (dpc[7]!=401 && dpc[7]!=402) ||  
           paInterpretReference(dpc[1],dpc[2],mode,dpc[7],  
                              plc,comp,rack,slot,  
                              cbase,cfactor,ctime,  
                              ibase,ifactor,itime,icommand,  
                              smooth,flutter)==false  
         )  
      {  
        dpc[1]="EI0.0.0.0:8A00:0";  
      }  
      paInterpretReference(dpc[1],dpc[2],mode,dpc[7],  
                         plc,comp,rack,slot,  
                         cbase,cfactor,ctime,  
                         ibase,ifactor,itime,icommand,  
                         smooth,flutter);  
      paSetMuehbusPanel(dpc[1],dpc[2],mode,dpc[7],  
                      plc,comp,rack,slot,  
                      cbase,cfactor,ctime,  
                      ibase,ifactor,itime,icommand,  
                      smooth,flutter, dpc[9], dpc[12]);  
      break;  
    case "opc":
      setMultiValue("subindex","visible",(dpc[7]==491),
                    "subindexTxt","visible",(dpc[7]==491));
      if (dpc[7]!=491)
      {
        dpc[2] = 0;
      }
      dss=dpNames("*","_OPCServer");j=0;
      for (i=1;i<=dynlen(dss);i++)
      {
        dss[i]=dpSubStr(dss[i],DPSUB_DP);
        if (strpos(dss[i],"_")==0)
        {
          j++;
          ds[j]=strltrim(dss[i],"_");
        }
      }
      setValue("servers","items",ds);
      ds=makeDynString();
      dss=dpNames("*","_OPCGroup");j=0;
      for (i=1;i<=dynlen(dss);i++)
      {
        dss[i]=dpSubStr(dss[i],DPSUB_DP);
        if (strpos(dss[i],"_")==0)
        {
          j++;
          ds[j]=strltrim(dss[i],"_");
        }
      }
      setValue("groups","items",ds);
      ds=makeDynString();
      ds=strsplit(dpc[1],"$");
      for (i=1;i<4;i++)
        if (dynlen(ds)<i) ds[i]="";

      setMultiValue("servers","text",ds[1],
                    "groups","text",ds[2],
                    "items","text",ds[3],
                    "item","text",ds[3]);

      if      ( dpc[7]==   0) s="default";  
      else if ( dpc[7]== 480) s="undefined";  
      else if ( dpc[7]== 486) s="boolean";  
      else if ( dpc[7]== 481) s="integer16";  
      else if ( dpc[7]== 482) s="integer32";  
      else if ( dpc[7]== 484) s="float32";  
      else if ( dpc[7]== 485) s="float64";  
      else if ( dpc[7]== 487) s="string";  
      else if ( dpc[7]== 483) s="uchar"; 
      else if ( dpc[7]== 488) s="uinteger16"; 
      else if ( dpc[7]== 489) s="uinteger32"; 
      else if ( dpc[7]== 490) s="time"; 
      else if ( dpc[7]== 491) s="bitstring"; 
      else                    s="undefined"; 

      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1; }  
      
      // inserted by mhaslop 14.10.99 (TI 3287)
      
      server="_"+strltrim(strrtrim(ds[1]));

      if (strltrim(strrtrim(server))!="_")
      {
        dyn_string dsItems;
        
        dpGet(server+".ItemIds:_online.._value", dsItems);
        setValue("items","items",dsItems);
        setValue("items","text",ds[3]); //, "visible", true); //!!! visible weg für OPC

/*
        dpConnect("OPCworkGetItemIds",false,server+".ItemIds:_online.._value");
      
        paErrorHandlingOpc("set",
        dpSetWait(server+".GetItemIds:_original.._value",1) );
*/
      }
      // end insert

      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "lowlevel","state",0,lowlevel,
                    "subindex","text",dpc[2],
                    "direction","number",( (dpc[3]==1 || dpc[3]==5) ? 0 : 1),
                    "trans_art","text",s,
                    "Treiber","text",dpc[9],
                    "olditem","text",ds[3]);  
      break;  
    case "abb_arc": 
    { 
      int      dtyp;
      char     c;
      unsigned modus=dpc[3],node=0,din=0,job=0,dwort=0;
      
      if (dpc[1]=="" || (dpc[1][0]!="r" && dpc[1][0]!="t"))
        dpc[1] = "r" + node + "." + din + "." + job + "." + dwort;

      if (modus == 0)
        modus = 0x42;
      dtyp = dpElementType(dpSubStr(dpe, DPSUB_DP_EL));
      if ((modus & 0x07) == 2)
        sscanf(dpc[1],"%c%u.%u.%u.%u",c,node,din,job,dwort);
      else
        sscanf(dpc[1], "%c%u.%u.%u",c,node,din,job);
  
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "paName", "text", dpc[1],
                    "modus", "number", ((modus & 0x07) == 2 ? 0 : 1),
                    "lowlevel", "visible", ((modus & 0x07) == 2 ? true : false),
                    "lowlevel", "state", 0, (modus & 0x40 ? true : false),
                    "node", "text", node,
                    "din", "text", din,
                    "job", "text", job,
                    "dwort", "text", ((modus & 0x07) == 2 ? dwort : (dpc[2] & 0x0FF0) / 0x0010),
                    "tdbit", "visible", (dtyp == DPEL_BOOL ? true : false),
                    "dbit", "visible", (dtyp == DPEL_BOOL ? true : false),
                    "dbit", "text", dpc[2] & 0x000F,
                    "Treiber","text",dpc[9]);   
      break; 
    case "modbus":
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}   // Eingang Spontan + LLV
      else            lowlevel=0;
      if (dpc[3]<=0 || dpc[3]==5) dpc[3]=1;
      if (dpc[3] == 1) p = 0; else p = 1; 
      if (dpc[3] == 2) q = 0; else if (dpc[3] == 3) q = 2; else q = 1;

      if ( dpc[7]== 560) s="undefined";  
      else if ( dpc[7]== 561) s="int 16";  
      else if ( dpc[7]== 562) s="int 32";  
      else if ( dpc[7]== 563) s="uint 16";  
      else if ( dpc[7]== 564) s="uint 32";  
      else if ( dpc[7]== 565) s="byte";  
      else if ( dpc[7]== 566) s="float";  
      else if ( dpc[7]== 567) s="boolean";  
      else if ( dpc[7]== 568) s="boolean as byte";  
      else if ( dpc[7]== 569) s="string";  
      else if ( dpc[7]== 570) s="blob";  
      else                    s="undefined"; 
      paSetPollingValues(dpc[3],dpc[4],lowlevel,0);  
      ds = strsplit(dpc[1], "."); i = ds[3];
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],
                    "cmbType","text",(ds[1]=="M")?"MODBUS":"UNICOS",
                    "spbPlc","text",ds[2],
                    "spbRef","text",ds[4],
                    "einaus","number",p,   
                    "lowlevel","state",0,lowlevel,   
                    "Treiber","text",dpc[9],
                    "poll_zeit","text",dpc[5],
                    "modus", "number", q,   
                    "trans_art","text", s );   
      delay(0,300);
      setValue("subindex","text", dpc[2]);
      paSetModbusFc(ds[1], dpc[3], i);
      break;  
    case "apc":
      gdsEqu = dpNames("*", "_Apc_Equ");
      for ( i = dynlen(gdsEqu); i > 0; i-- )
      {
        // don't display redundant datapoints
        if ( i > 1 &&
             strpos(gdsEqu[i],"_2") == strlen(gdsEqu[i]) - 2 &&
             gdsEqu[i] == gdsEqu[i-1] + "_2"
           )
        {
          dynRemove(gdsEqu, i);
        }
      }
      if ( dynlen(gdsEqu) > 0 )
        for ( i = 1; i <= dynlen(gdsEqu); i++ )
        {
          gdsEqu[i] = dpSubStr(gdsEqu[i], DPSUB_DP);
          gdsEqu[i] = substr(gdsEqu[i], 1, strlen(gdsEqu[i]) - 1);
        }
      else
        gdsEqu[1] = "???";
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}   // Eingang Spontan + LLV
      else            lowlevel=0;
      if (dpc[3]<=0 || dpc[3]==5) dpc[3]=1;
      if (dpc[3] == 1) p = 0; else p = 1; 
      if (dpc[3] == 2) q = 0; else q = 1;

      if ( dpc[7]== 640) s="undefined";  
      else if ( dpc[7]== 643) s="int 16";  
      else if ( dpc[7]== 644) s="int 32";  
      else if ( dpc[7]== 646) s="uint 16";  
      else if ( dpc[7]== 642) s="byte";  
      else if ( dpc[7]== 645) s="float";  
      else if ( dpc[7]== 641) s="boolean";  
      else                    s="undefined"; 
      paSetPollingValues(dpc[3],dpc[4],lowlevel,0);  
//!!!
      ds = makeDynString();
      if ( ( i = strpos(dpc[1], ".") ) >= 0 )
      {
        ds[1] = substr(dpc[1],0,i);
        ds[2] = substr(dpc[1],i+1,strlen(dpc[1])-i);
      }
      else
      {
        ds[1] = dpc[1];
      }
      if ( dynlen(ds) < 1 || ds[1] == "" || ds[1] == "0" ) ds[1] = gdsEqu[1];
      if ( dynlen(ds) < 2 ) ds[2] = "";
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",ds[1] + "." + ds[2],
                    "cmbEquipment","items",gdsEqu);
      // IM 49920
      setMultiValue("cmbEquipment","selectedPos",dynContains(gdsEqu,ds[1]),
                    "address","text",ds[2],
                    "einaus","number",p,   
                    "lowlevel","state",0,lowlevel,   
                    "Treiber","text",dpc[9],
                    "poll_zeit","text",dpc[5],
                    "modus", "number", q,   
                    "trans_art","text", s );   
      paSetApcDrv( dpc[3] );
      delay(0,300);
      setValue("subindex","text", dpc[2]);
      if ( dynContains(gdsEqu, ds[1]) < 1 )
      {
        dyn_float  df;
        dyn_string ds;

        ChildPanelOnCentralModalReturn("vision/MessageWarning",
          getCatStr("para","warning"),
          makeDynString(getCatStr("para","apc_nousedequipment")),df,ds);
      }
      break;  
    case "tls":
      if (dpc[3]>=64) { dpc[3]-=64; lowlevel=1;}   // Eingang Spontan + LLV
      else            lowlevel=0;
      if (dpc[3]<=0 || dpc[3]==5) dpc[3]=1;
      if (dpc[3] == 1) p = 0; else p = 1; 
      if (dpc[3] == 2) q = 0; else if (dpc[3] == 3) q = 2; else q = 1;

      if (dpc[3]==1 ||dpc[3]==5)  
      {  
        setMultiValue("lowlevel","visible",false,  
                      "lowlevel", "state", 0,lowlevel);  
        if (dpc[3]==1)  
          setValue("einaus","number",0);  
        else  
          setValue("einaus","number",1);  
      }  
      else  
      {  
        setMultiValue("einaus","number",2,  
                      "lowlevel","visible",true,  
                      "lowlevel", "state", 0,lowlevel);  
      }  

      tlsSetPollingValues(dpc[3],dpc[4],lowlevel,0);
      ds = strsplit(dpc[1],".");
      setMultiValue("cboAddressActive","state",0,dpc[12],   
                    "var_name","text",dpc[1],
                    "lowlevel","state",0,lowlevel,   
                    "Treiber","text",dpc[9],
                    "poll_zeit","text",dpc[5],
                    "modus", "number", q,
                    "EHB","text", dynlen(ds) > 1  ? ds[1] : 0,
                    "HB", "text", dynlen(ds) > 2  ? ds[2] : 0,
                    "LB", "text", dynlen(ds) > 3  ? ds[3] : 0,
                    "FG", "text", dynlen(ds) > 4  ? ds[4] : 0,
                    "Type","text",dynlen(ds) >= 5 ? ds[5] : 0,
                    "DE", "text", dynlen(ds) >= 6 ? ds[6] : 0,
                    "SC", "text", dynlen(ds) == 7 ? ds[7] : ""
                   );
                       
      delay(0,300);
      setValue("subindex","text", dpc[2]);
      break;  
    default:
      sScript=upGetScriptName(globalAddressOld[Id]);
      if (sScript!="")
        evalScript(dpc, sScript, makeDynString(), dpe, Id, dpc, 3);
      break;
    } 
  }  
}  
  
bool paReadPanelAllAddressAttributes(string dpe, dyn_anytype &dpc, bool &readOK)  
{  
  int        pos,i,j,k,l,m,n,o,p,sy,ta,st,mi,wert,driver,datatype,  
             lowlevel,q,intern,OF_MONTH=2678400,OF_WEEK=604800,OF_DAY=86400,  
             p13,da,df;  
  bool       df13,active,all_right=true;  
  string     s,ss,u,tel_nr,ser_nr,text,server,group,item,sScript;  
  time       t1, t2, t3;  
  dyn_string d,ds; 
  
  dpc=globalAnytype;  
  readOK=true;

  switch (globalAddressOld[paMyModuleId()])  
  {  
    case "":
      if (myPanelName()=="address")
      {  
        getValue("treiber","selectedPos",pos);  
        dpc[8]=globalAddressDrivers[pos];  
      }
      break;  
    case "pfm": case "pdp": case "rk5":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "trans_art","selectedPos",j,  
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "syncmod", "number",sy,  
                    "statag", "selectedPos", ta,  
                    "stastu", "text", st,  
                    "stamin", "text", mi,  
                    "timeout","text",m,  
                    "poll_zeit","text",n,  
                    "einaus","number",p,  
                    "lowlevel","state",0,lowlevel,  
                    "modus","number",q);  
      if (ta<1) ta=1;
      if (globalAddressOld[paMyModuleId()]=="rk5")  
      {  
        j=paConvertTrafo();  
        s=paEncodeAddress(l);  
      }  
      else  
      {  
        getValue("intern","state",0,intern);  
        if (j==1) j=40;  
        if (j>0) j--;  
        // if (j==15) j=38;  // bit string reversed  
      }  
  
      ta=ta-1;  
      if (p==0) q=1;  
      else  
      if (p==1) q=5;  
      else q+=2;  
      wert=st*3600+mi*60;  
      if (sy==0)  
        wert=wert+ta*86400 + OF_MONTH;  
      else if (sy==1)  
        wert=wert+ta*86400 + OF_WEEK;  
      else if (sy==2)  
        wert=wert + OF_DAY;  
      setPeriod(t1, wert);  
      setPeriod(t2, m);  
      setPeriod(t3, n);  
      if (lowlevel) q+=64;  
      if (globalAddressOld[paMyModuleId()]=="rk5")  
      {  
        if (intern) q+=32;  
      }  
      dpc[1]=s;  
      dpc[2]=l;  
      dpc[3]=q;  
      dpc[4]=t1;  
      dpc[5]=t3;  
      dpc[6]=t2;  
      dpc[7]=j;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "ssi":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "einaus","number",p,  
                    "einaus13","number",p13,  
                    "einaus13","visible",df13,  
                    "var_da", "text", da);  
//      dpGet("_SSI_DaDf_Table.Da_"+da+":_online.._value", df);    
      if (df13)  
      {  
        if (p13==0) p=1;  
        else   
        if (p13==1) p=5;  
        else        p=2;  
      }  
      else  
      {  
        if (p==0) p=1;  
        else      p=2;  
      }  
      dpc[1]=s;  
      dpc[2]=l;  
      dpc[3]=p;  
      dpc[7]=40;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;
      break;  
    case "iec":  
      getMultiValue("cboAddressActive","state",0,active,
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "einaus13","number",p13,  
                    "einaus13","visible",df13,  
                    "var_da", "text", da);  
//      dpGet("_SSI_DaDf_Table.Da_"+da+":_online.._value", df);    
      if (p13==0) 
        p=1;  
      else if (p13==1) 
        p=5;  
      else  
        p=2;  
      dpc[1]=s;  
      dpc[2]=l;  
      dpc[3]=p;  
      dpc[7] = _iecConvertDaToType(da);
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;
      break;  
    case "sim":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "trans_art","selectedPos",j,  
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "timeout","text",m,  
                    "einaus","number",p,  
                    "lowlevel","state",0,lowlevel);  
      q=0;  
      if (j==1) j=40;   // bit  
      if (j>0) j--;  
      if (j==15) j=38;  // bit string reversed  
      if (p==0) q=1;  
      else  
      if (p==1) q=5;  
      else q+=2;  
      setPeriod(t2, m);  
      if (lowlevel) q+=64;  
      dpc[1]=s;  
      dpc[2]=l;  
      dpc[3]=q;  
      dpc[6]=t2;  
      dpc[7]=j;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "abb":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "var_name","text",s,   
                    "einaus","number",p,   
                    "lowlevel","state",0,lowlevel,   
                    "Treiber","text",driver);   
      if (p==0)
      {
        q=2;                   // Eingang Spontan
        if (lowlevel) q=66;    // Eingang Spontan + LLV
      }
      else
        q=1;                   // Ausgang Gruppe
      dpc[1]=s;  
      dpc[3]=q;  
      dpc[7]=280;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])]; 
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "seb":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "Treiber","text",driver,  
                    "var_name","text",s,  
                    "stastu", "text", st,  
                    "stamin", "text", mi,  
                    "timeout","text",m,  
                    "poll_zeit","text",n,  
                    "einaus","number",p,  
                    "modus","number",q,  
                    "tel_nr","text",tel_nr,  
                    "ser_nr","text",ser_nr);  
      if (p==0) q=1;  
      else q+=2;  
      setPeriod(t1, st * 3600 + mi * 60 + 86400);  
      setPeriod(t2, m);  
      setPeriod(t3, n);  
      dpc[1]=s;  
      dpc[3]=q;  
      dpc[4]=t1;  
      dpc[5]=t3;  
      dpc[6]=t2;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[10]=tel_nr;  
      dpc[11]=ser_nr;  
      dpc[12]=active;  
      break;  
    case "ads":  
      getValue("cboAddressActive","state",0,active);
      dpc[12]=active;  
      break;  
    case "mue":  
      getMultiValue("cboAddressActive","state",0,active,   
                    "Treiber","text",driver,  
                    "reference","text",s,  
                    "subindex","text",l,  
                    "mode","number",q,  
                    "datatype","number",datatype);  
      datatype+=401;  
      switch (q)   
      {   
        case 0 :  // Auf Anforderung   
          i = 3; break;   
        case 1 :  // Zyklisch   
          i = 4; break;   
        case 2 :  // Spontan   
          i = 2; break;   
        case 3 :  // Ausgang (Einzel)   
          i = 5; break;   
        default :    
          i = 0; break;   
      }  
      dpc[1]=s;  
      dpc[2]=l;  
      dpc[3]=i;  
      dpc[7]=datatype;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "opc":
    { 
      int subindex = 0;
      
      getMultiValue("cboAddressActive","state",0,active,   
                    "servers","text",server,
                    "subindex","text",subindex,
                    "groups","text",group,
                    "item","text",item,
                    "lowlevel","state",0,lowlevel,
                    "direction","number",p,
                    "trans_art","text",ss,
                    "Treiber","text",driver);
      s=server+"$"+group+"$"+item;  
      if (p==0) q= (ss=="bitstring") ? 1 : 5;  
      else      q=2;
      if (lowlevel && q==2) q+=64; 

      if      ( ss=="default" )    j=0;  
      else if ( ss=="undefined" )  j=480;  
      else if ( ss=="boolean" )    j=486;  
      else if ( ss=="integer16" )  j=481;  
      else if ( ss=="integer32" )  j=482;  
      else if ( ss=="float32" )    j=484;  
      else if ( ss=="float64" )    j=485;  
      else if ( ss=="string" )     j=487;  
      else if ( ss=="uchar" )      j=483;  
      else if ( ss=="uinteger16" ) j=488;  
      else if ( ss=="uinteger32" ) j=489;  
      else if ( ss=="time" )       j=490;  
      else if ( ss=="bitstring" )  j=491;  

      dpc[1]=s;  
      dpc[2]=(j==491)?subindex:0;  
      dpc[3]=q;  
      dpc[7]=j;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;  
      if (strltrim(strrtrim(item))=="")
      {
        readOK=false;
      }
      break;  
    }

    case "abb_arc":  
    {
      int    nr,dtyp,dwort,dbit,modus,subindex=0,node,din,job;
      string pa;

      getMultiValue("cboAddressActive","state",0,active,   
                    "lowlevel","state",0,lowlevel,
                    "modus", "number", nr,
                    "node", "text", node,
                    "din", "text", din,
                    "job", "text", job,
                    "dwort", "text", dwort,
                    "dbit", "text", dbit,
                    "Treiber","text",driver);
      if (nr == 0)
      {
        modus = 2;
        if (lowlevel) 
          modus += 64;
        datatype = dpElementType(dpSubStr(dpe,DPSUB_DP_EL)) == DPEL_BOOL ? 1001 : 1002;
      }
      else
      {
        modus = 1;
        datatype = 1003;
        subindex |= (dpElementType(dpSubStr(dpe,DPSUB_DP_EL)) == DPEL_BOOL ? 0x0000 : 0x1000);
        subindex |= (dwort * 0x0010);
      }

      subindex |= dbit;

      if (nr == 0)
        pa = "r" + node + "." + din + "." + job + "." + dwort;
      else
        pa = "t" + node + "." + din + "." + job;

      dpc[1]=pa;
      dpc[2]=subindex;
      dpc[3]=modus;
      dpc[7]=datatype;  
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])];  
      dpc[9]=driver;  
      dpc[12]=active;  
      break;
    case "modbus":

      getMultiValue("cboAddressActive","state",0,active,   
                    "trans_art","selectedPos",j,  
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "syncmod", "number",sy,  
                    "statag", "selectedPos", ta,  
                    "stastu", "text", st,  
                    "stamin", "text", mi,  
                    "poll_zeit","text",n,  
                    "einaus","number",p,  
                    "lowlevel","state",0,lowlevel,  
                    "modus","number",q);  

      j=paConvertTrafoModbus();

      if (ta<1) ta=1; ta--;
      wert=st*3600+mi*60;  
      if (sy==0)  
        wert=wert+ta*86400 + OF_MONTH;  
      else if (sy==1)  
        wert=wert+ta*86400 + OF_WEEK;  
      else if (sy==2)  
        wert=wert + OF_DAY;  
      setPeriod(t1, wert);  

      if (p==1)
      {
        if ( q == 0 ) q = 2; // input spontaneous
        else
        if ( q == 2 ) q = 3; // input single query
        else          q = 4; // input polling
        if (lowlevel) q+=64; // input + LLV
      }
      else
        q=1;                   // Ausgang Gruppe

      dpc[1]=s;
      dpc[2]=l;
      dpc[3]=q;
      dpc[4]=t1;  
      if ( n > 0 && n < 100 ) n = 100;
      dpc[5]=n;
      dpc[7]=j;
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])]; 
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "apc":

      getMultiValue("cboAddressActive","state",0,active,   
                    "trans_art","selectedPos",j,  
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "syncmod", "number",sy,  
                    "statag", "selectedPos", ta,  
                    "stastu", "text", st,  
                    "stamin", "text", mi,  
                    "poll_zeit","text",n,  
                    "einaus","number",p,  
                    "lowlevel","state",0,lowlevel,  
                    "modus","number",q);  

      j=paConvertTrafoApc();

      if (ta<1) ta=1; ta--;
      wert=st*3600+mi*60;  
      if (sy==0)  
        wert=wert+ta*86400 + OF_MONTH;  
      else if (sy==1)  
        wert=wert+ta*86400 + OF_WEEK;  
      else if (sy==2)  
        wert=wert + OF_DAY;  
      setPeriod(t1, wert);  

      if (p==1)
      {
        if ( q == 0 ) q = 2; // input spontaneous
        else          q = 4; // input polling
        if (lowlevel) q+=64; // input + LLV
      }
      else
        q=1;                   // Ausgang Gruppe

      dpc[1]=s;
      dpc[2]=l;
      dpc[3]=q;
      dpc[4]=t1;  
      if ( n > 0 && n < 100 ) n = 100;
      dpc[5]=n;
      dpc[7]=j;
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])]; 
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    case "tls":

      getMultiValue("cboAddressActive","state",0,active,   
                    "Treiber","text",driver,  
                    "subindex","text",l,  
                    "var_name","text",s,  
                    "syncmod", "number",sy,  
                    "statag", "selectedPos", ta,  
                    "stastu", "text", st,  
                    "stamin", "text", mi,  
                    "poll_zeit","text",n,  
                    "einaus","number",p,  
                    "lowlevel","state",0,lowlevel,  
                    "modus","number",q
//                     "EHB","text", ds[1],
//                     "HB", "text", ds[2],
//                     "LB", "text", ds[3],
//                     "FG", "text", ds[4],
//                     "Type","text",ds[5],
//                     "DE", "text", ds[6]
                   );  

      j=0;

      if (ta<1) ta=1; ta--;
      wert=st*3600+mi*60;  
      if (sy==0)  
        wert=wert+ta*86400 + OF_MONTH;  
      else if (sy==1)  
        wert=wert+ta*86400 + OF_WEEK;  
      else if (sy==2)  
        wert=wert + OF_DAY;  
      setPeriod(t1, wert);  

      if (p==1)
      {
        if ( q == 0 ) q = 2; // input spontaneous
        else
        if ( q == 2 ) q = 3; // input single query
        else          q = 4; // input polling
        if (lowlevel) q+=64; // input + LLV
      }
      else
        q=1;                   // Ausgang Gruppe

      // dpc[1]=ds[1]+"."+ds[2]+"."+ds[3]+"."+ds[4]+"."+ds[5]+"."+ds[6];
      dpc[1]=s;
      dpc[2]=l;
      dpc[3]=q;
      dpc[4]=t1;  
      dpc[5]=n;
      dpc[7]=j;
      dpc[8]=globalAddressDrivers[dynContains(globalAddressTypes,globalAddressNew[paMyModuleId()])]; 
      dpc[9]=driver;  
      dpc[12]=active;  
      break;  
    default:
      sScript=upGetScriptName(globalAddressOld[paMyModuleId()]);
      if (sScript!="")
        evalScript(dpc, sScript, makeDynString(), dpe, paMyModuleId(), dpc, 4);
      readOK=(dynlen(dpc)>=99)?dpc[99]:false;
      break;
    }
  }  
  return (readOK);
}  
  
paSaveAllAddressAttributes(string OpenConfig,bool &allright)  
{ 
  bool        ok; 
  string      dpe=dpSubStr(OpenConfig,DPSUB_SYS_DP_EL);
  dyn_string  sPara;  
  dyn_anytype dpc;  
  
  paReadPanelAllAddressAttributes(dpe,dpc,ok);  
  if (ok)
  {
    int Id=paMyModuleId();

    if ( globalAddressOld[Id] == "opc" )
    {
      dyn_float  df;
      dyn_string ds = strsplit(dpc[1], "$");
      
      if ( dynlen(ds) < 3 || ds[1] == "" || ds[2] == "" || ds[3] == "" )
      {
        sPara=makeDynString(paGetCatStr("para","noref"));  
        paChildPanelOn("vision/MessageWarning",  
                       paGetCatStr("para","warning"),  
                       "","",true,false,-1,-1,sPara,ok);  
        allright = false;
        return;
      }
    }

    paDpSetAddress(dpe,dpc,allright);  
    paPutGlobalDpc(OpenConfig,dpc);  
  }
  else
  {
    sPara=makeDynString(paGetCatStr("para","noitem"));  
    paChildPanelOn("vision/MessageWarning",  
                   paGetCatStr("para","warning"),  
                   "","",true,false,-1,-1,sPara,ok);  
    allright = false;
  }
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for pfm,pdp,rk5  
//////////////////////////////////////////////////////////////////////////////
// Evaluating of polling times  
//////////////////////////////////////////////////////////////////////////////  
paSetPollingValues(int modus,time startzeit,int lowlevel,int intern)  
{  
  int        i,ta,st,mi,wert,  
             OF_MONTH = 2678400,OF_WEEK = 604800,OF_DAY = 86400;  
  dyn_string ds_month,ds_week;  
  
  for (i=1;i<=7;i++) ds_week[i]=paGetCatStr("para","weekday"+i);
  for (i=1;i<=31;i++) ds_month[i]=i;
  
  wert=period(startzeit);   
  if (modus==1 || modus==5 || (globalAddressOld[paMyModuleId()] == "modbus" && modus == 2) )   
  {   
    setMultiValue("tm","visible",false,   
                  "lowlevel","visible",false,   
                  "modus","visible",false,   
                  "border1","visible",false,   
                  "tp","visible",false,   
                  "txtstz", "visible", false,   
                  "txttag", "visible", false,   
                  "txtstd", "visible", false,   
                  "txtmin", "visible", false,   
                  "syncmod", "visible", false,   
                  "border2","visible",false,   
                  "border3","visible",false,   
                  "synchelp", "visible", false,   
                  "statag", "items", ds_month,   
                  "statag", "visible", false,   
                  "stastu", "visible", false,   
                  "stamin", "visible", false,   
                  "lowlevel", "state", 0,lowlevel,   
                  "poll_zeit","visible",false,  
                  "einaus","number",(modus==5));  
    if (globalAddressOld[paMyModuleId()]!="rk5" &&
        globalAddressOld[paMyModuleId()]!="modbus" &&
        globalAddressOld[paMyModuleId()]!="apc")  
      setMultiValue("intern","visible",true,   
                    "intern","state",0,intern);  
  }   
  else   
  {   
    setMultiValue("einaus","number",(globalAddressOld[paMyModuleId()]!="modbus")?2:1,   
                  "modus","number",(globalAddressOld[paMyModuleId()]!="modbus")?modus-2:(modus/2-1),   
                  "modus","visible",true,   
                  "border1","visible",true,   
                  "lowlevel","visible",true,   
                  "lowlevel", "state", 0,lowlevel,   
                  "tm","visible",true);   
    if (globalAddressOld[paMyModuleId()]!="rk5" &&
        globalAddressOld[paMyModuleId()]!="modbus" &&
        globalAddressOld[paMyModuleId()]!="apc")  
      setMultiValue("intern","visible",true,   
                    "intern","state",0,intern);  
    if ( modus == 4 )   
    {  
      if (wert>=OF_MONTH)   
      {   
        setMultiValue("syncmod","number",0,   
                      "txttag","visible",true,   
                      "statag","items",ds_month,   
                      "statag","visible",true,   
                      "synchelp","visible",false);   
        wert=wert-OF_MONTH;   
        ta=wert / 86400;   
        st=(wert-ta*86400) / 3600;   
        mi=(wert-ta*86400-st*3600) / 60;   
        if (ta<0) ta=0;   
        if (ta>30) ta=30;   
        ta=ta+1;   
        setMultiValue("statag","selectedPos", ta,   
                      "statag","text", ds_month[ta],   
                      "stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      if (wert>=OF_WEEK)   
      {   
        setMultiValue("syncmod","number",1,   
                      "txttag","visible",true,   
                      "statag","items",ds_week,   
                      "statag","visible",true,   
                      "synchelp","visible",true);   
        wert=wert-OF_WEEK;   
        ta=wert / 86400;   
        st=(wert-ta*86400) / 3600;   
        mi=(wert-ta*86400-st*3600) / 60;   
        if (ta<0) ta=0;   
        if (ta>6) ta=6;   
        ta=ta+1;   
        setMultiValue("statag","selectedPos", ta,   
                      "statag","text", ds_week[ta],   
                      "stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      if (wert>=OF_DAY)   
      {   
        setMultiValue("syncmod","number",2,   
                      "txttag","visible",false,   
                      "statag","visible",false,   
                      "synchelp","visible",false);   
        wert=wert-OF_DAY;   
        ta=0;   
        st=wert / 3600;   
        mi=(wert-st*3600) / 60;   
        setMultiValue("stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      {   
        setMultiValue("syncmod","number",3,   
                      "txttag","visible",false,   
                      "statag","visible",false,   
                      "synchelp","visible",false);   
        ta=0;   
        st=wert / 3600;   
        mi=(wert-st*3600) / 60;   
        setMultiValue("stastu","text", st,   
                      "stamin","text", mi);  
      }   
      setMultiValue("tp","visible",true,   
                    "txtstz", "visible", true,   
                    "txtstd", "visible", true,   
                    "txtmin", "visible", true,   
                    "syncmod", "visible", true,   
                    "border2","visible", true,   
                    "border3","visible", true,   
                    "stastu", "visible", true,   
                    "stamin", "visible", true,   
                    "poll_zeit","visible",true);   
    }   
    else   
    {   
      setMultiValue("tp","visible",false,   
                    "txtstz", "visible", false,   
                    "txttag", "visible", false,   
                    "txtstd", "visible", false,   
                    "txtmin", "visible", false,   
                    "syncmod", "visible", false,   
                    "border2","visible",false,   
                    "border3","visible",false,   
                    "synchelp", "visible", false,   
                    "statag", "visible", false,   
                    "stastu", "visible", false,   
                    "stamin", "visible", false,   
                    "poll_zeit","visible",false);   
    }   
  }   
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for rk5  
//////////////////////////////////////////////////////////////////////////////  
// Decoding of address, without complete checking  
//////////////////////////////////////////////////////////////////////////////  
string paSetAddressValues(string referenz)  
{  
  string  typ;     // Bausteintyp  
  int     nr;      // Bausteinnr  
  int     adr;     // Adresse fuer DB  
  string  fmt;     // Datenformat  
  int     i, j;    // ne variable halt  
  
  if (referenz == "" || referenz == "0")  
    referenz = "DB0DW0";  
  sscanf(referenz, "%[^0-9]%d%[^0-9]%d", typ, nr, fmt, adr);  
  
  // Ausnahmen klaeren ...  
  if (typ[0] == 'D')  // Datenbaustein  
    ;  
  else if (typ == "AS")  // Absolute Adresse  
    typ = "B";  
  else if (typ == "BS" || typ == "RS")  // System  
    typ = "R";                    
  else                   // Bei anderen Typen folgt hier das Format  
  {  
    fmt = typ[1];  
    typ = typ[0];  
  }   
  
  if (typ == "DB")  
    setValue("pa_typ", "selectedPos", 1);  
  else if (typ == "DX")  
    setValue("pa_typ", "selectedPos", 2);  
  else if (typ[0] == 'F' || typ[0] == 'M')  
    setValue("pa_typ", "selectedPos", 3);  
  else if (typ[0] == 'I' || typ[0] == 'E')  
    setValue("pa_typ", "selectedPos", 4);  
  else if (typ[0] == 'A')  
    setValue("pa_typ", "selectedPos", 5);  
  else if (typ[0] == 'T')  
    setValue("pa_typ", "selectedPos", 6);  
  else if (typ[0] == 'C' || typ[0] == 'Z')  
    setValue("pa_typ", "selectedPos", 7);  
  else if (typ[0] == 'P')  
    setValue("pa_typ", "selectedPos", 8);  
  else if (typ[0] == 'Q')  
    setValue("pa_typ", "selectedPos", 9);  
  else if (typ[0] == 'R')  
    setValue("pa_typ", "selectedPos", 10);  
  else  
    setValue("pa_typ", "selectedPos", 1);  
  
  paSetupTrafo();  
  
  getMultiValue("pa_typ", "selectedPos", i,  
                "syncmod", "number", j);  
  if (i > 2)  
  {  
    setMultiValue("txt_adr", "visible", false,  
                  "pa_adr", "visible", false,  
                  "einaus", "number", 2,  
                  "einaus", "enabled", false,  
                  "tm","visible",true,  
                  "lowlevel","visible",true,  
                  "modus","visible",true);  
  
    getValue("modus","number",i);  
    if (i==2)  
    {  
      setMultiValue("tp","visible",true,  
                    "txtstz", "visible", true,  
                    "txttag", "visible", (j < 3),  
                    "txtstd", "visible", true,  
                    "txtmin", "visible", true,  
                    "syncmod", "visible", true,  
                    "synchelp", "visible", true,  
                    "statag", "visible", (j < 3),  
                    "stastu", "visible", true,  
                    "stamin", "visible", true,  
                    "poll_zeit","visible",true);  
    }  
    else  
    {  
      setMultiValue("tp","visible",false,  
                    "txtstz", "visible", false,  
                    "txttag", "visible", false,  
                    "txtstd", "visible", false,  
                    "txtmin", "visible", false,  
                    "syncmod", "visible", false,  
                    "synchelp", "visible", false,  
                    "statag", "visible", false,  
                    "stastu", "visible", false,  
                    "stamin", "visible", false,  
                    "poll_zeit","visible",false);  
    }  
  }  
  else  
  {  
    setMultiValue("txt_adr", "visible", true,  
                  "pa_adr", "visible", true,  
                  "einaus", "enabled", true);  
  }  
  
  setValue("pa_nr", "text", nr);  
  setValue("pa_adr", "text", adr);  
  return (referenz);  
}  
  
  
//////////////////////////////////////////////////////////////////////////////  
// Setting possible tranformations corresponding to types  
//////////////////////////////////////////////////////////////////////////////  
void paSetupTrafo()  
{  
  int         typ,pos;  
  string      trans;  
  dyn_string  items;  
  
  getMultiValue("trans_art", "text", trans,  
                "pa_typ", "selectedPos", typ);  
  setValue("trans_art", "deleteAllItems");  
  switch (typ)  
  {  
    case 1 :  // DB  
    case 2 :  // DX  
    case 3 :  // M  
    case 4 :  // E  
    case 5 :  // A  
    case 8 :  // P  
    case 9 :  // Q  
      items=makeDynString("integer8","integer16","integer32","unsigned8",  
                          "unsigned16","unsigned32","floating point","bitstring",  
                          "Siemens-KT","Siemens-KC","BCD16","BCD32");  
      break;  
    case 6 : // T  
      items = makeDynString("Siemens-KT");  
      break;  
    case 7 : // Z  
      items = makeDynString("unsigned16");  
      break;  
    case 10 :  
      items=makeDynString("integer16","unsigned16","Siemens-KC","Siemens-KT","BCD16");  
      break;  
  
    default :  
      items=makeDynString("undefined");  
      break;  
  }  
  setValue("trans_art", "items", items);     
}   
  
//////////////////////////////////////////////////////////////////////////////  
// Setting possible tranformations corresponding to types  
//////////////////////////////////////////////////////////////////////////////  
void paSetupTrafoModbus()  
{  
  int         typ,pos;  
  string      trans;  
  dyn_string  items;  
  
  getMultiValue("trans_art", "text", trans,  
                "pa_typ", "selectedPos", typ);  
  setValue("trans_art", "deleteAllItems");  
  switch (typ)  
  {  
    case 1 :  // DB  
    case 2 :  // DX  
    case 3 :  // M  
    case 4 :  // E  
    case 5 :  // A  
    case 8 :  // P  
    case 9 :  // Q  
      items=makeDynString("integer8","integer16","integer32","unsigned8",  
                          "unsigned16","unsigned32","floating point","bitstring",  
                          "Siemens-KT","Siemens-KC","BCD16","BCD32");  
      break;  
    case 6 : // T  
      items = makeDynString("Siemens-KT");  
      break;  
    case 7 : // Z  
      items = makeDynString("unsigned16");  
      break;  
    case 10 :  
      items=makeDynString("integer16","unsigned16","Siemens-KC","Siemens-KT","BCD16");  
      break;  
  
    default :  
      items=makeDynString("undefined");  
      break;  
  }  
  setValue("trans_art", "items", items);     
}   

//////////////////////////////////////////////////////////////////////////////  
paSetModbusFc( string sType, int iDirection, int iFc )
{
  int        iPos = 0, i;
  string     s = var_name.text;
  dyn_int    dii;
  dyn_string ds = strsplit(s, "."), dss;
  
  dii = paGetModbusFcNumbers(sType, iDirection);
  dss = paGetModbusFcNames  (sType, iDirection);
  if ( iFc == 0 || dynContains(dii, iFc) < 1 )
  {
    if ( dynlen(dss) > 0 )
      iPos = 1;
  }
  else
  {
    iPos = dynContains(dii, iFc);
  }
  cmbFc.items   = dss;
  cmbFc.text    = (iPos>0)?dss[iPos]:"";
  cmbFc.enabled = (dynlen(dii) > 0);
  cmbFcN.text   = (iPos>0)?dii[iPos]:0;
  cmbFcN.items  = dii;
  ds[3] = cmbFcN.text;
  s = ds[1]+"."+ds[2]+"."+ds[3]+"."+ds[4];
  var_name.text = s;
  if ( ds[1] == "U" )
  {
    einaus.number = 1;
    modus.number  = 0;
  }
  einaus.enabled = (ds[1]=="M");
  modus.enabled  = (ds[1]=="M");
  setMultiValue("tm","visible",(iDirection>1),   
                "border1","visible",(iDirection>1),   
                "modus","visible",(iDirection>1),   
                "lowlevel","visible",(iDirection>1));
  if (iDirection==4)
  {
    setMultiValue("tp","visible",true,
                  "txtstz", "visible", true,
                  "syncmod", "visible", true,
                  "border2","visible", true, 
                  "border3","visible", true, 
                  "stastu", "visible", true,
                  "stamin", "visible", true,
                  "txtstd", "visible", true,
                  "txtmin", "visible", true);
    getValue("syncmod","number",i);
    if (i<2)
    {
      setMultiValue("synchelp", "visible", (i==1),
                    "statag", "visible", true,
                    "txttag", "visible", true);
    }
    else
    {
      setMultiValue("synchelp", "visible", false,
                    "statag", "visible", false,
                    "txttag", "visible", false);
    }
    setValue("poll_zeit","visible",true);
  }
  else
  {
    setMultiValue("tp","visible",false,
                  "txtstz", "visible", false,
                  "syncmod", "visible", false,
                  "border2","visible",false, 
                  "border3","visible",false, 
                  "synchelp", "visible", false,
                  "stastu", "visible", false,
                  "stamin", "visible", false,
                  "txtstd", "visible", false,
                  "txtmin", "visible", false,
                  "statag", "visible", false,
                  "txttag", "visible", false,
                  "poll_zeit","visible",false);
  }
}

string paGetModbusFcName(int i)
{
  string     s;
  dyn_string ds = makeDynString( "read coils",
                                 "read input discretes",
                                 "read multiple registers",
                                 "read input registers",
                                 "write coil",
                                 "write single register",
                                 "read exception status",
                                 "",
                                 "",
                                 "",
                                 "",
                                 "",
                                 "",
                                 "",
                                 "force multiple coils",
                                 "write multiple registers",
                                 "",
                                 "",
                                 "",
                                 "read general reference",
                                 "write general reference",
                                 "mask write register",
                                 "read/write registers",
                                 "read FIFO queue");
   if ( i <= 0 || i > dynlen(ds) )
     return ("");
   else
   {
     s = ds[i];
     return (s);
   }                             
}

dyn_string paGetModbusFcNames( string sType, int iDirection )
{
  dyn_string sd = makeDynString();
  
  if ( sType[0] == "U" && iDirection == 2 ) // Unicos input spontaneous
  {
    sd[2] = "events";
    sd[1] = "status";
  }
  else
  if ( sType[0] == "M" && ( iDirection == 2 || iDirection == 1 ) ) // Modbus input spontaneous / output
  {
    sd[1] = paGetModbusFcName(5);
    sd[2] = paGetModbusFcName(6);
    sd[3] = paGetModbusFcName(15);
    sd[4] = paGetModbusFcName(16);
  }
  else
  if ( sType[0] == "M" && ( iDirection == 3 || iDirection == 4 ) ) // Modbus input single query / polling
  {
    sd[1] = paGetModbusFcName(1);
    sd[2] = paGetModbusFcName(2);
    sd[3] = paGetModbusFcName(3);
    sd[4] = paGetModbusFcName(4);
    sd[5] = paGetModbusFcName(7);
    sd[6] = paGetModbusFcName(24);
  }
  return (sd);
}

dyn_int paGetModbusFcNumbers( string sType, int iDirection )
{
  dyn_int    di = makeDynInt();
  
  if ( sType[0] == "U" && iDirection == 2 ) // Unicos input spontaneous
  {
    di = makeDynInt   ( 1,18);
  }
  else
  if ( sType[0] == "M" && ( iDirection == 2 || iDirection == 1 ) ) // Modbus input spontaneous / output
  {
    di = makeDynInt   ( 5, 6, 15, 16 );
  }
  else
  if ( sType[0] == "M" && ( iDirection == 3 || iDirection == 4 ) ) // Modbus input single query / polling
  {
    di = makeDynInt   ( 1, 2, 3, 4, 7, 24 );
  }
  return (di);
}
//////////////////////////////////////////////////////////////////////////////  
// Converting a transformation into a position of a combo box  
//////////////////////////////////////////////////////////////////////////////  
int paSelectTrafo(int typ)  
{  
  dyn_string  items;  
  int  pos;  
  
  getValue("trans_art", "items", items);  
  switch (typ)  
  {  
    case 240 : //undefined  
      pos = dynContains(items, "undefined");   
      break;    
    case 241 : // int8  
      pos = dynContains(items, "integer8");   
      break;          
    case 242 : // uint8  
      pos = dynContains(items, "unsigned8");   
      break;    
    case 243 : // int16  
      pos = dynContains(items, "integer16");   
      break;    
    case 244 : // uint16  
      pos = dynContains(items, "unsigned16");   
      break;    
    case 245 : // int32  
      pos = dynContains(items, "integer32");   
      break;    
    case 246 : // uint32  
      pos = dynContains(items, "unsigned32");   
      break;    
    case 247 : // float  
      pos = dynContains(items, "floating point");   
      break;    
    case 248 : // BCD16  
      pos = dynContains(items, "BCD16");   
      break;    
    case 249 : // BCD32  
      pos = dynContains(items, "BCD32");   
      break;    
    case 250 : // KC  
      pos = dynContains(items, "Siemens-KC");   
      break;    
    case 251 : // KT  
      pos = dynContains(items, "Siemens-KT");   
      break;    
    case 252 : // bit  
      pos = dynContains(items, "bitstring");   
      break;    
    case 253 : // string --> undef'd  
      pos = dynContains(items, "unsigned16");   
      break;    
    case 254 : // LBYte --> undef'd  
      pos = dynContains(items, "integer8");   
      break;    
    case 255 : // RByte --> undef'd  
      pos = dynContains(items, "integer8");   
      break;    
    default :   
      pos = dynContains(items, "unsigned16");   
      break;    
  }  
  if (pos > 0)  
    return pos;  
  return 1;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Converting a position of a combo box into a transformation  
//////////////////////////////////////////////////////////////////////////////  
string paConvertTrafo()  
{  
  string item;  
  
  getValue("trans_art", "text", item);  
  if (item == "undefined")           return 240;  
  else if (item == "integer8")       return 241;  
  else if (item == "unsigned8")      return 242;  
  else if (item == "integer16")      return 243;  
  else if (item == "unsigned16")     return 244;  
  else if (item == "integer32")      return 245;  
  else if (item == "unsigned32")     return 246;  
  else if (item == "floating point") return 247;  
  else if (item == "BCD16")          return 248;  
  else if (item == "BCD32")          return 249;  
  else if (item == "Siemens-KT")     return 250;  
  else if (item == "Siemens-KC")     return 251;  
  else if (item == "bitstring")      return 252;  
  else                               return 240;  
}  

//////////////////////////////////////////////////////////////////////////////  
// Converting a position of a combo box into a transformation  
//////////////////////////////////////////////////////////////////////////////  
string paConvertTrafoModbus()  
{  
  string item;  
  
  getValue("trans_art", "text", item);  
  if (item == "undefined")          return 560;  
  else if (item == "int 16")       	return 561;  
  else if (item == "int 32")   		return 562;  
  else if (item == "uint 16")       return 563;  
  else if (item == "uint 32")       return 564;  
  else if (item == "byte")        	return 565;  
  else if (item == "float")        	return 566;  
  else if (item == "boolean")       return 567;  
  else if (item == "boolean as byte")   return 568;  
  else if (item == "string")        return 569;  
  else if (item == "blob")        	return 570;  
  else                              return 560;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Converting a position of a combo box into a transformation  
//////////////////////////////////////////////////////////////////////////////  
string paConvertTrafoApc()  
{  
  string item;  
  
  getValue("trans_art", "text", item);  
  if (item == "undefined")          return 640;  
  else if (item == "int 16")       	return 643;  
  else if (item == "int 32")   		return 644;  
  else if (item == "uint 16")       return 646;  
  else if (item == "byte")        	return 642;  
  else if (item == "float")        	return 645;  
  else if (item == "boolean")       return 641;  
  else                              return 640;  
}  
  
  
//////////////////////////////////////////////////////////////////////////////  
// Coding a HW-address into a PA-address  
// Return value is the PA-address  
//////////////////////////////////////////////////////////////////////////////  
string  paEncodeAddress(int subidx)  
{  
  int    typ,nr,adr;  
  string pa,trafo;  
  
  getMultiValue("pa_typ", "selectedPos", typ,  
                "pa_nr", "text", nr,  
                "pa_adr", "text", adr,  
                "trans_art", "text", trafo);  
  switch (typ)  
  {  
    case 1 : pa = "DB"; break;  
    case 2 : pa = "DX"; break;  
    case 3 : pa = "M"; break;  
    case 4 : pa = "E"; break;  
    case 5 : pa = "A"; break;  
    case 6 : pa = "T"; break;  
    case 7 : pa = "Z"; break;  
    case 8 : pa = "P"; break;  
    case 9 : pa = "Q"; break;  
    case 10: pa = "BS"; break;  
    default: return "";  
  }  
  
  // Counter, timer and sys-addr. don't know more parameters  
  if (typ == 6 || typ == 7 || typ == 10)  
    return pa + nr;;  
  
  // Appending data format. DBs have here the number and a "D" before  
  // if no bit  
  if (typ == 1 || typ == 2)  
  {  
    pa = pa + nr;  
    if (trafo != "integer8" && trafo != "unsigned8")  
      pa = pa + "D";  
  }  
  if (trafo == "integer8" || trafo == "unsigned8")  
    pa += "B";  
  else  
  if (trafo == "integer32"      || trafo == "unsigned32" ||  
      trafo == "floating point" || trafo == "BCD32")  
    pa += "D";  
  else  
  if (trafo != "bitstring")  
    pa += "W";  
  if (typ == 1 || typ == 2)  
    pa += adr;  
  else  
    pa += nr;  
  if (trafo=="bitstring")  
    pa+="."+subidx;  
  return pa;  
}  
  
//////////////////////////////////////////////////////////////////////////////  
// Functions for mue  
//////////////////////////////////////////////////////////////////////////////  
bool paInterpretReference(string reference,int subindex,int &mode,int &datatype,  
                        int &plc,int &comp,int &rack,int &slot,  
                        int &cbase,int &cfactor,int &ctime,  
                        int &ibase,int &ifactor,float &itime,int &icommand,  
                        int &smooth,int &flutter)  
{  
  int        i,impulse;  
  string     s=substr(reference,2),param;  
  dyn_int    db,  
             d_cbase=makeDynInt(1,2,3,4,30,60,120,180,300,900,1800,3600,7200,10800,18000),  
             d_ibase=makeDynInt(50,500,1000,10000);  
  dyn_string ds=strsplit(s,".");  
  
  if (dynlen(ds)!=4)  
    return false;  
  
  plc = ds[1];  
  comp=ds[2];  
  rack=ds[3];  
  s   =ds[4];  
  ds=strsplit(s,":");  
  slot=ds[1];  
  param=ds[2];  
  impulse=ds[3];  
  icommand=(impulse>0);  
  db=hexcharToBits(param[1]);  
  datatype=db[1];  
  flutter =db[2];  
  mode    =db[3]*2+db[4];  
  db=hexcharToBits(param[2]);  
  smooth=0; cbase=1; cfactor=1;  
  if (datatype && mode==2)  
    smooth+=db[1]+db[2]+db[3]+db[4];  
  if (mode==1)  
    cbase=db[1]*8+db[2]*4+db[3]*2+db[4];  
  db=hexcharToBits(param[3]);  
  if (datatype && mode==2)  
    smooth+=db[1]+db[2]+db[3]+db[4];  
  if (mode==1)  
    cfactor=db[1]*8+db[2]*4+db[3]*2+db[4];  
  ctime=cfactor*d_cbase[cbase];  
  paGetImpulse(impulse,ibase,ifactor,itime);  
  return true;  
}  
  
paSetReference(string &reference,int subindex,int mode,int datatype,  
             int plc,int comp,int rack,int slot,  
             int cbase,int cfactor,int &ctime,  
             int ibase,int ifactor,float &itime,int icommand,  
             int smooth,int flutter)  
{  
  int        i;  
  string     s,ref;  
  dyn_int    di=makeDynInt(50,500,1000,10000),  
             dc=makeDynInt(1,2,3,4,30,60,120,180,300,900,1800,3600,7200,10800,18000);  
  dyn_string ds=makeDynString("01","03","07","0F",  
                              "1F","3F","7F","FF");  
  
  ctime=cfactor*dc[cbase];  
  itime=1.0/1000*ifactor*di[ibase];  
  
  // Robert Stockinger 24.11.98 EA mit in den Parameter codieren  
  if( mode < 3 ) ref = "E";  
  else           ref = "A";  
  
  if (datatype) ref+="I"; else ref+="B";   // Robert Stockinger 24.11.98 EA mit in den Parameter codieren  
  sprintf(s,"%d",plc);  
  ref+=s+".";  
  sprintf(s,"%d",comp);  
  ref+=s+".";  
  sprintf(s,"%d",rack);  
  ref+=s+".";  
  sprintf(s,"%d",slot);  
  ref+=s+":8";  
  if (!datatype && mode<3)  
    s=intToHexchar(8*datatype+4*flutter+mode);  
  else  
    s=intToHexchar(8*datatype+mode);  
  ref+=s;  
  if (mode==1)  
  {  
    s=intToHexchar(cbase);  
    ref+=s;  
    s=intToHexchar(cfactor);  
    ref+=s;  
  }  
  else  
  if (datatype && mode==2)  
  {  
    if (smooth>0)  
      ref+=ds[smooth];  
    else  
      ref+="00";  
  }  
  else  
  {  
    ref+="00";  
  }  
  ref+=":";  
  if (!datatype && mode==3)  
  {  
    if (icommand)  
    {  
      sprintf(s,"%d",ifactor*di[ibase]);  
      ref+=s;  
    }  
    else  
    {  
      ref+="0";  
    }  
  }  
  else  
  {  
    ref+="0";  
  }  
  reference=ref;  
}  
  
paSetMuehbusPanel(string reference,int subindex,int mode,int datatype,  
                int plc,int comp,int rack,int slot,  
                int cbase,int cfactor,int ctime,  
                int ibase,int ifactor,float itime,int icommand,  
                int smooth,int flutter,int treiber, bool active)  
{  
  setMultiValue("cboAddressActive","state",0,active,
                "flutter_1","visible",(!datatype && mode<3),  
                "flutter_txt","visible",(!datatype && mode<3),  
                "flutter","visible",(!datatype && mode<3),  
                "smooth_1","visible",(datatype && mode==2),  
                "smooth_txt","visible",(datatype && mode==2),  
                "smooth","visible",(datatype && mode==2),  
                "impulse_txt","visible",(!datatype && mode==3 && icommand),  
                "icycle_1","visible",(!datatype && mode==3 && icommand),  
                "icommand","visible",(!datatype && mode==3),  
                "ibase_txt","visible",(!datatype && mode==3 && icommand),  
                "ifactor_txt","visible",(!datatype && mode==3 && icommand),  
                "itime_txt","visible",(!datatype && mode==3 && icommand),  
                "ibase","visible",(!datatype && mode==3 && icommand),  
                "ifactor","visible",(!datatype && mode==3 && icommand),  
                "itime","visible",(!datatype && mode==3 && icommand),  
                "iunit","visible",(!datatype && mode==3 && icommand),  
                "cycle_txt","visible",(mode==1),  
                "ccycle_1","visible",(mode==1),  
                "cbase_txt","visible",(mode==1),  
                "cfactor_txt","visible",(mode==1),  
                "ctime_txt","visible",(mode==1),  
                "cbase","visible",(mode==1),  
                "cfactor","visible",(mode==1),  
                "ctime","visible",(mode==1),  
                "cunit","visible",(mode==1),  
                "reference","text",reference,  
                "subindex","text",subindex,  
                "mode","number",mode,  
                "datatype","number",datatype,  
                "plc","text",plc,  
                "comp","text",comp,  
                "rack","text",rack,  
                "slot","text",slot,  
                "cbase","selectedPos",cbase,  
                "cfactor","text",cfactor,  
                "ctime","text",ctime,  
                "ibase","selectedPos",ibase,  
                "ifactor","text",ifactor,  
                "itime","text",itime,  
                "icommand","state",0,icommand,  
                "smooth","text",smooth,  
                "flutter","number",flutter,
                "Treiber", "text", treiber);  
}  
  
// Hex into char-format (for Example "D" ==> bitstring "1101")  
dyn_bool hexcharToBits(char ch)  
{  
  dyn_bool   db=makeDynBool(false,false,false,false);  
  dyn_char   dc=makeDynChar(  "0",       "1",       "2",       "3",  
                              "4",       "5",       "6",       "7",  
                              "8",       "9",       "A",       "B",  
                              "C",       "D",       "E",       "F");  
  dyn_string ds=makeDynString("0|0|0|0", "0|0|0|1", "0|0|1|0", "0|0|1|1",  
                              "0|1|0|0", "0|1|0|1", "0|1|1|0", "0|1|1|1",  
                              "1|0|0|0", "1|0|0|1", "1|0|1|0", "1|0|1|1",  
                              "1|1|0|0", "1|1|0|1", "1|1|1|0", "1|1|1|1");  
  int        pos=dynContains(dc,ch);  
  if (pos>0)  
    db=strsplit(ds[pos],"|");  
  return db;  
}  
  
// Bitstring of format char into hex-format (z.B. 11 ==> "D")  
char intToHexchar(int i)  
{  
  dyn_char   dc=makeDynChar("0","1","2","3",  
                            "4","5","6","7",  
                            "8","9","A","B",  
                            "C","D","E","F");  
  return dc[i+1];  
}  
  
paGetImpulse(int impulse,int &ibase,int &ifactor,float &itime)  
{  
  dyn_int di=makeDynInt(50,500,1000,10000);  
  
  if (impulse<500)   ibase=1;  
  else  
  if (impulse<1000)  ibase=2;  
  else  
  if (impulse<10000) ibase=3;  
  else               ibase=4;  
  
  ifactor=impulse/di[ibase];  
  itime=1.0/1000*impulse;  
}  
  
paSetImpulse(int &impulse,int ibase,int ifactor,float &itime)  
{  
  dyn_int di=makeDynInt(50,500,1000,10000);  
  
  impulse=di[ibase]*ifactor;  
  itime=1.0/1000*impulse;  
}  
  
strReplaceChars(string &st,int pos,int num,string new)  
{  
  string s=st;  
  
  if (pos<0 || pos >=strlen(s) || pos+num>strlen(s))  
    return;  
  st=substr(s,0,pos)+new+substr(s,pos+num,strlen(s)-pos-num);  
}  
   
//////////////////////////////////////////////////////////////////////////////  
// Functions for ssi  
//////////////////////////////////////////////////////////////////////////////  
paShowReference(string r)  
{    
  dyn_string x = makeDynString("","","","","","");  
  int i, j;  
    
  j=1; x[j]="";  
  for (i=0; i<=strlen(r) && j<=6; i++)  
  {  
    if (r[i]==".") j++;  
    else           x[j]=x[j]+r[i];  
  }  
  setMultiValue(  
    "var_name","text",r,  
    "var_da","text", x[1], // Datenart  
    "var_rg","text", x[2], // Region  
    "var_ko","text", x[3], // Komponente  
    "var_bg","text", x[4], // Baugruppe  
    "var_we","text", x[5], // Wert  
    "var_sa","text", x[6]  // Subadresse  
  );  
}  

//////////////////////////////////////////////////////////////////////////////  
// Functions for iec  
//////////////////////////////////////////////////////////////////////////////  
paShowReference_iec(string r)  
{    
  dyn_string x = makeDynString("","","","","","");  
  int i, j;
  string datart;  
    
  j=1; x[j]="";  
  for (i=0; i<=strlen(r) && j<=6; i++)  
  {  
    if (r[i]==".") j++;  
    else           x[j]=x[j]+r[i];  
  }
 
  datart=x[1];
  if ( (i=strpos(datart, ":")) >= 0 )
  {
    datart=substr(x[1],i+1);    
    x[1]=substr(x[1],0,i);
  }
  else
  {
    datart="";
  }
 
  setMultiValue(  
    "var_name","text",r,  
    "var_da",  "text", x[1],    // Datenart  
    "var_rg",  "text", x[2],    // Region  
    "var_ko",  "text", x[3],    // Komponente  
    "var_bg",  "text", x[4],    // Baugruppe  
    "var_we",  "text", x[5],    // Wert  
    "var_sa",  "text", x[6],    // Subadresse  
    "var_qu",  "text", datart,  //Qualitätsinfo
    "iectext", "text", _iecDaToString(x[1])
  );  
}  
  
// Return values:  
// return[1][1]... Designation of the data format  
// return[2]   ... Index-list  
// return[3]   ... SSI-Designation-list  
// return[4]   ... PVSSII-type-list  
dyn_dyn_string _ssi_getTelegramList(int df)     // List for data format "df"  
{  
  int            bez=1,idx=2,ssi=3,typ=4,i;  
  string         t_int      = "integer",  
                 t_unsigned = "unsigned integer",  
                 t_float    = "float",  
                 t_string   = "text",  
                 t_bool     = "bit",  
                 t_char     ,  
                 t_bitm     ;  
  dyn_dyn_string li;  
  
 
  t_char     = paGetCatStr("para","BP");  
  t_bitm     = paGetCatStr("para","BP");
 
 
  switch ( df )  
  {  
    case -1:       
      li[bez][1]=paGetCatStr("para","ND");  
      i=1; li[idx][i]="?";          li[ssi][i]="?";     li[typ][i]="?";  
      break;  
    case 0: case 100:  
      li[bez][1]=paGetCatStr("para","ST");  
      i=1; li[idx][i]="?";          li[ssi][i]="?";     li[typ][i]="?";  
      break;  
    case 1: case 101:  
      li[bez][1]= paGetCatStr("para","DV") + " unsigned 32Bit";  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","DV") +" unsigned 32Bit";     li[typ][i]=t_unsigned;  
      break;  
    case 2: case 102:  
      li[bez][1]=paGetCatStr("para","DV") +" signed 32Bit";  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","DV") +" signed 32Bit";       li[typ][i]=t_int;  
      break;   
    case 3: case 103:  
      li[bez][1]=paGetCatStr("para","TS") +" (digital)";  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","TP") ;                  li[typ][i]=t_char;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","FB") ;                  li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","CM") ;                  li[typ][i]=t_bool;  
      break;   
    case 4: case 104:   
      li[bez][1]="Floating Point";  
      i=1; li[idx][i]="0";          li[ssi][i]="floating point " + paGetCatStr("para","VA") ;            li[typ][i]=t_char;  
      break;   
    case 5: case 105:  
      li[bez][1]=paGetCatStr("para","GT") ;  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","MV") ;                   li[typ][i]=t_int;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","LIM") +" LI0";           li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","LIM") +" LI1";           li[typ][i]=t_bool;  
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","LIM") +" LI2";           li[typ][i]=t_bool;  
      i++; li[idx][i]="4";          li[ssi][i]=paGetCatStr("para","LIM") +" LI3";           li[typ][i]=t_bool;  
      i++; li[idx][i]="5";          li[ssi][i]=paGetCatStr("para","GRD") +" GR0";           li[typ][i]=t_bool;  
      i++; li[idx][i]="6";          li[ssi][i]=paGetCatStr("para","GRD") +" GR1";           li[typ][i]=t_bool;  
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","MV");                    li[typ][i]=t_int;  
      i++; li[idx][i]="11";         li[ssi][i]=paGetCatStr("para","LIM");                   li[typ][i]=t_bitm;  
      i++; li[idx][i]="12";         li[ssi][i]=paGetCatStr("para","GRD");                   li[typ][i]=t_bitm;  
      i++; li[idx][i]="20";         li[ssi][i]=paGetCatStr("para","MV");                    li[typ][i]=t_int;  
      i++; li[idx][i]="21";         li[ssi][i]=paGetCatStr("para","LG");                    li[typ][i]=t_bitm;  
      break;   
    case 6: case 106:  
      li[bez][1]=paGetCatStr("para","RK");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","TD");                    li[typ][i]=t_string;  
      break;        
    case 7: case 107:  
      li[bez][1]="String";  
      i=1; li[idx][i]="0";          li[ssi][i]="String ("+paGetCatStr("para","LIM")+")";    li[typ][i]=t_string;   
      break;   
    case 8: case 108:  
      li[bez][1]=paGetCatStr("para","TD");;  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","TD");                    li[typ][i]=t_string;    
      break;            
    case 9: case 109:  
      li[bez][1]="16 "+paGetCatStr("para","SM");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","ME")+" 0";               li[typ][i]=t_bool;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","ME")+" 1";               li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","ME")+" 2";               li[typ][i]=t_bool;  
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","ME")+" 3";               li[typ][i]=t_bool;  
      i++; li[idx][i]="4";          li[ssi][i]=paGetCatStr("para","ME")+" 4";               li[typ][i]=t_bool;  
      i++; li[idx][i]="5";          li[ssi][i]=paGetCatStr("para","ME")+" 5";               li[typ][i]=t_bool;  
      i++; li[idx][i]="6";          li[ssi][i]=paGetCatStr("para","ME")+" 6";               li[typ][i]=t_bool;  
      i++; li[idx][i]="7";          li[ssi][i]=paGetCatStr("para","ME")+" 7";               li[typ][i]=t_bool;  
      i++; li[idx][i]="8";          li[ssi][i]=paGetCatStr("para","ME")+" 8";               li[typ][i]=t_bool;  
      i++; li[idx][i]="9";          li[ssi][i]=paGetCatStr("para","ME")+" 9";               li[typ][i]=t_bool;  
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","ME")+" 10";              li[typ][i]=t_bool;  
      i++; li[idx][i]="11";         li[ssi][i]=paGetCatStr("para","ME")+" 11";              li[typ][i]=t_bool;        
      i++; li[idx][i]="12";         li[ssi][i]=paGetCatStr("para","ME")+" 12";              li[typ][i]=t_bool;        
      i++; li[idx][i]="13";         li[ssi][i]=paGetCatStr("para","ME")+" 13";              li[typ][i]=t_bool;        
      i++; li[idx][i]="14";         li[ssi][i]=paGetCatStr("para","ME")+" 14";              li[typ][i]=t_bool;        
      i++; li[idx][i]="15";         li[ssi][i]=paGetCatStr("para","ME")+" 15";              li[typ][i]=t_bool;        
      i++; li[idx][i]="20";         li[ssi][i]=paGetCatStr("para","ALL");                   li[typ][i]=t_bitm;   
      break;       
    case 10: case 110:  
      li[bez][1]="8 "+paGetCatStr("para","DM");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","ME")+" Z0";              li[typ][i]=t_bool;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","ME")+" D0";              li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","ME")+" Z1";              li[typ][i]=t_bool;  
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","ME")+" D1";              li[typ][i]=t_bool;  
      i++; li[idx][i]="4";          li[ssi][i]=paGetCatStr("para","ME")+" Z2";              li[typ][i]=t_bool;  
      i++; li[idx][i]="5";          li[ssi][i]=paGetCatStr("para","ME")+" D2";              li[typ][i]=t_bool;  
      i++; li[idx][i]="6";          li[ssi][i]=paGetCatStr("para","ME")+" Z3";              li[typ][i]=t_bool;  
      i++; li[idx][i]="7";          li[ssi][i]=paGetCatStr("para","ME")+" D3";              li[typ][i]=t_bool;       
      i++; li[idx][i]="8";          li[ssi][i]=paGetCatStr("para","ME")+" Z4";              li[typ][i]=t_bool;  
      i++; li[idx][i]="9";          li[ssi][i]=paGetCatStr("para","ME")+" D4";              li[typ][i]=t_bool;  
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","ME")+" Z5";              li[typ][i]=t_bool;  
      i++; li[idx][i]="11";         li[ssi][i]=paGetCatStr("para","ME")+" D5";              li[typ][i]=t_bool;        
      i++; li[idx][i]="12";         li[ssi][i]=paGetCatStr("para","ME")+" Z6";              li[typ][i]=t_bool;        
      i++; li[idx][i]="13";         li[ssi][i]=paGetCatStr("para","ME")+" D6";              li[typ][i]=t_bool;        
      i++; li[idx][i]="14";         li[ssi][i]=paGetCatStr("para","ME")+" Z7";              li[typ][i]=t_bool;        
      i++; li[idx][i]="15";         li[ssi][i]=paGetCatStr("para","ME")+" D7";              li[typ][i]=t_bool;     
      i++; li[idx][i]="20";         li[ssi][i]=paGetCatStr("para","ME")+" 0";               li[typ][i]=t_bitm;  
      i++; li[idx][i]="21";         li[ssi][i]=paGetCatStr("para","ME")+" 1";               li[typ][i]=t_bitm;  
      i++; li[idx][i]="22";         li[ssi][i]=paGetCatStr("para","ME")+" 2";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="23";         li[ssi][i]=paGetCatStr("para","ME")+" 3";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="24";         li[ssi][i]=paGetCatStr("para","ME")+" 4";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="25";         li[ssi][i]=paGetCatStr("para","ME")+" 5";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="26";         li[ssi][i]=paGetCatStr("para","ME")+" 6";               li[typ][i]=t_bitm;              
      i++; li[idx][i]="27";         li[ssi][i]=paGetCatStr("para","ME")+" 7";               li[typ][i]=t_bitm;              
      i++; li[idx][i]="30";         li[ssi][i]=paGetCatStr("para","ALL");                   li[typ][i]=t_bitm;   
      break;  
    case 11: case 111:  
      li[bez][1]="4 "+paGetCatStr("para","DF");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","ME")+" Z0";              li[typ][i]=t_bool;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","ME")+" D0";              li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","ME")+" SF0";             li[typ][i]=t_bool;  
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","ME")+" SL0";             li[typ][i]=t_bool;  
      i++; li[idx][i]="4";          li[ssi][i]=paGetCatStr("para","ME")+" Z1";              li[typ][i]=t_bool;  
      i++; li[idx][i]="5";          li[ssi][i]=paGetCatStr("para","ME")+" D1";              li[typ][i]=t_bool;  
      i++; li[idx][i]="6";          li[ssi][i]=paGetCatStr("para","ME")+" SF1";             li[typ][i]=t_bool;  
      i++; li[idx][i]="7";          li[ssi][i]=paGetCatStr("para","ME")+" SL1";             li[typ][i]=t_bool;       
      i++; li[idx][i]="8";          li[ssi][i]=paGetCatStr("para","ME")+" Z2";              li[typ][i]=t_bool;  
      i++; li[idx][i]="9";          li[ssi][i]=paGetCatStr("para","ME")+" D2";              li[typ][i]=t_bool;  
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","ME")+" SF2";             li[typ][i]=t_bool;  
      i++; li[idx][i]="11";         li[ssi][i]=paGetCatStr("para","ME")+" SL2";             li[typ][i]=t_bool;        
      i++; li[idx][i]="12";         li[ssi][i]=paGetCatStr("para","ME")+" Z3";              li[typ][i]=t_bool;        
      i++; li[idx][i]="13";         li[ssi][i]=paGetCatStr("para","ME")+" D3";              li[typ][i]=t_bool;        
      i++; li[idx][i]="14";         li[ssi][i]=paGetCatStr("para","ME")+" SF3";             li[typ][i]=t_bool;        
      i++; li[idx][i]="15";         li[ssi][i]=paGetCatStr("para","ME")+" SL3";             li[typ][i]=t_bool;     
      i++; li[idx][i]="20";         li[ssi][i]=paGetCatStr("para","ME")+" 0";               li[typ][i]=t_bitm;  
      i++; li[idx][i]="21";         li[ssi][i]=paGetCatStr("para","ME")+" 1";               li[typ][i]=t_bitm;  
      i++; li[idx][i]="22";         li[ssi][i]=paGetCatStr("para","ME")+" 2";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="23";         li[ssi][i]=paGetCatStr("para","ME")+" 3";               li[typ][i]=t_bitm;        
      i++; li[idx][i]="30";         li[ssi][i]=paGetCatStr("para","ALL");                   li[typ][i]=t_bitm;  
      break;                            
    case 12: case 112:  
      li[bez][1]="1 "+paGetCatStr("para","SMD");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","ME")+" Z";               li[typ][i]=t_bool;  
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","ME")+" D";               li[typ][i]=t_bool;  
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","ME")+" SF";              li[typ][i]=t_bool;  
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","ME")+" SL";              li[typ][i]=t_bool;  
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","TM");                    li[typ][i]=t_bitm;  
      break;  
    case 13: case 113:  
      li[bez][1]=paGetCatStr("para","CD");  
      i=1; li[idx][i]="0";          li[ssi][i]=paGetCatStr("para","CD")+" 0";               li[typ][i]=t_bool;   
      i++; li[idx][i]="1";          li[ssi][i]=paGetCatStr("para","CD")+" 1";               li[typ][i]=t_bool;   
      i++; li[idx][i]="2";          li[ssi][i]=paGetCatStr("para","CD")+" 2";               li[typ][i]=t_bool;   
      i++; li[idx][i]="3";          li[ssi][i]=paGetCatStr("para","CD")+" 3";               li[typ][i]=t_bool;   
      i++; li[idx][i]="4";          li[ssi][i]=paGetCatStr("para","CD")+" 4";               li[typ][i]=t_bool;   
      i++; li[idx][i]="5";          li[ssi][i]=paGetCatStr("para","CD")+" 5";               li[typ][i]=t_bool;   
      i++; li[idx][i]="6";          li[ssi][i]=paGetCatStr("para","CD")+" 6";               li[typ][i]=t_bool;   
      i++; li[idx][i]="7";          li[ssi][i]=paGetCatStr("para","CD")+" 7";               li[typ][i]=t_bool;   
      i++; li[idx][i]="8";          li[ssi][i]=paGetCatStr("para","CD")+" 8";               li[typ][i]=t_bool;   
      i++; li[idx][i]="9";          li[ssi][i]=paGetCatStr("para","CD")+" 9";               li[typ][i]=t_bool;   
      i++; li[idx][i]="10";         li[ssi][i]=paGetCatStr("para","CD")+" 10";              li[typ][i]=t_bool;   
      i++; li[idx][i]="11";         li[ssi][i]=paGetCatStr("para","CD")+" 11";              li[typ][i]=t_bool;   
      i++; li[idx][i]="12";         li[ssi][i]=paGetCatStr("para","CD")+" 12";              li[typ][i]=t_bool;   
      i++; li[idx][i]="13";         li[ssi][i]=paGetCatStr("para","CD")+" 13";              li[typ][i]=t_bool;   
      i++; li[idx][i]="14";         li[ssi][i]=paGetCatStr("para","CD")+" 14";              li[typ][i]=t_bool;   
      i++; li[idx][i]="15";         li[ssi][i]=paGetCatStr("para","CD")+" 15";              li[typ][i]=t_bool;   
      i++; li[idx][i]="20";         li[ssi][i]=paGetCatStr("para","TI");                    li[typ][i]=t_unsigned;   
      i++; li[idx][i]="21";         li[ssi][i]=paGetCatStr("para","FA");                    li[typ][i]=t_unsigned;   
      i++; li[idx][i]="22";         li[ssi][i]=paGetCatStr("para","OW");                    li[typ][i]=t_bool;    
      break;            
    default:  
      li[bez][1]="?";  
      i=1; li[idx][i]="?";          li[ssi][i]="?";                              li[typ][i]="?";  
  }  
  if ( df > 100 && li[bez][1] != "?" ) li[bez][1]= paGetCatStr("para","RT")+" - "+li[bez][1];  
  
  return li;  
}  
  
dyn_string _ssi_getTelegram(int df,   // Data format  
                            int ix)   // Index  
{  
  int            bez=1,idx=2,ssi=3,typ=4,gef;  
  string         s_ix=ix;  
  dyn_string     ret;  
  dyn_dyn_string li;  
  
  li=_ssi_getTelegramList(df);  
  if ( gef=dynContains(li[idx], s_ix) )  
  {  
    ret[1]="";  
    ret[2]=li[ssi][gef];  
    ret[3]=li[typ][gef];  
  }  
  else  
  {  
    ret[1]="NOTFOUND";  
    ret[2]="?";  
    ret[3]="?";  
  }  
  return ret;  
}  
  
_ssi_zeige_subindex()  
{  
  int        da,df,subidx,datart,i;  
  string     datart_s,bez,typ;  
  dyn_string tele;  
    
  // Subindex, art of data  
  getMultiValue("subindex", "text", subidx,  
                "var_da", "text", datart_s);  
  if ( (i=strpos(datart_s, ":")) >= 0 )  
    datart_s=substr(datart_s, 0, i);  
  sscanf(datart_s, "%d", datart);  
  // Data format  
  dpGet("_SSI_DaDf_Table.Da_"+datart+":_online.._value", df);  
  tele= _ssi_getTelegram(df, subidx);  
  bez=tele[2];  
  typ=tele[3];  
  setMultiValue("subindex_ssitext", "text", bez,  
                "subindex_pvsstyp", "text", typ);  
}
 
 
// Convert IEC-Typeident to _address.._datatype
int  _iecConvertDaToType(int da)
{
  switch (da)
  {
    // IEC-Monitor
    case 1 :   // M_SP_NA_1
    case 2 :   // M_SP_TA_1
	  case 30 :  // M_SP_TB_1
      return 521; // SIQ
    case 3 :   // M_DP_NA_1
    case 4 :   // M_DP_TA_1
	  case 31 :  // M_DP_TB_1
      return 522; // DIQ
    case 5 :   // M_ST_NA_1
    case 6 :   // M_ST_TA_1
	  case 32 :  // M_ST_TB_1
      return 523; // VTI
    case 7 :   // M_BO_NA_1
    case 8 :   // M_BO_TA_1
	  case 33 :  // M_BO_TB_1
      return 531; // BSI
    case 9 :   // M_ME_NA_1
    case 10 :  // M_ME_TA_1
	  case 34 :  // M_ME_TD_1
      return 524; // NVA
    case 11 :  // M_ME_NB_1
    case 12 :  // M_ME_TB_1
	  case 35 :  // M_ME_TE_1
      return 525; // SVA
    case 13 :  // M_ME_NC_1
    case 14 :  // M_ME_TC_1
	  case 36 :  // M_ME_TF_1
      return 526; // R32
    case 15 :  // M_IT_NA_1
    case 16 :  // M_IT_TA_1
	  case 37 :  // M_IT_TB_1
      return 527; // BCR
    case 17 :  // M_EP_TA_1
	  case 38 :  // M_EP_TD_1
      return 528; // SEP
    case 18 :  // M_EP_TB_1
	  case 39 :  // M_EP_TE_1
      return 529; // SPE
    case 19 :  // M_EP_TC_1
	  case 40 :  // M_EP_TF_1
      return 530; // OCI
    case 20 :  // M_PS_NA_1
      return 531; // BSI preliminarry
      // return 535; // SCD
    case 21 :  // M_ME_ND_1
      return 524; // NVA
    
	// IEC Command
    case 45 :  // C_SC_NA_1
	  case 58 :  // C_SC_TA_1
      return 532; // SCO
    case 46 :  // C_DC_NA_1
	  case 59 :  // C_DC_TA_1
      return 533; // DCO
    case 47 :  // C_RC_NA_1
	  case 60 :  // C_RC_TA_1
      return 534; // RCO
    case 48 :  // C_SE_NA_1
	  case 61 :  // C_SE_TA_1
      return 524; // NVA
    case 49 :  // C_SE_NB_1
	  case 62 :  // C_SE_TA_1
      return 525; // SVA
    case 50 :  // C_SE_NC_1
	  case 63 :  // C_SE_TC_1
      return 526; // R32
    case 51 :  // C_BO_NA_1
	  case 64 :  // C_BO_TA_1
      return 531; // BSI
 
    // IEC End of Init
	  case 70 :  // M_EI_NA_1
	    return 536; // Empty
 
    // IEC Spezialtelegramme
	  case 100 : // C_IC_NA_1
	  case 101 : // C_CI_NA_1
	    return 539; // Interrogation
	  case 102 : // C_RD_NA_1
	    return 538; // Empty
	  case 103 : // C_CS_NA_1
	    return 543; // CP56
	  case 104 : // C_TS_NA_1
	  case 107 : // C_TS_TA_1
	    return 540; // FBP
	  case 105 : // C_RP_NA_1
	    return 529; // Interrogation
	  case 106 : // C_CD_NA_1
	    return 541; // CP16
 
    // IEC Parametrierung
	  case 110 : // P_ME_NA_1
	    return 524; // NVA
	  case 111 : // P_ME_NB_1
	    return 525; // SVA
	  case 112 : // P_MB_NC_1
	    return 526; // R32
	  case 113 : // P_AC_NA_1
	    return 538; // Empty
 
	  // SSI-Typen
	  case 135 : // SSI System
	    return 537; // Private, Blob
	  case 136 : // DF12, 1 Doppelmeldung
	    return 50; // SsiTrans1DoubleIndType
	  case 137 : // DF09, 16 Einzelmeldungen
	    return 47; // SsiTransSingleAlarmsType
	  case 138 : // DF10, 8 Doppelmeldungen
	    return 48; // SsiTrans8DoubleIndType
	  case 139 : // DF11, 4 Doppelmeldungen
	    return 49; // SsiTrans4DoubleIndType
	  case 140 : // DF02, signed int
	    return 42; // SsiTransSignedInt32Type
	  case 141 : // DF16, Bitmuster 16 Bit / Transparente Daten
	    return 47; // SsiTransSingleAlarmsType (passt am besten)
	  case 142 : // DF06, Nutzdaten
	    return 52; // SsiTransStrTranspType
	  case 143 : // DF100
	    return 537; // Private, Blob
	  case 160 : // DF13, Einzelbefehl
	    return 51; // SsiTransBinaryCommandType
 
    default :
      return 520;
  }
}   
 
string  _iecDaToString(int da)
{
  string sText;
 
  sText = getCatStr("iec", da);
 
  if (strlen(sText) >= 14)
    if (substr(sText,0,14) == "catgets error:") sText = getCatStr("iec","notValid");
 
  return (sText);
}

//////////////////////////////////////////////////////////////////////////////  
// This function controls the error handling of all dpSet-calls  
//////////////////////////////////////////////////////////////////////////////  
paErrorHandlingOpc(string action, int error)  
{  
  bool           ok;  
  dyn_string     sPara;  
  dyn_errClass   err;    
  
  err = getLastError();  
  // check if error   
  if(dynlen(err) > 0)    
  {  
    throwError(err);  
    errorDialog(err);
  }    
}  

//////////////////////////////////////////////////////////////////////////////  
// This function sets items of OPC into Panel
//
// inserted by mhaslop: 14.10.1999 (TI 3287)
// modified by peterv:  19.11.1999 (TI 3260)
//
//////////////////////////////////////////////////////////////////////////////  
OPCworkGetItemIds(string dp,dyn_string ds)
{
string server,item;

  getValue("items","text",item);
  server = dpSubStr( dp, DPSUB_DP );
  setMultiValue("items","items",ds,
                "items","visible",true,
                "ok","enabled",true,
                "save","enabled",true,
                "direction","enabled",(dynlen(ds)<2) );
  
  setValue("items","text",item);
  
  dpDisconnect("OPCworkGetItemIds",server+".ItemIds:_online.._value");
}

//xxxx
//////////////////////////////////////////////////////////////////////////////  
// This function checks if the given dpe is from the own system
//////////////////////////////////////////////////////////////////////////////  
dpFromOwnSystem(string dpe, bool &system)
{
string dpeSystem;
int    i1,i2;

 
  dpeSystem = dpSubStr( dpe, DPSUB_SYS );
  i1 = getSystemId();
  i2 = getSystemId( dpeSystem );
  
  if( i1 == i2 )
    system = TRUE;
  else
    system = FALSE;
}
//xxxx

//////////////////////////////////////////////////////////////////////////////  
// Functions for Applicom 
//////////////////////////////////////////////////////////////////////////////
// Reading possible protocols from apc_config
//////////////////////////////////////////////////////////////////////////////  
dyn_string paReadApcDrvProtocol()
{
  int        idx = 0;
  file       fd;
  string     s;
  dyn_string dsProtocols = makeDynString(), ds;

  if ( access(getPath(CONFIG_REL_PATH,"apc_config"), R_OK) != 0 )
  {
    ChildPanelOnCentralModal("vision/MessageWarning", // config file not found or not readable
      getCatStr("para","warning"),
      makeDynString(getCatStr("para","apc_noconfigfile")));
    return(dsProtocols);
  }
  fd = fopen(getPath(CONFIG_REL_PATH,"apc_config"), "r");
  while ( !feof(fd) && strpos(s, "[PROTOCOL") != 0 ) // searching for [PROTOCOL] section
  {
    fgets(s, 65535, fd);
  }
  if ( feof(fd) )
  {
    ChildPanelOnCentralModal("vision/MessageWarning", // configs not found
      getCatStr("para","warning"),
      makeDynString(getCatStr("para","apc_noprotocol")));
    fclose(fd);
    return(dsProtocols);
  }
  s = "";
  while ( !feof(fd) && strpos(s, "[") != 0 ) // reading protocols
  {
    fgets(s, 65535, fd);
    if ( strpos(s, "[") != 0 )
    {
      ds = strsplit(s, "=");
      if ( dynlen(ds) == 2 )
      {
        idx = ds[2]; idx++;
        if ( dynlen(dsProtocols) < idx || dsProtocols[idx] == "" )
          dsProtocols[idx] = ds[1];
      }
    }
  }
  fclose(fd);
  return(dsProtocols);
}

//////////////////////////////////////////////////////////////////////////////  
paSetApcDrv( int iDirection )
{
  int        iPos = 0, i;
  string     s = var_name.text;
  dyn_int    dii;
  dyn_string ds = strsplit(s, "."), dss;
  
  setMultiValue("tm","visible",(iDirection>1),   
                "border1","visible",(iDirection>1),   
                "modus","visible",(iDirection>1),   
                "lowlevel","visible",(iDirection>1));
  if (iDirection==4)
  {
    setMultiValue("tp","visible",true,
                  "txtstz", "visible", true,
                  "syncmod", "visible", true,
                  "border2","visible", true, 
                  "border3","visible", true, 
                  "stastu", "visible", true,
                  "stamin", "visible", true,
                  "txtstd", "visible", true,
                  "txtmin", "visible", true);
    getValue("syncmod","number",i);
    if (i<2)
    {
      setMultiValue("synchelp", "visible", (i==1),
                    "statag", "visible", true,
                    "txttag", "visible", true);
    }
    else
    {
      setMultiValue("synchelp", "visible", false,
                    "statag", "visible", false,
                    "txttag", "visible", false);
    }
    setValue("poll_zeit","visible",true);
  }
  else
  {
    setMultiValue("tp","visible",false,
                  "txtstz", "visible", false,
                  "syncmod", "visible", false,
                  "border2","visible",false, 
                  "border3","visible",false, 
                  "synchelp", "visible", false,
                  "stastu", "visible", false,
                  "stamin", "visible", false,
                  "txtstd", "visible", false,
                  "txtmin", "visible", false,
                  "statag", "visible", false,
                  "txttag", "visible", false,
                  "poll_zeit","visible",false);
  }
}

//////////////////////////////////////////////////////////////////////////////  
// Functions for TLS driver 
//////////////////////////////////////////////////////////////////////////////
tlsSetPollingValues(int modus,time startzeit,int lowlevel,int intern)  
{  
  int        i,ta,st,mi,wert,  
             OF_MONTH = 2678400,OF_WEEK = 604800,OF_DAY = 86400;  
  dyn_string ds_month,ds_week;  
  
  for (i=1;i<=7;i++) ds_week[i]=paGetCatStr("para","weekday"+i);
  for (i=1;i<=31;i++) ds_month[i]=i;
  
  wert=period(startzeit);   
  if (modus==1 || modus==5)
  {   
    setMultiValue("tm","visible",false,   
                  "lowlevel","visible",false,   
                  "modus","visible",false,   
                  "border1","visible",false,   
                  "tp","visible",false,   
                  "txtstz", "visible", false,   
                  "txttag", "visible", false,   
                  "txtstd", "visible", false,   
                  "txtmin", "visible", false,   
                  "syncmod", "visible", false,   
                  "border2","visible",false,   
                  "border3","visible",false,   
                  "synchelp", "visible", false,   
                  "statag", "items", ds_month,   
                  "statag", "visible", false,   
                  "stastu", "visible", false,   
                  "stamin", "visible", false,   
                  "lowlevel", "state", 0,lowlevel,   
                  "poll_zeit","visible",false,  
                  "einaus","number",0);  
  }   
  else   
  {   
    setMultiValue("einaus","number",1,   
                  "modus","number",modus,   
                  "modus","visible",true,   
                  "border1","visible",true,   
                  "lowlevel","visible",true,   
                  "lowlevel", "state", 0,lowlevel,   
                  "tm","visible",true);   
    if ( modus == 4 )   //polling
    {  
      if (wert>=OF_MONTH)   
      {   
        setMultiValue("syncmod","number",0,   
                      "txttag","visible",true,   
                      "statag","items",ds_month,   
                      "statag","visible",true,   
                      "synchelp","visible",false);   
        wert=wert-OF_MONTH;   
        ta=wert / 86400;   
        st=(wert-ta*86400) / 3600;   
        mi=(wert-ta*86400-st*3600) / 60;   
        if (ta<0) ta=0;   
        if (ta>30) ta=30;   
        ta=ta+1;   
        setMultiValue("statag","selectedPos", ta,   
                      "statag","text", ds_month[ta],   
                      "stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      if (wert>=OF_WEEK)   
      {   
        setMultiValue("syncmod","number",1,   
                      "txttag","visible",true,   
                      "statag","items",ds_week,   
                      "statag","visible",true,   
                      "synchelp","visible",true);   
        wert=wert-OF_WEEK;   
        ta=wert / 86400;   
        st=(wert-ta*86400) / 3600;   
        mi=(wert-ta*86400-st*3600) / 60;   
        if (ta<0) ta=0;   
        if (ta>6) ta=6;   
        ta=ta+1;   
        setMultiValue("statag","selectedPos", ta,   
                      "statag","text", ds_week[ta],   
                      "stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      if (wert>=OF_DAY)   
      {   
        setMultiValue("syncmod","number",2,   
                      "txttag","visible",false,   
                      "statag","visible",false,   
                      "synchelp","visible",false);   
        wert=wert-OF_DAY;   
        ta=0;   
        st=wert / 3600;   
        mi=(wert-st*3600) / 60;   
        setMultiValue("stastu","text", st,   
                      "stamin","text", mi);  
      }   
      else   
      {   
        setMultiValue("syncmod","number",3,   
                      "txttag","visible",false,   
                      "statag","visible",false,   
                      "synchelp","visible",false);   
        ta=0;   
        st=wert / 3600;   
        mi=(wert-st*3600) / 60;   
        setMultiValue("stastu","text", st,   
                      "stamin","text", mi);  
      }   
      setMultiValue("tp","visible",true,   
                    "txtstz", "visible", true,   
                    "txtstd", "visible", true,   
                    "txtmin", "visible", true,   
                    "syncmod", "visible", true,   
                    "border2","visible", true,   
                    "border3","visible", true,   
                    "stastu", "visible", true,   
                    "stamin", "visible", true,   
                    "poll_zeit","visible",true);   
    }   
    else   //modus !=1, !=5, !=4 --> Einzelabfrage
    {   
      setMultiValue("tp","visible",false,   
                    "txtstz", "visible", false,   
                    "txttag", "visible", false,   
                    "txtstd", "visible", false,   
                    "txtmin", "visible", false,   
                    "syncmod", "visible", false,   
                    "border2","visible",false,   
                    "border3","visible",false,   
                    "synchelp", "visible", false,   
                    "statag", "visible", false,   
                    "stastu", "visible", false,   
                    "stamin", "visible", false,   
                    "poll_zeit","visible",false);   
    }   
  }   
}  

//////////////////////////////////////////////////////////////////////////////  
// Functions for ??? (no more configs to parametrize)  
//////////////////////////////////////////////////////////////////////////////  
