V 10
1
LANG:1 8 (NoName)
PANEL,258 70 1000 800 N "_3DFace" 0
"/* Config & Scan Functions
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                      CONFIGURATION & SCAN CONTROL                        */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        S.G.Basiladze, Abdelouahab Abdesselam (OPC, Alert configs)

   DESIGN ISSUEs:  This script provides the Data Points loading, creating
                   OPC config file & addresses and data simulation functions

   MODIF_HISTORY:  01.03.2001 - first version
                   09.11.2002 -  2-nd version, DAQ Control is added
                   07.05.2003 -  3-rd version, DDC Control is added
                   28.09.2003 -  4-th version, Control Script is added
/*--------------------------------------------------------------------------*/
/* SYSTEM CONTROL DATAPOINTS:
                   Host.Stat  - Desirable   (new) system state;
                   Syst.Stat  - Current (and old) system state;
                   Next.Stat  - Next step in the Syst->->->Host sequence;
                   Busy.Stat  - synchronisation, is using in 2 cases
                                a) for disabling of Transition function
                                   (for instance, if Syst_Off->->Host_Mon,
                                   then Next_ConfFunction will be skipped);                                   
                                b) for waiting when Transition will be made.*/
/* ADD ALERTS PROCEDURES:
                  1) Put 'AlertClassScripts.ctl' into 'scripts/lib' folder;
                  2) Add 
[event]
LoadCtrlLibs = \"AlertClassScripts.ctl\"
                     into 'config/config'.                                  */
/* The *.Stat DataPoints bits assignment:

        DCS Mode : 0x1* - Global Control (\"on write\" - from DAQ),
                   0x2* - Local  Control (\"on event\" - control button click).

        DCS State: 0x20 – Off,          MPS State: 0x10 – Off,
                   0x24 – Configured,              0x14 - reserve (Config),
                   0x28 – Monitoring,              0x18 – Standby,
                   0x1C – DAQ control.             0x1C – On.

      Status bits:   00 - Normal        Colours  : Green[Local] or Cyan[Glob]
                     10 - Warning                  Yellow
                     01 - Alarm                    Red
                     11 - reserved (Disabled)      Gray
  ===================================-======================================*/
main()
{ int    flag, tout, int1;
  string snam, mstr, estr;

  tout = 10 * 60 * 60;               /* TimeOut is 10 hours                 */

  dpSet(\"SCTmops1:Conf.Data:_original.._value\", 0);      /* Init Config Flag*/
  delay(2);
  dpSet(\"SCTmops1:Busy.Stat:_original.._value\", 0x0);    /* Busy Resetting  */
  int1=0; flag=0; while(flag != 1)   /* Waiting for 'State' Panel Flag      */
  { delay(1);
    dpGet(\"SCTmops1:Conf.Numb:_original.._value\", flag);
    int1++; if(int1 >= tout)
    { sprintf(estr,\" TimeOut '%d sec' - PANEL FLAG Waiting \", tout);
      ErrorStop(estr,\" CHECK ERROR, PUSH EXIT [X] & RESTART \");
    }
  }
  dpGet(\"SCTmops1:Conf.Indx:_original.._value\", flag);
    if(flag == 0)
  { dpGet(\"SCTmops1:Conf.Name:_original.._value\", snam);
    sprintf(mstr,
           \" %s IS WAITING '%d sec' FOR STATE_CONTROL SCRIPT... \",snam, tout);
    setValue(\"MoniIndi\",\"text\", mstr);
  }
  int1=0;                            /* Waiting for 'State' Script Flag     */
  flag=0; while((flag != 1) && (flag != 3))
  { delay(1);
    dpGet(\"SCTmops1:Conf.Indx:_original.._value\", flag);
    int1++; if(int1 >= tout)
    { sprintf(estr,\" TimeOut '%d sec' - CONTROL SCRIPT Waiting \", tout);
      ErrorStop(estr,\" CHECK ERROR, PUSH EXIT [X] & RESTART \");
    }
  }
  dpConnect(\"SelectConfigFunction\",\"SCTmops1:Conf.Data:_original.._value\");
  dpSet(\"SCTmops1:Conf.Numb:_original.._value\", 2);
} 
/* ======================================================================== */
/*                        MAKE_CONFIGS() SUBROUTINES                        */
/* ======================================================================== */
/* CREATE THE SETTINGS FOR OPC-SERVER                                       */
/*                                                                          */
 setOPCServer(string serverName, int aliveTimer, int reconnectTimer)
 { bool connectedState;
	
     //rename serverName just the internal name form
   serverName = \"_\" + serverName;
     //create severName datapoint if it does not exist already
     if (!dpExists(serverName))
   { //create serverName datapoint of type _OPCServer (PVSS internal type)
     dpCreate(serverName, \"_OPCServer\"); 
   }
     //set some of the serverName datapoint elements
   dpSet(serverName+\".StateTimer:_original.._value\", aliveTimer);
   dpSet(serverName+\".ReconnectTimer:_original.._value\", reconnectTimer);
     //check if the PVSS OPC client is connected
   dpGet(serverName+\".Connected:_online.._value\", connectedState);
     if(!connectedState)
   { ;
//     setValue(\"CommInfo\",\"text\",\" WARNING: OPC client is not connected \");
   }
//   DebugN(\"====================== connectedState = \", connectedState);
 }

/* CREATE OPC-SERVER GROUP AND IT'S SETTINGS                                */
/*                                                                          */
 setOPCGroup(string groupName, int  nominalValue, string DataSoure,
                               bool active,       bool   enableCallBack)
 { bool DataSoureDevice;
	
     //rename groupName just the internal name form
   groupName = \"_\" + groupName;
     //create groupName datapoint if it does not already exist 
     if (!dpExists(groupName))
   { //create groupName datapoint of type _OPCGroup (PVSS internal type)
     dpCreate(groupName, \"_OPCGroup\"); 
   }
     //set some of the groupName datapoint elements
   dpSet(groupName+\".UpdateRateReq:_original.._value\", nominalValue);
     if(DataSoure == \"Device\")
   { DataSoureDevice = TRUE;
   } else
   { DataSoureDevice =FALSE;
   }
   dpSet(groupName+\".DataSourceDevice:_original.._value\", DataSoureDevice);
   dpSet(groupName+\".Active:_original.._value\", active);
   dpSet(groupName+\".EnableCallback:_original.._value\", enableCallBack);
 }

/* CREATE (IF ABSENT) AND FILL AlrL, WarL, WarH, AlrH CONFIGs OF DATA_POINT */
/*                  Priority - Prior_3 > Prior_2 > Prior_1                  */
/*                                                                          */
 setAlerts(string dpConfigName, int Priority,
           float Alarm_low, float Warn_low, float Warn_high, float Alarm_high)
 { int      alert_exist, status;
   unsigned num_ranges = 0;
   float    normal_simu;
   string   dpName, estr;
/**/
   normal_simu = (Warn_low + Warn_high) / 2.0;
   dpSet(dpConfigName, normal_simu);                               /* Debug */
   sprintf(dpName, dpConfigName);
   strreplace(dpName,\":_original.._value\",\"\");
               // test if the alert exist already
   status = dpGet(dpName + \":_alert_hdl.._type\", alert_exist);
     if(!status && !alert_exist)
   {           // set analog alert (13 means analog alerts, 12 - binary alerts)
     dpSet(dpName + \":_alert_hdl.._type\", 13,
               // set 5 ranges
     dpName + \":_alert_hdl.1._type\", 4,  // alarm   low  range
     dpName + \":_alert_hdl.2._type\", 4,  // warning low  range
     dpName + \":_alert_hdl.3._type\", 4,  // normal       range
     dpName + \":_alert_hdl.4._type\", 4,  // warning high range
     dpName + \":_alert_hdl.5._type\", 4,  // alarm   high range
               //  set each range: each range consists of two values (borders)
     dpName + \":_alert_hdl.1._u_limit\", Alarm_low, 
     dpName + \":_alert_hdl.2._l_limit\", Alarm_low, 
     dpName + \":_alert_hdl.2._u_limit\", Warn_low, 
     dpName + \":_alert_hdl.3._l_limit\", Warn_low,
     dpName + \":_alert_hdl.3._u_limit\", Warn_high,
     dpName + \":_alert_hdl.4._l_limit\", Warn_high,
     dpName + \":_alert_hdl.4._u_limit\", Alarm_high,
     dpName + \":_alert_hdl.5._l_limit\", Alarm_high,
               // set the limit of each range, look for consistency!    
     dpName + \":_alert_hdl.1._u_incl\", TRUE,  
     dpName + \":_alert_hdl.2._l_incl\", FALSE, 
     dpName + \":_alert_hdl.2._u_incl\", TRUE, 
     dpName + \":_alert_hdl.3._l_incl\", FALSE, 
     dpName + \":_alert_hdl.3._u_incl\", FALSE, 
     dpName + \":_alert_hdl.4._l_incl\", TRUE, 
     dpName + \":_alert_hdl.4._u_incl\", FALSE, 
     dpName + \":_alert_hdl.5._l_incl\", TRUE, 
               // set alert texts
     dpName + \":_alert_hdl.1._text\", \" Data is alarm Low\",  
     dpName + \":_alert_hdl.2._text\", \" Data is warn. Low\", 
     dpName + \":_alert_hdl.3._text\", \" Data is Normal\",
     dpName + \":_alert_hdl.4._text\", \" Data is warn. High\",
     dpName + \":_alert_hdl.5._text\", \" Data is alarm High\",
               // set alert class
     dpName + \":_alert_hdl.1._class\", \"Alarm_\"+Priority+\".\", 
     dpName + \":_alert_hdl.2._class\", \"Warning_\"+Priority+\".\",
     dpName + \":_alert_hdl.4._class\", \"Warning_\"+Priority+\".\",
     dpName + \":_alert_hdl.5._class\", \"Alarm_\"+Priority+\".\",
               // working with the original value
     dpName + \":_alert_hdl.._orig_hdl\", TRUE, 
               // activates the alert handling
     dpName + \":_alert_hdl.._active\", TRUE); 
   } else
   {           // get the number of  alert ranges
     dpGet(dpName + \":_alert_hdl.._num_ranges\", num_ranges);
               // make sure there are 5 ranges (the case of script)
       if(num_ranges == 5)
     {         // acknoledge the alert if any, otherwise the parameters
               // cann't be changed
       dpSet(dpName + \":_alert_hdl.._ack\", 1);
               // desactivates the alert handling
       dpSet(dpName + \":_alert_hdl.._active\", FALSE, 
               // set each range: each range consists of two values (borders)
       dpName + \":_alert_hdl.1._u_limit\", Alarm_low, 
       dpName + \":_alert_hdl.2._l_limit\", Alarm_low, 
       dpName + \":_alert_hdl.2._u_limit\", Warn_low, 
       dpName + \":_alert_hdl.3._l_limit\", Warn_low,
       dpName + \":_alert_hdl.3._u_limit\", Warn_high,
       dpName + \":_alert_hdl.4._l_limit\", Warn_high,
       dpName + \":_alert_hdl.4._u_limit\", Alarm_high,
       dpName + \":_alert_hdl.5._l_limit\", Alarm_high);
               // re-activates the alert handling
       dpSet(dpName + \":_alert_hdl.._active\", TRUE);
     } else
     { sprintf(estr,
       \" there are not 5 ranges as assumed\\n    in the alert Script \");
       dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
       dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);
//       Debug(\" ERROR in alert script: there are not 5 ranges as assumed \");
     }
   }           //end of else
 }
 
/* CHECK WHETHER OPC SDERVER IS INCLUDING AND OPC_NAME & OPC_GROUP EXIST    */
/*                                                                          */
 CheckOPCserver(string opcServerName, string OPCGroup) 
 { int    serv;
   string opc, group, estr;

               //check if OPC server exists 
   opc = getSystemName() + \"_\" + opcServerName;
     if(!dpExists(opc))
   { sprintf(estr,
\" CheckOPCserver()\\n    OPC Server '\"+opcServerName+\"' does not exist\"); 
     dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
     dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);
//     Debug(
//\" ERROR in CheckOPCserver(): OPC Server: \"+opcServerName+\" does not exist\"); 
     return;
   }	       //check if OPC group exists
   group = getSystemName() + \"_\" + OPCGroup; 
     if (!dpExists(group))
   { sprintf(estr,
     \" CheckOPCserver()\\n    OPC group '\"+OPCGroup+\"' does not exist\");
     dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
     dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);
//     Debug(\" ERROR in CheckOPCserver(); OPC group '\"+OPCGroup+\"' does not exist\");
     return;
   }
 }

/* CREATE (IF ABSENT) AND CHANGE THE CONNECTION OF OPC_ITEM TO PVSS DPe     */
/* NOTE! OPCItemName should include: PortName.UnitName.ItemName             */
/*                                                                          */
 setOPCAddress(string dpeName  , string OPCItemName  , string dpeType,
               string direction, string opcServerName, int    driverNum,
               string OPCGroup) 
 { int intDirection, intDpeType;
   string       estr, reference; 
   dyn_errClass eror; 

   strreplace(dpeName,\":_original.._value\",\"\");
/*   
   DebugN(\"=====================dpeName = \", dpeName );
   DebugN(\"=====================OPCItemName = \", OPCItemName);
   DebugN(\"=====================dpeType = \", dpeType);
   DebugN(\"=====================direction = \", direction);
   DebugN(\"=====================opcServerName = \", opcServerName);
   DebugN(\"=====================OPCGroup = \", OPCGroup);
   while(1){delay(1);}                                             /* Debug */	
               //the full OPC item address  
   reference = opcServerName + \"$\" + OPCGroup + \"$\" + OPCItemName; 
               //the direction (read or write):
     if(direction == \"OUT\" || direction == \"out\" || direction == \"Out\")
   { intDirection = DPATTR_ADDR_MODE_OUTPUT_SINGLE;
   } else if(direction == \"IN\" || direction == \"in\" || direction == \"In\")
   { intDirection = DPATTR_ADDR_MODE_INPUT_SPONT;
   }
     switch(intDirection) 
   { case DPATTR_ADDR_MODE_OUTPUT_SINGLE:    ;
     case DPATTR_ADDR_MODE_INPUT_SPONT:      ;
     case DPATTR_ADDR_MODE_INPUT_SPONT + 64: ;
     case DPATTR_ADDR_MODE_OUTPUT_SINGLE + 64:
          dpSetWait(dpeName + \":_distrib.._type\", DPCONFIG_DISTRIBUTION_INFO,
                    dpeName + \":_distrib.._driver\", driverNum);
          eror = getLastError();
            if(dynlen(eror) > 0) 
          {
//            throwError(eror);
            sprintf(estr,
            \" setOPCAddress()\\n    while creating the address config\");
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);
//            Debug(
//            \" ERROR in setOPCAddress() while creating the address config\");
          }    //find the PVSS OPC client data type:
            switch(dpeType)
          { case \"VT_UI1\":    intDpeType = 0;    break;  //uint8
            case \"VT_UI2\":    intDpeType = 488;  break;  //uint16
            case \"VT_UI4\":    intDpeType = 489;  break;  //uint32
            case \"VT_BOOL\":   intDpeType = 486;  break;  //Bool
            case \"VT_FLOAT8\": intDpeType = 485;  break;  //float64
            case \"VT_FLOAT4\": intDpeType = 484;  break;  //float32
            case \"VT_I1\":     intDpeType = 0;    break;  //int8
            case \"VT_I2\":     intDpeType = 481;	 break;  //int16
            case \"VT_I4\":     intDpeType = 482;	 break;  //int32
            case \"VT_STRING\": intDpeType = 487;  break;  //string
            case \"default\":   intDpeType = 0;    break;  //default
            default:          intDpeType = 480;  break;  //unknown
          }	   //set the address config parameters
          dpSetWait(dpeName + \":_address.._type\", DPCONFIG_PERIPH_ADDR_MAIN,
                    dpeName + \":_address.._reference\", reference,
                    dpeName + \":_address.._datatype\" , intDpeType,
                    dpeName + \":_address.._mode\"     , intDirection,
                    dpeName + \":_address.._drv_ident\", \"OPCCLIENT\");
          eror = getLastError();
            if(dynlen(eror) > 0) 
          {
//          	throwError(eror);
            sprintf(estr,
     \" setOPCAddress()\\n    while configuring the peripheral address\");
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
//            Debug(
//     \" ERROR in setOPCAddress() while configuring the peripheral address\");
          } break;
     default:  sprintf(estr,
     \" setOPCAddress()\\n    the selected mode \"+ intDirection +\" is unknown\");
              dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
              dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);
//            Debug(
//\" ERROR in setOPCAddress(); the selected mode \"+ intDirection +\" is unknown\");
            return;
   }
 } 

/* CONVERTIONs: RAW->PHYSICAL->RAW BY USING _MSG_CONV AND _CMD_CONV CONFIGs */
/*                                                                          */
 setConversion(string dpeName, string Direction, float Alfa, float Beta)
 { dyn_errClass eror;

     switch(Direction)
   { case \"IN\":                            // Monitored value coversion
     dpSetWait(
          dpeName+\":_msg_conv.._type\", 33, //Coversion from raw to physical
          dpeName+\":_msg_conv.1._type\", 2, //Polynomial 4th degree conversion
          dpeName+\":_msg_conv.1._poly_grade\", 1,  //Take only: y = a + b*x
          dpeName+\":_msg_conv.1._poly_a\", Alfa,
          dpeName+\":_msg_conv.1._poly_b\", Beta); break;
     case \"OUT\":                           // Controled value conversion
     dpSetWait(
          dpeName+\":_cmd_conv.._type\", 36, //Coversion from raw to physical
          dpeName+\":_cmd_conv.1._type\", 2, //Polynomial 4th degree conversion
          dpeName+\":_cmd_conv.1._poly_grade\", 1,  //Take only: y = a + b*x
          dpeName+\":_cmd_conv.1._poly_a\", Alfa,
          dpeName+\":_cmd_conv.1._poly_b\", Beta); break;
     default: ;	
   }//end of switch(...)
   eror = getLastError(); if(dynlen(eror) > 0) 
   { throwError(eror);
   }	  		  
 }
/*                                                          07.07.2003      */
/*                             CONVERSION FORMULAS                          */
/*                                                                          */
//   switch(para)                    /* Conversion of Raw Value to \"Recv\"   */
// { case  1: recv = 1.0  * rawv;            break;      /* LVcaTemp        */
//   case  2: recv = rawv / 2.5;             break;      /* LVcaPowr        */
//   default: recv = 9999.9;
// }
//   switch(para)                    /* Conversion of \"Send\" to Raw Value   */
// { case  1: rawv = send * 2.5;             break;      /* LVcaTrip        */
//   default: rawv = 0.0;
// }
//   switch(para)                    /* Conversion of Raw Value to \"Recv\"   */
// { case  1: recv = (20.0 * rawv) / 1000.0; break;      /* LVch_Vcc        */
//   case  2: recv = (50.0 * rawv) / 1000.0; break;      /* LVps_Vcc        */
//   case  3: recv = (20.0 * rawv) / 1000.0; break;      /* LVretVcc        */
//   case  4: recv =  10.0 * rawv;           break;      /* LVch_Icc        */
//   case  5: recv = (20.0 * rawv) / 1000.0; break;      /* LVch_Vdd        */
//   case  6: recv = (50.0 * rawv) / 1000.0; break;      /* LVps_Vdd        */
//   case  7: recv = (20.0 * rawv) / 1000.0; break;      /* LVretVdd        */
//   case  8: recv =  10.0 * rawv;           break;      /* LVch_Idd        */
//   case  9: recv = (40.0 * rawv) / 1000.0; break;      /* LVchVCSV        */
//   case 10: recv =  rawv / 25.0;           break;      /* LVchVCSI        */
//   case 11: recv = (50.0 * rawv) / 1000.0; break;      /* LVchPINV        */
//   case 12: recv =  rawv / 100.0;          break;      /* LVchPINI        */
//   case 13: recv = ( 1.0 * rawv) / 1.0;    break;      /* MOch_Tm0        */
//   case 14: recv = ( 1.0 * rawv) / 1.0;    break;      /* MOch_Tm1        */
//   case 15: recv = 2.0 * rawv;             break;      /* LVchDTrp_send   */
//   case 16: recv = 2.0 * rawv;             break;      /* LVchCTrp_send   */
//   case 17: recv = rawv - 128.0;           break;      /* LVchTLim_send   */
//   case 18: recv = rawv - 128.0;           break;      /* LVchTTrp_send   */
//   case 23: recv = rawv / 8.0;             break;      /* HVchVolt        */
//   case 24: recv = rawv;                   break;      /* HVchCurr        */
//   case 27: recv = rawv;                   break;      /* HVchITrp_send   */
//   case 28: recv = rawv;                   break;      /* HVchRamp_send   */
//   default: recv = 9999.9;
// }
//   switch(para)                    /* Conversion of \"Send\" to Raw Value   */
// { case  1: rawv = (send * 1000.0) / 20.0; break;      /* LVch_Vcc        */
//   case  5: rawv = (send * 1000.0) / 20.0; break;      /* LVch_Vdd        */
//   case  9: rawv = (send * 1000.0) / 40.0; break;      /* LVchVCSV        */
//   case 11: rawv = (send * 1000.0) / 50.0; break;      /* LVchPINV        */
//   case 15: rawv = send / 2.0;             break;      /* LVchDTrp        */
//   case 16: rawv = send / 2.0;             break;      /* LVchCTrp        */
//   case 17: rawv = send + 128.0;           break;      /* LVchTLim        */
//   case 18: rawv = send + 128.0;           break;      /* LVchTTrp        */
//   case 26: rawv = send;                   break;      /* HVchVolt        */
//   case 27: rawv = send;                   break;      /* HVchITrp        */
//   case 28: rawv = send;                   break;      /* HVchRamp        */
//   default: rawv = 0.0;
// }

/* ======================================================================== */
/* SELECT CONFIG FUNCTION BASING ON CONF_STAT DATA POINT                    */
/*                                                                          */
/*               Script Flag - Conf.Indx ( 0 -> 1 )                         */
/*               Panel  Flag - Conf.Numb ( 0 -> 1 )                         */
/*               Funct  Attr - Conf.Stat ( x[OPC]x[Load] - hex )            */
/*               Funct  Flag - Conf.Data ( 1 -> 2 ; 2 -> 1 )                */
/*                                                                          */
 SelectConfigFunction(string Dapo, int Flag)
 { int    code, load, serv, int1;
   string dstr;
   
   dpGet(\"SCTmops1:Conf.Stat:_original.._value\", code);
   load =  code &  0xF;
   serv = (code & 0xF0) >> 4;
/*
   int1=0; while(int1 < 10)
   { sprintf(dstr,\" Config Code: %Xh; Load=%Xh, Serv=%Xh\", code, load, serv);
     dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  int1++;
     delay(1);
   }                                                               /* Debug */
     if((load > 0) || (serv > 0))
   { dpSet(\"SCTmops1:Moni.Stat:_original.._value\", 0x2); /*Yellow Background*/
     MakeConfigs(load, serv);
     dpSet(\"SCTmops1:Moni.Stat:_original.._value\", 0x0); /* Green Background*/
     dpSet(\"SCTmops1:Conf.Stat:_original.._value\", 0x0); /* Script Handshake*/
   }
 }

/* CREATE PVSS CONFIGs AND LOAD THEM, MAKE OPC_CONFIG FILE & PVSS OPC ADDRs */
/*                                                                          */
/*                      Load -       ( if Serv == 0x0 or 0x4 or 0x8 )       */
/*                             0x0 - Load NOTHING       from 'Para' confFile*/
/*                             0x4 - Load 'Off' to DaPo from 'Para' confFile*/
/*                             0x8 - Load 'Stb' to DaPo from 'Para' confFile*/
/*                             0xC - Load 'On'  to DaPo from 'Para' confFile*/
/*                      Serv - what will be created for OPC-server:         */
/*                             0x0 - Create NOTHING                         */
/*                             0x4 - Create OPC-configFile                  */
/*                             0x8 - Create OPC-addresses and PVSS          */
/*                                          comm/mesg conversion formulas   */
/*                             0xC - Create NOTHING, Load NOTHING (OPC Run) */
/*                                                                          */
 MakeConfigs(int Load, int Serv)
 { int  host, node, port, unit, chan, cnod, cpor, busn;
   int  hmax, nmax, pmax, umax, cmax, mmax, lvmx, hvmx, lmax;
   int  mod1, mod2, para, len1, len2, leng, open;
   int  rack, crat, card, lvca, hvca, lvpa, lvix, hvpa, hvix, hivo;
   int  grup, maxp, lvca_max  , hvca_max  , crmx;
   int  iden, pmon, simu, unin, limi, int1, int2, int3;
   int  syss, stat, stus, imod;      /* SYStem STATe and STatuS (Error)     */
   int  busy, tout, usts, csts;      /* BUSY, TimeOUT (sec); Unit,Chan STuS */
   int  vadc, conv, eror, errn, arch;/* ADC range, CONVersion number, ERrOR */
   float acal,bcal, ccal, dcal, ecal, rcal;    /* A,B,C,D,E,R- CALibrations */
   float data,flo1, flo2;
   float      s00f, s01f, s02f, s03f,/* String '**' of Float(s)             */
              s04f, s05f, s06f, s07f, s08f, s09f, s10f, s11f,
              s12f, s13f, s14f, s15f, s16f, s17f, s18f, s19f,
              s20f, s21f, s22f, s23f, s24f, s25f, s26f, s27f;
   int        s00i, s01i, s02i, s03i,/* String '**' of Integer(s)           */
              s04i, s05i, s06i, s07i, s08i, s09i, s10i, s11i,
              s12i, s13i, s14i, s15i, s16i, s17i, s18i, s19i,
              s20i, s21i, s22i, s23i, s24i, s25i, s26i, s27i;
   string     s00w, s01w, s02w, s03w,/* String '**' of Word(s)              */
              s04w, s05w, s06w, s07w, s08w, s09w, s10w, s11w,
              s12w, s13w, s14w, s15w, s16w, s17w, s18w, s19w,
              s20w, s21w, s22w, s23w, s24w, s25w, s26w, s27w, s28w;
   string     s00e, s01e, s02e, s03e,/* String '**' of idEn(s)              */
              s04e, s05e, s06e, s07e, s08e, s09e, s10e, s11e,
              s12e, s13e, s14e, s15e, s16e, s17e, s18e, s19e,
              s20e, s21e, s22e, s23e, s24e, s25e, s26e, s27e;
   string     stri, snam, bnam, fstr, estr, mstr, dstr;
   string     str0, str1, str2, str3, str4, str5,
              str6, str7, str8, str9;
   string     nadr, padr, uadr, cadr, para_adr;/* Node,Port,Unit,Chan ADdRes*/
   dyn_string list;
   file       finp, fopc, fsdi, fpdo, fpdi, fini, fidn;
   bool       connectedState;
/*-----------------------------------=--------------------------------------*/
   imod =   4;                       /* Identification mode for Chan Name   */
   tout =  30;                       /* TimeOut (in sec)                    */  
/*-----------------------------------=--------------------------------------*/
   int1=0; while(int1 < 9)           /* 9 - Max_number of PVSS systems      */
   { snam = getSystemName(int1);
     int2 = strlen(snam); if(int2 > 0)
     {
/*
       dpSet(\"SCTmops1:Moni.Name:_original.._value\",sman);delay(1);/* Debug */
       strreplace(snam,\":\",\"\");          sprintf(stri, snam);
       strreplace(stri,\"SCTmops\",\"\");    break;
     } int1++;
   }
   sprintf(stri, snam);                 strreplace(stri,\"mops\",\"\");
   len1 = strlen(snam);                 len2 = strlen(stri);
     if(len2 >= len1)
   { sprintf(estr,\" PVSS_DB is not for MoPS: %s \", snam);
     ErrorStop(estr,\" CHECK PROJ_DB, PUSH EXIT [X] & RESTART \");
   }
     if((Serv & 0xC) == 0x4)
   { setOPCServer(\"CANopen\", 10, 10); 
     setOPCGroup(\"Comm\", 1000, \"Device\", TRUE, FALSE); 
     setOPCGroup(\"Moni\",  100, \"Cache\" , TRUE, TRUE);
     CheckOPCserver(\"CANopen\", \"Comm\");   /* Checking if OPC server exists  */
   }
     if((Serv & 0xC) > 0x4)
   { connectedState = 1;                  /* Should be commented for NO_OPC */
/**/
     dpGet(\"_CANopen.Connected:_online.._value\", connectedState);  /* Debug */
       if(!connectedState)
     { sprintf(estr,\" OPC Client is not connected\");
       dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
       dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
//       dpSet(\"SCTmops1:Moni.Stat:_original.._value\", 0x2);    /* YellowColor*/
//       sprintf(mstr,\" CHECK OPC-SERVER AND PUSH EXIT [X] BUTTON\");
//       dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr);
//       while(1) { delay(1); }
     }
   }
//   dpGet(\"SCTmops1:Cmax.Numb:_original.._value\", cmax);
   sprintf(str1,\"%s\",\" ERROR \");         sprintf(str2,\"%s\",\" ERROR \");
   sprintf(str3,\"%s\",\" ERROR \");         sprintf(str4,\"%s\",\" ERROR \");
   sprintf(str5,\"%s\",\" ERROR \");         sprintf(str6,\"%s\",\" ERROR \");
   sprintf(str7,\"%s\",\" ERROR \");         sprintf(str8,\"%s\",\" ERROR \");
/*SYST*/                             /* System parameters reading from CF   */
   dpSet(\"SCTmops1:Moni.Stat:_original.._value\", 0x2);        /* YellowColor*/
   sprintf(mstr,\" SYST LOCAL PVSS CONFIGs LOADING...\");
   open = 1;                                                  /* Open->Local*/
   finp = fopen(\"Cnf_Syst.txt\",\"r\");
   eror = ferror(finp); if(eror)
   { Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" SYST COMMON PVSS CONFIGs LOADING...\");
     open = 2;                                                /*Open->Common*/
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Syst.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     fgets(fstr, 300, finp);
     sscanf(fstr,\"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\",
            s00i, s01i, s02i, s03i, s04i, s05i, s06i, s07i, s08i, s09i,
            s10i, s11i, s12i, s13i, s14i, s15i, s16i, s17i, s18i);
     fclose(finp);
     hmax= s01i; if(hmax > 9)
     { sprintf(estr,
       \" Reading 'Cnf_Host.txt',\\n    HostMax number is too much: %d\",
                     hmax); 
       ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
     }
     dpSet(\"SCTmops1:Hmax.Numb:_original.._value\", s01i);
     dpSet(\"SCTmops1:Nmax.Numb:_original.._value\", s02i);
     dpSet(\"SCTmops1:Pmax.Numb:_original.._value\", s03i);
     dpSet(\"SCTmops1:Umax.Numb:_original.._value\", s04i);
     dpSet(\"SCTmops1:Cmax.Numb:_original.._value\", s05i);
     dpSet(\"SCTmops1:LVch_max.Numb:_original.._value\", s06i);
     dpSet(\"SCTmops1:HVch_max.Numb:_original.._value\", s07i);
     dpSet(\"SCTmops1:LVca_max.Numb:_original.._value\", s08i);
     dpSet(\"SCTmops1:HVca_max.Numb:_original.._value\", s09i);
     dpSet(\"SCTmops1:CRpa_max.Numb:_original.._value\", s10i);
     dpSet(\"SCTmops1:Lmax.Numb:_original.._value\", s11i);
     delay(1);
     dpGet(\"SCTmops1:Hmax.Numb:_original.._value\", hmax);     /* Host_Max   */
     dpGet(\"SCTmops1:Nmax.Numb:_original.._value\", nmax);     /* Node_Max   */
     dpGet(\"SCTmops1:Pmax.Numb:_original.._value\", pmax);     /* Port_Max   */
     dpGet(\"SCTmops1:Umax.Numb:_original.._value\", umax);     /* Unit_Max   */
     dpGet(\"SCTmops1:Cmax.Numb:_original.._value\", cmax);     /* Chan_Max   */
     dpGet(\"SCTmops1:LVch_max.Numb:_original.._value\", lvmx); /* LVparaMax  */
     dpGet(\"SCTmops1:HVch_max.Numb:_original.._value\", hvmx); /* HVparaMax  */
     dpGet(\"SCTmops1:LVca_max.Numb:_original.._value\", lvca_max);
     dpGet(\"SCTmops1:HVca_max.Numb:_original.._value\", hvca_max);
     dpGet(\"SCTmops1:CRpa_max.Numb:_original.._value\", crmx); /* CRparaMax  */
     dpGet(\"SCTmops1:Lmax.Numb:_original.._value\", lmax);     /* LimiTypeMax*/
     dpSet(\"SCTmops1:Eout.Indx:_original.._value\", s18i);     /* ErrFileLeng*/
     cnod= s12i; cpor= s13i;         /* Control (nonScan) NODe & PORt number*/
     mmax = nmax*pmax * umax*cmax;   /* Modl-s/Chan-s_MAX number in one Host*/
/**/
     setValue(\"CtrlIndi\",\"backCol\",\"Yellow\");
     sprintf(dstr,\" Hmax=%d, Nmax=%d, Pmax=%d, Umax=%d, Cmax=%d, Lmax=%d\",
                    hmax, nmax, pmax, umax, cmax, lmax);
     setValue(\"CtrlIndi\",\"text\", dstr);                            /* Debug */
/**/
     setValue(\"DiagIndi\",\"backCol\",\"Yellow\");
     sprintf(dstr,\" LVpMx=%d, HVpMx=%d, LVcpMx=%d, HVcpMax=%d, CRpMax=%d\",
                    lvmx, hvmx, lvca_max, hvca_max, crmx);
     setValue(\"DiagIndi\",\"text\", dstr);                   delay(1); /* Debug*/
   } else
   { sprintf(estr,\" 'Cnf_Syst.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*HOST*/                             /* Host(s) parameters reading from CF  */
     if(open == 1)
   { sprintf(mstr,\" HOST LOCAL PVSS CONFIGs LOADING...\");
     finp = fopen(\"Cnf_Host.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" HOST COMMON PVSS CONFIGs LOADING...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Host.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     fgets(fstr, 300, finp);
     sscanf(fstr,\"%d %d %s %s %s %d %d %d %d %d %d %d %d\",
                 s00i, s01i, s02w, s03w, s04w, s05i, s06i, s07i, s08i,
                                               s09i, s10i, s11i, s12i);
//     sprintf(dstr,\" %d %s %s %s %d %d %d\",
//                  s00i, s01w, s02w, s03w, s04i, s05i, s06i);
     dpGet(\"SCTmops1:Host.Numb:_original.._value\", host);
     sprintf(str1,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Name:_original.._value\");
     strreplace(s02w,\"\\\"\",\"\");          dpSet(str1, s02w);
     sprintf(str2,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Iden:_original.._value\");
     strreplace(s03w,\"\\\"\",\"\");          dpSet(str2, s04w);
     sprintf(str3,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Stat:_original.._value\");
                                        dpSet(str3, 0x8);
     sprintf(str4,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Pmon:_original.._value\");
                                        dpSet(str4, s10i);
     sprintf(str5,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Scan:_original.._value\");
                                        dpSet(str5, s11i);
     sprintf(str6,\"%s\"\"%d\"\"%s\",
                  \"SCTmops1:Host0\",host,\".Simu:_original.._value\");
                                        dpSet(str6, s12i);
/*
     sscanf(fstr,\"%d %d %s %s %s %d %d %d %d %d %d %d %d\",
                 s00i, s01i, s02w, s03w, s04w, s05i, s06i, s07i, s08i,
                                               s09i, s10i, s11i, s12i);
//     sprintf(dstr,\" %d %s %s %s %d %d %d\",
//                  s00i, s01w, s02w, s03w, s04i, s05i, s06i);
//     dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr); delay(2);
     dpGet(str1, str0);  dpGet(str2, str9);  dpGet(str3, stat);
     sprintf(dstr,\" Host0%d Name: %s, Iden: %s, Stat = %xh\",
                    host, str0, str9, stat);
     dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr); delay(2);
     dpGet(str4, int1);  dpGet(str5, int2);  dpGet(str6, int3);
     sprintf(dstr,\" Host0%d Pmon = %d, Scan = %d, Simu = %d\",
                    host, int1, int2, int3);
     dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr); delay(2);/* Debug */
     fclose(finp);
   } else
   { sprintf(estr,\" 'Cnf_Host.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*NODE*/                             /* Node(s) parameters reading from CF  */
     if(open == 1)
   { sprintf(mstr,\" NODE LOCAL PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"Cnf_Node.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" NODE COMMON PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Node.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
/*OPC>*/
     if((Serv == 0x4) || (Serv == 0x8))   /* ConfigFile for OPC-server      */
   { fopc = fopen(\"C:/SCT_DCS/CAN/Elmb/OPCserver/OPCCanServer.cfg\",\"w\");
     fini = fopen(\"OPCini.bak\",\"w\"); /* ConfigFile for OPC INItial param-s  */
     fprintf(fini,\"\\n[INIT]\\n\");
   }
/*<OPC*/                             /* Node(s) parameters reading from DB  */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     node=0; while(node < nmax)      /* OVER nodes must be after SCAN ones  */
     { fgets(fstr, 300, finp);
       sscanf(fstr,\"%d %d %d %s %s %s %s %s %s %d %s %s %d %s %s %d %s %s %d\",
              s00i, s01i, s02i, s03w, s04w, s05w, s06w, s07w, s08w, s09i,
                    s10w, s11w, s12i, s13w, s14w, s15i, s16w, s17w, s18i);
       node = s02i; if(node > 9)
       { sprintf(estr,
         \" Reading 'Cnf_Node.txt',\\n    Node number is too much, Node: %d\",
                      node); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(node == 9)
       { break;
       }
       sprintf(str1,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Name:_original.._value\");
       strreplace(s04w,\"\\\"\",\"\");       dpSet(str1, s04w);
       sprintf(str2,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Iden:_original.._value\");
       strreplace(s05w,\"\\\"\",\"\");       dpSet(str2, s05w);
       sprintf(str3,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Stat:_original.._value\");
       strreplace(s06w,\"\\\"\",\"\");       sscanf(s06w,\"%x\",stat);
                                       dpSet(str3, stat);
         if(pmax > 3)
       { busn = (node * pmax) + 3;
            if(busn < 10)
         { sprintf(bnam,\"Bus0%d\", busn);
         } else
         { sprintf(bnam,\"Bus%d\" , busn);
         }
         sprintf(str4,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port03.Iden:_original.._value\");
         strreplace(s16w,\"\\\"\",\"\");     dpSet(str4, s16w);
         sprintf(str5,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port03.Stat:_original.._value\");
         strreplace(s17w,\"\\\"\",\"\");     sscanf(s17w,\"%x\",stat);
                                       dpSet(str5, stat);
         sprintf(str6,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port03.Baud:_original.._value\");
                                       dpSet(str6, s18i);
       }
/*OPC>*/
         if((Serv == 0x4) || (Serv == 0x8))
       { fprintf(fopc,\"[CANBUS]\\n\");
           if((stat == 0x54) && (pmax > 3))
         { fprintf(fopc,\"%s = %s %s %d\\n\" , bnam, s05w, s16w, s18i);
           sprintf(stri,\"SCTmops1:Host0%d.Pmon:_original.._value\", host);
           dpGet(stri, pmon);
           fprintf(fini,\"%s.NMT               = 128\\n\", bnam);
           fprintf(fini,\"%s.SyncInterval      = %d\\n\" , bnam, pmon * 1000);
           fprintf(fini,\"%s.NodeGuardInterval = %d\\n\" , bnam, pmon * 1000);
         }
       }
/*<OPC*/
         if(pmax > 2)
       { busn = (node * pmax) + 2;
            if(busn < 10)
         { sprintf(bnam,\"Bus0%d\", busn);
         } else
         { sprintf(bnam,\"Bus%d\" , busn);
         }
         sprintf(str4,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port02.Iden:_original.._value\");
         strreplace(s13w,\"\\\"\",\"\");     dpSet(str4, s13w);
         sprintf(str5,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port02.Stat:_original.._value\");
         strreplace(s14w,\"\\\"\",\"\");     sscanf(s14w,\"%x\",stat);
                                       dpSet(str5, stat);
         sprintf(str6,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port02.Baud:_original.._value\");
                                       dpSet(str6, s15i);
       }
/*OPC>*/
         if((Serv == 0x4) || (Serv == 0x8))
       {   if((stat == 0x54) && (pmax > 2))
         { fprintf(fopc,\"%s = %s %s %d\\n\" , bnam, s05w, s13w, s15i);
           sprintf(stri,\"SCTmops1:Host0%d.Pmon:_original.._value\", host);
           dpGet(stri, pmon);
           fprintf(fini,\"%s.NMT               = 128\\n\", bnam);
           fprintf(fini,\"%s.SyncInterval      = %d\\n\" , bnam, pmon * 1000);
           fprintf(fini,\"%s.NodeGuardInterval = %d\\n\" , bnam, pmon * 1000);
         }
       }
/*<OPC*/
         if(pmax > 1)
       { busn = (node * pmax) + 1;
            if(busn < 10)
         { sprintf(bnam,\"Bus0%d\", busn);
         } else
         { sprintf(bnam,\"Bus%d\" , busn);
         }
         sprintf(str4,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port01.Iden:_original.._value\");
         strreplace(s10w,\"\\\"\",\"\");     dpSet(str4, s10w);
         sprintf(str5,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Port01.Stat:_original.._value\");
         strreplace(s11w,\"\\\"\",\"\");     sscanf(s11w,\"%x\",stat);
                                       dpSet(str5, stat);
         sprintf(str6,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                      \".Node0\",node,\".Port01.Baud:_original.._value\");
                                       dpSet(str6, s12i);
       }
/*OPC>*/
         if((Serv == 0x4) || (Serv == 0x8))
       {   if((stat == 0x54) && (pmax > 1))
         { fprintf(fopc,\"%s = %s %s %d\\n\" , bnam, s05w, s10w, s12i);
           sprintf(stri,\"SCTmops1:Host0%d.Pmon:_original.._value\", host);
           dpGet(stri, pmon);
           fprintf(fini,\"%s.NMT               = 128\\n\", bnam);
           fprintf(fini,\"%s.SyncInterval      = %d\\n\" , bnam, pmon * 1000);
           fprintf(fini,\"%s.NodeGuardInterval = %d\\n\" , bnam, pmon * 1000);
         }
       }
/*<OPC*/
       sprintf(str4,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Port00.Iden:_original.._value\");
       strreplace(s07w,\"\\\"\",\"\");       dpSet(str4, s07w);
       sprintf(str5,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Port00.Stat:_original.._value\");
       strreplace(s08w,\"\\\"\",\"\");       sscanf(s08w,\"%x\",stat);
                                       dpSet(str5, stat);
       sprintf(str6,\"%s\"\"%d\"\"%s\"\"%d\"\"%s\",\"SCTmops1:Host0\",host,
                    \".Node0\",node,\".Port00.Baud:_original.._value\");
                                       dpSet(str6, s09i);
/*OPC>*/
         if((Serv == 0x4) || (Serv == 0x8))
       {   if(stat == 0x54)
         { busn = (node * pmax) + 0;
             if(busn < 10)
           { sprintf(bnam,\"Bus0%d\", busn);
           } else
           { sprintf(bnam,\"Bus%d\" , busn);
           }
           fprintf(fopc,\"%s = %s %s %d\\n\" , bnam, s05w, s07w, s09i);
           sprintf(stri,\"SCTmops1:Host0%d.Pmon:_original.._value\", host);
           dpGet(stri, pmon);
           fprintf(fini,\"%s.NMT               = 128\\n\", bnam);
           fprintf(fini,\"%s.SyncInterval      = %d\\n\" , bnam, pmon * 1000);
           fprintf(fini,\"%s.NodeGuardInterval = %d\\n\" , bnam, pmon * 1000);
         }
       }
/*<OPC*/
/*
       sprintf(dstr,\"%d %d %s %s %s %s %s %s \\n%d %s %s %d %s %s %d %s %s %d\",
               s01i, s02i, s03w, s04w, s05w, s06w, s07w, s08w, s09i,
               s10w, s11w, s12i, s13w, s14w, s15i, s16w, s17w, s18i);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(2);
       dpGet(str1, str0);  sprintf(dstr,\" Node0%d Name : %s\", node, str0);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(2);
       dpGet(str2, str0);  sprintf(dstr,\" Node0%d Iden : %s\", node, str0);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(2);
       dpGet(str3, stat);  sprintf(dstr,\" Node0%d Stat = %xh\",node, stat);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(1);
       dpGet(str4, str0);  sprintf(dstr,\" n_%d.Port0%d Iden = %s\",
                                                        node, port, str0);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(1);
       dpGet(str5, stat);  sprintf(dstr,\" n_%d.Port0%d Stat = %xh\",
                                                        node, port, stat);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(1);
       dpGet(str6, int1);  sprintf(dstr,\" n_%d.Port0%d Baud = %d\",
                                                        node, port, int1);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\",dstr);delay(1);/* Debug */
/*BUSES*/
       port=0; while(port < pmax)
       { para=0; while(para <  6)
         { busn = (node * pmax) + port;
           sprintf(padr,\"Bus%02d\", busn);
/*OPC>*/
             if((Serv == 0x4) || (Serv == 0x8))
           { sprintf(str4,\"SCTmops1:%s\", padr);
               switch(para)
             { case  0:              /* Bus_NMT                             */
                          if(Serv == 0x8)
                        { sprintf(str5,\"%s.Bus_NMT.Send\", str4);
                          sprintf(str7,\"%s.NMT\", padr);
                          setOPCAddress(str5, str7,
                                        \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.Bus_NMT.Recv\", str4);
                          sprintf(str8,\"%s.NMT\", padr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  1:              /* Bus_NGT                             */
                          if(Serv == 0x8)
                        { sprintf(str5,\"%s.Bus_NGT.Send\", str4);
                          sprintf(str7,\"%s.NodeGuardInterval\", padr);
                          setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                        break;
               case  2:              /* BusSync                             */
                          if(Serv == 0x8)
                        { sprintf(str5,\"%s.BusSync.Send\", str4);
                          sprintf(str7,\"%s.SYNC\", padr);
                          setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                        break;
               case  3:              /* BusSyncInt                          */
                          if(Serv == 0x8)
                        { sprintf(str5,\"%s.BusSyncInt.Send\", str4);
                          sprintf(str7,\"%s.SyncInterval\", padr);
                          setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                        break;
               case  4:              /* BusPortError                        */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.BusPortError.Recv\", str4);
                          sprintf(str8,\"%s.portError\", padr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  5:              /* BusPortErrorCode                    */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.BusPortErrorCode\", str4);
                          sprintf(str8,\"%s.portErrorDescription\", padr);
                          setOPCAddress(str6, str8,
                                       \"VT_STRING\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               default: ;
             }
           }
/*<OPC*/
             para++;
         } port++;
       } node++;
     } fclose(finp);
   } else
   { fclose(fopc);  fclose(fini);
     sprintf(estr,\" 'Cnf_Node.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*UNIT*/                             /* Unit(s) parameters reading from CF  */
     if(open == 1)
   { sprintf(mstr,\" UNIT LOCAL PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"Cnf_Unit.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" UNIT COMMON PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Unit.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   {
/*OPC>*/
       if((Serv == 0x4) || (Serv == 0x8))
     { fprintf(fopc,\"\\n[DEVICE]\\n\");
       fsdi= fopen(\"OPCsdi.bak\",\"w\");/* ConfigFile for OPC SDoItem param-s  */
       fprintf(fsdi,\"\\n[SDOItem]\\n\");
       fpdo= fopen(\"OPCpdo.bak\",\"w\");/* ConfigFile for OPC PDO  parameters  */
       fprintf(fpdo,\"\\n[PDO]\\n\");
       fpdi= fopen(\"OPCpdi.bak\",\"w\");/* ConfigFile for OPC PDoItem param-s  */
       fprintf(fpdi,\"\\n[PDOItem]\\n\");
     }
/*<OPC*/
     fgets(fstr, 300, finp);         /* Skip the first line                 */
     host=0; while(host < 99)        /* OVER units must be after SCAN ones  */
     { fgets(fstr, 300, finp);
       sscanf(fstr,\"%d %d %d %d %d %s %s %s %s %d %d %d %s\",
              s00i, s01i, s02i, s03i, s04i, s05w, s06w, s07w, s08w, s09i,
              s10i, s11i, s12w);
       host= s01i; if(host >= 99)    /* End of Unit ConfigFile              */
       { break;
       } else
       {   if(host > 9)
         { sprintf(estr,
           \" Reading 'Cnf_Unit.txt',\\n    Host number is too much, Unit: %d\",
                            unit); 
           ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
         }
       }
       node = s02i; if((node >= (nmax + cnod)) || (node > 9))
       { sprintf(estr,
         \" Reading 'Cnf_Unit.txt',\\n    Node number is too much, Unit: %d\",
                          unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       }
       port = s03i; if((port >= (pmax + cpor)) || (port > 9))
       { sprintf(estr,
         \" Reading 'Cnf_Unit.txt',\\n    Port number is too much, Unit: %d\",
                          unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       }
       unit = s04i; if((unit >= (umax + (cnod * cpor))) || (unit > 64))
       { sprintf(estr,
         \" Reading 'Cnf_Unit.txt',\\n    Unit number is too much, Unit: %d\",
                          unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       }                             /* Only Scan Units are including       */
         if((node < nmax) && (port < pmax) &&
            (unit < umax) && (unit !=  99))
       { crat = (node * pmax * umax) + (port * umax) + unit;
         sprintf(str3,\"SCTmops1:Crate%02d.Iden:_original.._value\", crat);
         strreplace(s07w,\"\\\"\",\"\");     sscanf(s07w,\"%x\",iden);
                                            dpSet(str3, iden);
         strreplace(s08w,\"\\\"\",\"\");     sscanf(s08w,\"%x\",stat);
         strreplace(str3,\".Iden\",\".Stat\");  dpSet(str3, stat);
/*
         sprintf(mstr,\"%d %d %d %d %d %s %s %s %s %d %d %d %s\",
                 s00i, s01i, s02i, s03i, s04i, s05w, s06w, s07w, s08w, s09i,
                 s10i, s11i, s12w);
         dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(2);
                                                                   /* Debug */
/*OPC>*/
           if((Serv == 0x4) || (Serv == 0x8))
         {   /*if(stat == 0x54)  /* Loading the CAN_parameters of ELMBs */
           { busn = (node * pmax) + port;
             sprintf(bnam,\"Bus%02d\", busn);
             fprintf(fopc,\"Crate%02d = %s %x NG\\n\", crat, bnam, iden);
             fprintf(fpdo,\"%x = %s 404 IN 0 18\\n\", 0x180+iden, bnam);
             fprintf(fpdo,\"%x = %s 404 IN 0 48\\n\", 0x280+iden, bnam);
             fprintf(fpdo,\"%x = %s 404 IN 0 48\\n\", 0x380+iden, bnam);
             fprintf(fpdo,\"%x = %s 404 IN 0 48\\n\", 0x480+iden, bnam);
             fprintf(fpdo,\"%x = %s 404 IN 0 48\\n\", 0x200+iden, bnam);
             fprintf(fpdo,\"%x = %s 404 IN 0 48\\n\", 0x300+iden, bnam);
             fprintf(fpdo,\"%x = %s 401 OUT\\n\"    , 0x400+iden, bnam);
             fprintf(fpdo,\"%x = %s 401 OUT\\n\"    , 0x500+iden, bnam);
             fprintf(fpdo,\"%x = %s 401 IN \\n\"    , 0x540+iden, bnam);
           }
         }
/*<OPC*/
       }
     } fclose(finp);
   } else
   {   if((Serv == 0x4) || (Serv == 0x8))
     { fclose(fopc);
       fclose(fini);  fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
     }
     sprintf(estr,\" 'Cnf_Unit.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*PARA*/                             /* Chan(s) parameters reading from CF  */
   para=0; if(open == 1)
   { sprintf(mstr,\" PARA LOCAL PVSS & OPC CONFIGs MAKING (~90 sec/cr)...\");
     finp = fopen(\"Cnf_Para.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" PARA COMMON PVSS & OPC CONFIGs MAKING (~90 sec/cr)...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Para.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     mod1=0; while(mod1 < mmax)
     {   if(para < (lvmx + hvmx - 2))/* NO LVchStat & HVchStat in Cnf_Para  */
       { fgets(fstr, 300, finp);
       }
       sscanf(fstr,\"%d%d%s%s %s%s%s%s%s%s %s%s%s%s%s%s %s%s%s%s%s\",
                    s00i, s01i,s02w,s03w,  s04w,s05w,s06w,s07w,s08w,s09w,
                    s10w,s11w,s12w,s13w,s14w,s15w, s16w,s17w,s18w,s19w,s20w);
/*
                                     strreplace(s02w,\"\\\"\",\"\");
       strreplace(s03w,\"\\\"\",\"\");     strreplace(s04w,\"\\\"\",\"\");
       strreplace(s05w,\"\\\"\",\"\");     strreplace(s06w,\"\\\"\",\"\");
       strreplace(s07w,\"\\\"\",\"\");     strreplace(s08w,\"\\\"\",\"\");
       strreplace(s09w,\"\\\"\",\"\");     strreplace(s10w,\"\\\"\",\"\");
       strreplace(s11w,\"\\\"\",\"\");     strreplace(s12w,\"\\\"\",\"\");
       strreplace(s13w,\"\\\"\",\"\");     strreplace(s14w,\"\\\"\",\"\");
       strreplace(s15w,\"\\\"\",\"\");     strreplace(s16w,\"\\\"\",\"\");
       strreplace(s17w,\"\\\"\",\"\");     strreplace(s18w,\"\\\"\",\"\");
       strreplace(s19w,\"\\\"\",\"\");     strreplace(s20w,\"\\\"\",\"\");
       sprintf(dstr,
       \" Pa: %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
                    s00i, s01i,s02w,s03w,  s04w,s05w,s06w,s07w,s08w,s09w,
                    s10w,s11w,s12w,s13w,s14w,s15w, s16w,s17w,s18w,s19w,s20w);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\",dstr);delay(2);/* Debug */
         if(s01i >= 99999)           /* ModuleNumb - end of Para ConfigFile */
       { break;
       } else                        /* Looking for parameter Iden (address)*/
       {   if(1)//para == 0)
         {   if(open == 1)           /* 'Iden' ConfigFile reading from CF   */
           { fidn = fopen(\"Cnf_Iden.txt\",\"r\");
             eror = ferror(fidn);
           } else
           {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
             fidn = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Iden.txt\",\"r\");
             eror = ferror(fidn);
           }
             if(!eror)
           { fgets(fstr, 300, fidn); /* Skip the first line                 */
             mod2=1; while(mod2 <= mmax)
             { fgets(fstr, 300, fidn);
               sscanf(fstr,
                \"%d%d %s%s%s%s %s%s%s%s%s %s%s%s %s%s%s%s%s  %d%d%d%s%s %s%s\",
                   s10i,s11i, s02e,s03e,s04e,s05e, s06e,s07e,s08e,s09e,s10e,
                              s11e,s12e,s13e,      s14e,s15e,s16e,s17e,s18e,
                              s19i,s20i,s21i,s22e,s23e, s24e,s25e);
/*
                                          strreplace(s02e,\"\\\"\",\"\");
               strreplace(s03e,\"\\\"\",\"\");  strreplace(s04e,\"\\\"\",\"\");
               strreplace(s05e,\"\\\"\",\"\");  strreplace(s06e,\"\\\"\",\"\");
               strreplace(s07e,\"\\\"\",\"\");  strreplace(s08e,\"\\\"\",\"\");
               strreplace(s09e,\"\\\"\",\"\");  strreplace(s10e,\"\\\"\",\"\");
               strreplace(s11e,\"\\\"\",\"\");  strreplace(s12e,\"\\\"\",\"\");
               strreplace(s13e,\"\\\"\",\"\");  strreplace(s14e,\"\\\"\",\"\");
               strreplace(s15e,\"\\\"\",\"\");  strreplace(s16e,\"\\\"\",\"\");
               strreplace(s17e,\"\\\"\",\"\");  strreplace(s18e,\"\\\"\",\"\");
                                          strreplace(s22e,\"\\\"\",\"\");
               strreplace(s23e,\"\\\"\",\"\");  strreplace(s24e,\"\\\"\",\"\");
               strreplace(s25e,\"\\\"\",\"\");
               sprintf(dstr,
\"Id: %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %d %d %d %s %s %s %s\",
                   s10i,s11i, s02e,s03e,s04e,s05e, s06e,s07e,s08e,s09e,s10e,
                              s11e,s12e,s13e,      s14e,s15e,s16e,s17e,s18e,
                              s19i,s20i,s21i,s22e,s23e, s24e,s25e);
               dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(2);
                                                                   /* Debug */
                 if(s11i >= 99999)     /* ModuleNumb - end of Iden ConfigFile */
               { fclose(fopc);  fclose(fini);
                 fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
                 sprintf(estr,
     \" Reading 'Cnf_Iden.txt',\\n    Can not find Si-Module: %d\", modl); 
                 ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
               } if(s01i == s11i)
               {                              strreplace(s02e,\"\\\"\",\"\");
                 strreplace(s03e,\"\\\"\",\"\");    strreplace(s04e,\"\\\"\",\"\");
                 strreplace(s05e,\"\\\"\",\"\");    strreplace(s06e,\"\\\"\",\"\");
                 strreplace(s07e,\"\\\"\",\"\");    strreplace(s08e,\"\\\"\",\"\");
                 strreplace(s09e,\"\\\"\",\"\");    strreplace(s10e,\"\\\"\",\"\");
                 strreplace(s11e,\"\\\"\",\"\");    strreplace(s12e,\"\\\"\",\"\");
                 strreplace(s13e,\"\\\"\",\"\");    strreplace(s14e,\"\\\"\",\"\");
                 strreplace(s15e,\"\\\"\",\"\");    strreplace(s16e,\"\\\"\",\"\");
                 strreplace(s17e,\"\\\"\",\"\");    strreplace(s18e,\"\\\"\",\"\");
                                              strreplace(s22e,\"\\\"\",\"\");
                 strreplace(s23e,\"\\\"\",\"\");    strreplace(s24e,\"\\\"\",\"\");
                 strreplace(s25e,\"\\\"\",\"\");
                 strreplace(s14e,\"Rack\" ,\"\"); sscanf(s14e,\"%d\", int3);
                 strreplace(s15e,\"Crate\",\"\"); sscanf(s15e,\"%d\", int2);
                 strreplace(s17e,\"Chan\" ,\"\"); sscanf(s17e,\"%d\", int1);
                 rack = int3;      unit = int2;       chan = int1;
//                 rack = int3 - 1;  unit = int2 - 1;   chan = int1 - 1;
                 host = s19i;      node = s20i;       port = s21i;
/*
//                 card = card - 1;
                   switch(card )
                 { case  0: lvca =  0; lvix =  0;  hvca =  1; hivo = 0; break;
                   case  1: lvca =  0; hvix =  0;  hvca =  1; hivo = 1; break;
                   case  2: lvca =  2; lvix =  1;  hvca =  1; hivo = 0; break;
                   case  3: lvca =  3; lvix =  2;  hvca =  4; hivo = 0; break;
                   case  4: lvca =  3; hvix =  1;  hvca =  4; hivo = 1; break;
                   case  5: lvca =  5; lvix =  3;  hvca =  4; hivo = 0; break;
                   case  6: lvca =  6; lvix =  4;  hvca =  7; hivo = 0; break;
                   case  7: lvca =  6; hvix =  2;  hvca =  7; hivo = 1; break;
                   case  8: lvca =  8; lvix =  5;  hvca =  7; hivo = 0; break;
                   case  9: lvca =  9; lvix =  6;  hvca = 10; hivo = 0; break;
                   case 10: lvca =  9; hvix =  3;  hvca = 10; hivo = 1; break;
                   case 11: lvca = 11; lvix =  7;  hvca = 10; hivo = 0; break;
                   case 12: lvca = 12; lvix =  8;  hvca = 13; hivo = 0; break;
                   case 13: lvca = 12; hvix =  4;  hvca = 13; hivo = 1; break;
                   case 14: lvca = 14; lvix =  9;  hvca = 13; hivo = 0; break;
                   case 15: lvca = 15; lvix = 10;  hvca = 16; hivo = 0; break;
                   case 16: lvca = 15; hvix =  5;  hvca = 16; hivo = 1; break;
                   case 17: lvca = 17; lvix = 11;  hvca = 16; hivo = 0; break;
                   default: lvca = -1; lvix = -1;  hvca =  0; hivo = 2;
                                       hvix = -1;
                 }
*/
                 crat = (node * pmax * umax) + (port * umax) + unit;
                 sprintf(stri,
                     \"SCTmops1:Crate%02d.Iden:_original.._value\", crat);
                 dpGet(stri, iden);
                 sprintf(stri,
                     \"SCTmops1:Crate%02d.Channel%02d.Stat:_original.._value\",
                               crat, chan);
                 sscanf(s22e,\"%x\", csts); dpSet(stri, csts);
/**/
                 sprintf(dstr,
                       \" Node=%d Port=%d Unit=%d (Iden=%Xh) Chan=%d Stat=%Xh\",
                                node, port, unit, iden, chan, csts);
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                                   /* Debug */
                 break;
               } mod2++;
             } fclose(fidn);
           } else
           { fclose(fopc);  fclose(fini);
             fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
             sprintf(estr,\" Can not open 'Cnf_Iden.txt' file\"); 
             ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
           }
                         /* \"Cnf_Para.txt\" file again           */
           busn = (node * pmax) + port;
           sprintf(padr,\"Bus%02d\", busn);      /* Bus Name   (Port ADdRess) */
           crat = (node * pmax * umax) + (port * umax) + unit;
           sprintf(uadr,\"Crate%02d\", crat);    /* Crate Name (Unit ADdRess) */ 
           lvpa=0; hvpa=0;
           para = 0; while(para < (lvmx + hvmx - 2))
           {   if(para == 0)         /* NO LVchStat & HVchStat in Cnf_Para  */
             { sprintf(str1,\"SCTmops1:%s%s\",uadr,\".Stat:_original.._value\"); 
               dpGet(str1, usts);
/*
               sprintf(dstr,\"Uname=%s St=%xh\", str1, usts);
               strreplace(dstr,\"_value\",\"\");
               dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr); delay(2);
                                                                   /* Debug */
                 switch(imod)        /* Identification mode for Chan Name   */
               { case  1: sprintf(str2,\"%s.%s.%s\",s02e,s03e,s04e);
                          break;
                 case  2: sprintf(str2,\"%s.%s.%s.%s\",s06e,s07e,s08e,s09e);
                          break;
                 case  3: sprintf(str2,\"%s.%s\",s11e,s12e);
                          break;
                 case  4: sprintf(str2,\"%s.%s.%s.%s\",s14e,s15e,s16e,s17e);
                          break;
                 default: sprintf(str2,\"\");
               }
             }                             strreplace(s02w,\"\\\"\",\"\");
             strreplace(s03w,\"\\\"\",\"\");     strreplace(s04w,\"\\\"\",\"\");
             strreplace(s05w,\"\\\"\",\"\");     strreplace(s06w,\"\\\"\",\"\");
             strreplace(s07w,\"\\\"\",\"\");     strreplace(s08w,\"\\\"\",\"\");
             strreplace(s09w,\"\\\"\",\"\");     strreplace(s10w,\"\\\"\",\"\");
             strreplace(s11w,\"\\\"\",\"\");     strreplace(s12w,\"\\\"\",\"\");
             strreplace(s13w,\"\\\"\",\"\");     strreplace(s14w,\"\\\"\",\"\");
             strreplace(s15w,\"\\\"\",\"\");     strreplace(s16w,\"\\\"\",\"\");
             strreplace(s17w,\"\\\"\",\"\");     strreplace(s18w,\"\\\"\",\"\");
             strreplace(s19w,\"\\\"\",\"\");     strreplace(s20w,\"\\\"\",\"\");
             sprintf(str0,\"%s\",s02w);      int1 = strlen(str0);
             strreplace(str0,\"HV\",\"\");     int2 = strlen(str0);
               if(int2 < int1)       /* HV set of parameters                */
             { sprintf(cadr,\"Channel%02d\", chan);   /* Chan ADdRess         */
               sprintf(para_adr, s02w);             /* Loading DataPoints : */
                 if((Serv == 0x0) || (Serv == 0x4) || (Serv == 0x8))
               { sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                               uadr,cadr,para_adr,\"Name:_original.._value\"); 
//               dpSet(str4, s02w);  /* Name of siModule (Chan) to Chan_DP  */
                   if(Load == 0x4)   /* Load Config State - Off             */
                 {   if((hvpa == 0) || (hvpa > 1))
                   { sscanf(s06w,\"%f\",s06f);
                     strreplace(str4,\"Name\",\"Send\");
                     dpSet(str4, s06f);
                       if(hvpa == 0)
                     { strreplace(str4,\"Send\",\"Recv\");
                       sscanf(s04w,\"%f\",s04f);
                       sscanf(s05w,\"%f\",s05f);
                       sscanf(s07w,\"%f\",s07f);
                       sscanf(s08w,\"%f\",s08f);
                       dpSet(str4, s06f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s04f, s05f, s07f, s08f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(hvpa == 1)
                     { sscanf(s04w,\"%f\",s04f);
                       sscanf(s05w,\"%f\",s05f);
                       sscanf(s06w,\"%f\",s06f);
                       sscanf(s07w,\"%f\",s07f);
                       sscanf(s08w,\"%f\",s08f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s06f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s04f, s05f, s07f, s08f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
/*
                   sprintf(dstr,\"OF: %s; N=%3.1f, W=%3.1f, F=%3.1f \",
                                     str4, s06f, s07f, s08f);
                   strreplace(dstr,\":_original.._value\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                         delay(1); /* Debug */
                 }
                   if(Load == 0x8)   /* Load Config State - Standby         */
                 {   if((hvpa == 0) || (hvpa > 1))
                   { sscanf(s12w,\"%f\",s12f);
                     strreplace(str4,\"Name\",\"Send\");
                     dpSet(str4, s12f);
                       if(hvpa == 0)
                     { strreplace(str4,\"Send\",\"Recv\");
                       sscanf(s10w,\"%f\",s10f);
                       sscanf(s11w,\"%f\",s11f);
                       sscanf(s13w,\"%f\",s13f);
                       sscanf(s14w,\"%f\",s14f);
                       dpSet(str4, s12f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s10f, s11f, s13f, s14f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(hvpa == 1)
                     { sscanf(s10w,\"%f\",s10f);
                       sscanf(s11w,\"%f\",s11f);
                       sscanf(s12w,\"%f\",s12f);
                       sscanf(s13w,\"%f\",s13f);
                       sscanf(s14w,\"%f\",s14f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s12f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s10f, s11f, s13f, s14f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
/*
                   sprintf(dstr,\"SB: %s; N=%3.1f, W=%3.1f, F=%3.1f \",
                                     str4, s12f, s13f, s14f);
                   strreplace(dstr,\":_original.._value\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                         delay(1); /* Debug */
                 }
                   if(Load == 0xC)   /* Load Config State - On              */
                 {   if((hvpa == 0) || (hvpa > 1))
                   { sscanf(s18w,\"%f\",s18f);
                     strreplace(str4,\"Name\",\"Send\");
                     dpSet(str4, s18f);
                       if(hvpa == 0)
                     { strreplace(str4,\"Send\",\"Recv\");
                       sscanf(s16w,\"%f\",s16f);
                       sscanf(s17w,\"%f\",s17f);
                       sscanf(s19w,\"%f\",s19f);
                       sscanf(s20w,\"%f\",s20f);
                       dpSet(str4, s18f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s16f, s17f, s19f, s20f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(hvpa == 1)
                     { sscanf(s16w,\"%f\",s16f);
                       sscanf(s17w,\"%f\",s17f);
                       sscanf(s18w,\"%f\",s18f);
                       sscanf(s19w,\"%f\",s19f);
                       sscanf(s20w,\"%f\",s20f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s18f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s16f, s17f, s19f, s20f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
/*
                   sprintf(dstr,\"ON: %s; N=%3.1f, W=%3.1f, F=%3.1f \",
                                     str4, s18f, s19f, s20f);
                   strreplace(dstr,\":_original.._value\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                         delay(1); /* Debug */
                 }
               }
/*OPC>*/                             /* If Unit and Chan are included       */
                 if(/*((usts & 0x4) > 0) && ((csts & 0x4) > 0) && */
                        ((Serv == 0x4) || (Serv == 0x8)))
               {   if(hvpa == 0)     /* HVchStat                            */
                 { sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                                          uadr, cadr,\"HVchStat\",\"Send\"); 
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
//                   sprintf(str5,\"%s_%s_SendChan%d\", uadr,\"HVchStat\", chan);
                   sprintf(str6,\"%s_%s_RecvChan%d\", uadr,\"HVchStat\", chan);
                                     /* Str7/8 - Full Item Name for Connect.*/
//                   sprintf(str7,\"%s.%s.%s_%s_SendChan%d\",
//                                 padr, uadr, uadr,\"HVchStat\", chan);
                   sprintf(str8,\"%s.%s.%s_%s_RecvChan%d\",
                                 padr, uadr, uadr,\"HVchStat\", chan);
//                   fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
//                                      str5, uadr, 0x2600 + chan);
                     if(chan == 0)
                   { strreplace(str6,\"Chan0\",\"Chan\");
                     fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 1\\n\",
                                        str6, uadr, 0x300+iden);
                   }
                     if(Serv == 0x8)
                   { strreplace(str4,\"Send\",\"Recv\");
                     setOPCAddress(str4, str8,
                                         \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                   }
                 }
                 sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                                        uadr, cadr, para_adr,\"Send\"); 
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
                 sprintf(cadr,\"Chan%d\", chan); /* Channel OPC ADdRess       */
                 sprintf(str5,\"%s_%s_Send%s\", uadr, para_adr, cadr);
                 sprintf(str6,\"%s_%s_Recv%s\", uadr, para_adr, cadr);
                                     /* Str7/8 - Full Item Name for Connect.*/
                 sprintf(str7,\"%s.%s.%s_%s_Send%s\",
                               padr, uadr, uadr, para_adr, cadr);
                 sprintf(str8,\"%s.%s.%s_%s_Recv%s\",
                               padr, uadr, uadr, para_adr, cadr);
/*
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", str8);
                                                         delay(2); /* Debug */
                   switch(hvpa)
                 { case  0:          /* HVchVolt                            */
                            fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI2\\n\",
                                    str5, uadr, 0x2700 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI2\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1.0); // ? /8 ?
//                              dpConnect(\"OneToOne_toSend\", str4);
                            }
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI2 ALL 2\\n\",
                                      str6, uadr, 0x300+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
//                            { strreplace(str4,\"Comm\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI2\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0 / 8.0);
//                              dpConnect(\"HVchVolt_toData\", str4);
                            }
                            break;
                   case  1:          /* HVchCurr                            */
//                            fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI2\\n\",
//                                    str5, uadr, 0x2600 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI2 ALL 4\\n\" ,
                                      str6, uadr, 0x300+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI2\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0);
//                              dpConnect(\"OneToOne_toData\", str4);
                            }
                            break;
                   case  2:          /* HVchITrp                            */
                            fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI4\\n\",
                                    str5, uadr, 0x2700 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 100.0);
//Pamela?//                     setConversion(str4, \"OUT\", 0.0, 0.1);
//                              dpConnect(\"OneToOne_toSend\", str4);
                            }
//                            fprintf(fpdi,\"s  = %s %x VT_UI2 %d   2\\n\",
//                                    str6, uadr, 0x280+iden, chan);
                            break;
                   case  3:          /* HVchRamp                            */
                            fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI1\\n\",
                                    str5, uadr, 0x2700 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1.0);
//                              dpConnect(\"OneToOne_toSend\", str4);
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   3\\n\",
//                                    str6, uadr, 0x280+iden, chan);
                            break;
                   default: ;
                 }
/*
                 sprintf(dstr,
                         \" Rk=%d Cr=%d Ca=%d Ix=%d %s_%s_%s:%s Us=%xh Cs=%xh\",
                 rack, crat, card, hvix, uadr,cadr,para_adr,s02w, usts, csts);
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                         delay(1); /* Debug */
               }
/*<OPC*/
                 if(hvpa < hvmx)
               { hvpa++;
               } else
               { fclose(fopc);  fclose(fini);
                 fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
                 sprintf(estr,
        \" HV_para - %s number in 'Cnf_Para' list:%d\\n    is more than Max=%d\",
                               s02w, para+1, hvmx);
                 ErrorStop(estr,
                           \" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
               }
             } else                  /* LV set of parameters                */
             { sprintf(cadr,\"Channel%02d\",chan);    /* Chan ADdRess         */
               sprintf(para_adr, s02w);             /* Loading DataPoints : */
                 if((Serv == 0x0) || (Serv == 0x4) || (Serv == 0x8))
               { sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                               uadr,cadr,para_adr,\"Name:_original.._value\"); 
//               dpSet(str4, s02w);  /* Name of siModule (Chan) to Chan_DP  */
                   if(Load == 0x4)   /* Load Config State - Off             */
                 {   if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                       (lvpa == 10) || (lvpa > 13))
                   {   if(lvpa < 18)
                     { sscanf(s06w,\"%f\",s06f);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s06f);
                     } else
                     { sscanf(s06w,\"%x\",s06i);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s06i);
                     }
                       if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                         (lvpa == 10))
                     { sscanf(s04w,\"%f\",s04f);
                       sscanf(s05w,\"%f\",s05f);
                       sscanf(s07w,\"%f\",s07f);
                       sscanf(s08w,\"%f\",s08f);
                       strreplace(str4,\"Send\",\"Recv\");
                       dpSet(str4, s06f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s04f, s05f, s07f, s08f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(lvpa != 0)
                     { sscanf(s04w,\"%f\",s04f);
                       sscanf(s05w,\"%f\",s05f);
                       sscanf(s06w,\"%f\",s06f);
                       sscanf(s07w,\"%f\",s07f);
                       sscanf(s08w,\"%f\",s08f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s06f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s04f, s05f, s07f, s08f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
                 }
                   if(Load == 0x8)   /* Load Config State - Standby         */
                 {   if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                       (lvpa == 10) || (lvpa > 13))
                   {   if(lvpa < 18)
                     { sscanf(s12w,\"%f\",s12f);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s12f);
                     } else
                     { sscanf(s12w,\"%x\",s12i);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s12i);
                     }
                       if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                         (lvpa == 10))
                     { sscanf(s10w,\"%f\",s10f);
                       sscanf(s11w,\"%f\",s11f);
                       sscanf(s13w,\"%f\",s13f);
                       sscanf(s14w,\"%f\",s14f);
                       strreplace(str4,\"Send\",\"Recv\");
                       dpSet(str4, s12f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s10f, s11f, s13f, s14f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(lvpa != 0)
                     { sscanf(s10w,\"%f\",s10f);
                       sscanf(s11w,\"%f\",s11f);
                       sscanf(s12w,\"%f\",s12f);
                       sscanf(s13w,\"%f\",s13f);
                       sscanf(s14w,\"%f\",s14f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s12f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s10f, s11f, s13f, s14f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
                 }
                   if(Load == 0xC)   /* Load Config State - On              */
                 { if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                     (lvpa == 10) || (lvpa > 13))
                   {   if(lvpa < 18)
                     { sscanf(s18w,\"%f\",s18f);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s18f);
                     } else
                     { sscanf(s18w,\"%x\",s18i);
                       strreplace(str4,\"Name\",\"Send\");
                       dpSet(str4, s18i);
                     }
                       if((lvpa == 0) || (lvpa ==  4) || (lvpa == 8) ||
                                         (lvpa == 10))
                     { sscanf(s16w,\"%f\",s16f);
                       sscanf(s17w,\"%f\",s17f);
                       sscanf(s19w,\"%f\",s19f);
                       sscanf(s20w,\"%f\",s20f);
                       strreplace(str4,\"Send\",\"Recv\");
                       dpSet(str4, s18f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s16f, s17f, s19f, s20f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   } else
                   {   if(lvpa != 0)
                     { sscanf(s16w,\"%f\",s16f);
                       sscanf(s17w,\"%f\",s17f);
                       sscanf(s18w,\"%f\",s18f);
                       sscanf(s19w,\"%f\",s19f);
                       sscanf(s20w,\"%f\",s20f);
                       strreplace(str4,\"Name\",\"Recv\");
                       dpSet(str4, s18f);
                         if(((usts & 0x4C) == 0x44) && ((csts & 0x4C) == 0x44))
                       { setAlerts(str4, 1, s16f, s17f, s19f, s20f);
                       } else
                       { setAlerts(str4, 1, -999, -99, 99, 999);
                       }
                     }
                   }
                 }
               }
/*OPC>*/                             /* If Unit and Chan are included       */
                 if(/*((usts & 0x4) > 0) && ((csts & 0x4) > 0) && */
                        ((Serv == 0x4) || (Serv == 0x8)))
               {   if(lvpa == 0)     /* LVchStat                            */
                 { sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                                          uadr, cadr,\"LVchStat\",\"Send\"); 
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
//                   sprintf(str5,\"%s_%s_SendChan%d\", uadr, \"LVchStat\", chan);
                   sprintf(str6,\"%s_%s_RecvChan%d\", uadr, \"LVchStat\", chan);
                                     /* Str7/8 - Full Item Name for Connect.*/
//                   sprintf(str7,\"%s.%s.%s_%s_SendChan%d\",
//                                 padr, uadr, uadr,\"LVchStat\", chan);
                   sprintf(str8,\"%s.%s.%s_%s_RecvChan%d\",
                                 padr, uadr, uadr,\"LVchStat\", chan);
//                   fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
//                                      str5, uadr, 0x2400 + chan);
//                     if(Serv == 0x8)
//                   { setOPCAddress(str4, str7,
//                                         \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                   }
                     if(chan == 0)
                   { strreplace(str6,\"Chan0\",\"Chan\");
                     fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 1\\n\",
                                        str6, uadr, 0x280+iden);
                   }
                     if(Serv == 0x8)
                   { strreplace(str4,\"Send\",\"Recv\");
                     setOPCAddress(str4, str8,
                                         \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                   }
                 }
                 sprintf(str4,\"SCTmops1:%s.%s.%s.%s\",
                                        uadr, cadr, para_adr,\"Send\"); 
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
                 sprintf(cadr,\"Chan%d\", chan); /* Channel OPC ADdRess       */
                 sprintf(str5,\"%s_%s_Send%s\", uadr, para_adr, cadr);
                 sprintf(str6,\"%s_%s_Recv%s\", uadr, para_adr, cadr);
                                     /* Str7/8 - Full Item Name for Connect.*/
                 sprintf(str7,\"%s.%s.%s_%s_Send%s\",
                              padr, uadr, uadr, para_adr, cadr);
                 sprintf(str8,\"%s.%s.%s_%s_Recv%s\",
                              padr, uadr, uadr, para_adr, cadr);
/*
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", str4);
                                                         delay(2); /* Debug */
                   switch(lvpa)
                 { case  0:          /* LVch_Vcc                            */
                            fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1000.0 / 20.0);
//                              dpConnect(\"LVch_Vcc_toSend\", str4);
                            }
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 2\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
//                              strreplace(str4,\"Comm\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 20.0 / 1000.0);
//                              dpConnect(\"LVch_Vcc_toData\", str4);
                            }
                            break;
                   case  1:            /* LVps_Vcc                          */
//                            fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 3\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 50.0 / 1000.0);
//                              dpConnect(\"LVps_Vcc_toData\", str4);
                            }
                            break;
                   case  2:            /* LVretVcc                          */
//                            fprintf(fsdi,\"%s  = %s %x 4 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 4\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 20.0 / 1000.0);
//                              dpConnect(\"LVretVcc_toData\", str4);
                            }
                            break;
                   case  3:            /* LVch_Icc                          */
//                            fprintf(fsdi,\"%s  = %s %x 5 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 5\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 10.0);
//                              dpConnect(\"LVch_Icc_toData\", str4);
                            }
                            break;
                   case  4:            /* LVch_Vdd                          */
                            fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1000.0 / 20.0);
//                              dpConnect(\"LVch_Vdd_toSend\", str4);
                            }
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 6\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
//                            { strreplace(str4,\"Comm\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 20.0 / 1000.0);
//                              dpConnect(\"LVch_Vdd_toData\", str4);
                            }
                            break;
                   case  5:            /* LVps_Vdd                          */
//                            fprintf(fsdi,\"%s  = %s %x 7 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 7\\n\",
                                      str6, uadr, 0x280+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 50.0 / 1000.0);
//                              dpConnect(\"LVps_Vdd_toData\", str4);
                            }
                            break;
                   case  6:            /* LVretVdd                          */
//                            fprintf(fsdi,\"%s  = %s %x 8 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 1\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 20.0 / 1000.0);
//                              dpConnect(\"LVretVdd_toData\", str4);
                            }
                            break;
                   case  7:            /* LVch_Idd                          */
//                            fprintf(fsdi,\"%s  = %s %x 9 IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 2\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 10.0);
//                              dpConnect(\"LVch_Idd_toData\", str4);
                            }
                            break;
                   case  8:            /* LVchVCSV                          */
                            fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1000.0 / 40.0);
//                              dpConnect(\"LVchVCSV_toSend\", str4);
                            }
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 3\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
//                            { strreplace(str4,\"Comm\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 40.0 / 1000.0);
//                              dpConnect(\"LVchVCSV_toData\", str4);
                            }
                            break;
                   case  9:            /* LVchVCSI                          */
//                            fprintf(fsdi,\"%s  = %s %x a IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 4\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0 / 25.0);
//                              dpConnect(\"LVchVCSI_toData\", str4);
                            }
                            break;
                   case 10:            /* LVchPINV                          */
                            fprintf(fsdi,\"%s  = %s %x 4 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1000.0 / 50.0);
//                              dpConnect(\"LVchPINV_toSend\", str4);
                            }
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 5\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
//                            { strreplace(str4,\"Comm\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 50.0 / 1000.0);
//                              dpConnect(\"LVchPINV_toData\", str4);
                            }
                            break;
                   case 11:            /* LVchPINI                          */
//                            fprintf(fsdi,\"%s  = %s %x d IO VT_UI1\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI1 ALL 6\\n\",
                                      str6, uadr, 0x380+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0 / 100.0);
//                              dpConnect(\"LVchPINI_toData\", str4);
                            }
                            break;
                   case 12:            /* MOch_Tm0                          */
//                            fprintf(fsdi,\"%s  = %s %x e IO VT_UI2\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI2 ALL 1\\n\",
                                      str6, uadr, 0x480+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0);
//                              dpConnect(\"MOch_Tm0_toData\", str4);
                            }
                            break;
                   case 13:            /* MOch_Tm1                          */
//                            fprintf(fsdi,\"%s  = %s %x f IO VT_UI2\\n\",
//                                    str5, uadr, 0x2500 + chan);
                              if(chan == 0)
                            { strreplace(str6,\"Chan0\",\"Chan\");
                              fprintf(fpdi,\"%s   = %s %x VT_UI2 ALL 3\\n\",
                                      str6, uadr, 0x480+iden);
                            }
                              if(Serv == 0x8)
                            { strreplace(str4,\"Send\",\"Recv\");
                              setOPCAddress(str4, str8,
                                           \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                              setConversion(str4, \"IN\", 0.0, 1.0);
//                              dpConnect(\"MOch_Tm1_toData\", str4);
                            }
                            break;
                   case 14:            /* LVchDTrp                          */
                            fprintf(fsdi,\"%s  = %s %x 5 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1.0 / 2.0);
//                              dpConnect(\"LVchDTrp_toSend\", str4);
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   1\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 15:            /* LVchCTrp                          */
                            fprintf(fsdi,\"%s  = %s %x 6 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 0.0, 1.0 / 2.0);
//                              dpConnect(\"LVchCTrp_toSend\", str4);
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   2\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 16:            /* LVchTLim                          */
                            fprintf(fsdi,\"%s  = %s %x 7 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 128.0, 1.0);
//                              dpConnect(\"LVchTLim_toSend\", str4);
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   3\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 17:            /* LVchTTrp                          */
                            fprintf(fsdi,\"%s  = %s %x 8 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                              strreplace(str4,\"Send\",\"Comm\");
                              setConversion(str4, \"OUT\", 128.0, 1.0);
//                              dpConnect(\"LVchTTrp_toSend\", str4);
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   4\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 18:            /* LVchCLKS                          */
                            fprintf(fsdi,\"%s  = %s %x 9 IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   5\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 19:            /* LVchCLKR                          */
                            fprintf(fsdi,\"%s  = %s %x a IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   6\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   case 20:            /* LVchVOut                          */
                            fprintf(fsdi,\"%s  = %s %x b IO VT_UI1\\n\",
                                    str5, uadr, 0x2500 + chan);
                              if(Serv == 0x8)
                            { setOPCAddress(str4, str7,
                                           \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                            }
//                            fprintf(fpdi,\"%s  = %s %x VT_UI1 %d   7\\n\",
//                                    str6, uadr, 0x180+iden, chan);
                            break;
                   default: ;
                 }
/*
                 sprintf(dstr,
                         \" Rk=%d Cr=%d Ca=%d Ix=%d %s_%s_%s:%s Us=%xh Cs=%xh\",
                 rack, crat, card, lvix, uadr,cadr,para_adr,s02w, usts, csts);
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                         delay(1); /* Debug */
               }
/*<OPC*/              
                 if(lvpa < lvmx)
               { lvpa++;
               } else
               { fclose(fopc);  fclose(fini);
                 fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
                 sprintf(estr,
        \" LV_para - %s number in 'Cnf_Para' list:%d\\n    is more than Max=%d\",
                               s02w, para+1, lvmx);
                 ErrorStop(estr,
                           \" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
               }
             }             
               if(s01i != mod2)
             { fclose(fopc);  fclose(fini);
               fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
               setValue(\"ErorIndi\",\"backCol\",\"Red\");
               sprintf(estr,
\" ModlNumb in 'Cnf_Para': %d for Para=%d\\n    not equal to ModlNumb in 'Cnf_Iden': %d\",
                             s01i, para, mod2);
               ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
             }
             fgets(fstr,300,finp);
             sscanf(fstr,\"%d%d%s%s %s%s%s%s%s%s %s%s%s%s%s%s %s%s%s%s%s\",
                    s00i, s01i,s02w,s03w,  s04w,s05w,s06w,s07w,s08w,s09w,
                    s10w,s11w,s12w,s13w,s14w,s15w, s16w,s17w,s18w,s19w,s20w);
/*
                                           strreplace(s02w,\"\\\"\",\"\");
             strreplace(s03w,\"\\\"\",\"\");     strreplace(s04w,\"\\\"\",\"\");
             strreplace(s05w,\"\\\"\",\"\");     strreplace(s06w,\"\\\"\",\"\");
             strreplace(s07w,\"\\\"\",\"\");     strreplace(s08w,\"\\\"\",\"\");
             strreplace(s09w,\"\\\"\",\"\");     strreplace(s10w,\"\\\"\",\"\");
             strreplace(s11w,\"\\\"\",\"\");     strreplace(s12w,\"\\\"\",\"\");
             strreplace(s13w,\"\\\"\",\"\");     strreplace(s14w,\"\\\"\",\"\");
             strreplace(s15w,\"\\\"\",\"\");     strreplace(s16w,\"\\\"\",\"\");
             strreplace(s17w,\"\\\"\",\"\");     strreplace(s18w,\"\\\"\",\"\");
             strreplace(s19w,\"\\\"\",\"\");     strreplace(s20w,\"\\\"\",\"\");
             sprintf(dstr,
       \" Pa: %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
                    s00i, s01i,s02w,s03w,  s04w,s05w,s06w,s07w,s08w,s09w,
                    s10w,s11w,s12w,s13w,s14w,s15w, s16w,s17w,s18w,s19w,s20w);
             dpSet(\"SCTmops1:Moni.Name:_original.._value\",dstr); delay(2);
                                                                   /* Debug */
               if(s01i >= 99999)     /* ModuleNumb - end of Para ConfigFile */
             { break;
             } para++;
           }
         } else
         { fclose(fopc);  fclose(fini);
           fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
           sprintf(estr,\" 'Cnf_Iden.txt' File opening \");
           ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
         }
       } mod1++;
     } fclose(finp);
   } else
   { sprintf(estr,\" 'Cnf_Para.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*CARD*/                             /* Card(s) parameters reading from CF  */
     if(open == 1)
   { sprintf(mstr,\" CARD LOCAL PVSS & OPC CONFIGs MAKING (~10 sec)...\");
     finp = fopen(\"Cnf_Card.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" CARD COMMON PVSS & OPC CONFIGs MAKING (~10 sec)...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Card.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     maxp = (2 * lvca_max) + hvca_max;    /* MaxP - MaxPara-s in 3 Cards    */
     grup=0; para=0; lvpa=0; hvpa=0;
     host=0; while(host < 99)
     { fgets(fstr, 300, finp);
/*
       sprintf(dstr,\" Unit=%d, LVca=%d LVpa=%d, HVca=%d HVpa=%d\",
                      unit, lvca, lvpa, hvca, hvpa);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\",dstr);delay(2);/* Debug */
       sscanf(fstr,
             \"%d %d%d%d%s%s %d%d%d%s%s %s%s%s%s%s%s %s%s%s%s%s%s %s%s%s%s%s\",
              s00i,  s01i,s02i,s03i,s04w,s05w, s06i,s07i,s08i,s09w,s10w,
              s11w,s12w,s13w,s14w,s15w,s16w,   s17w,s18w,s19w,s20w,s21w,s22w,
              s23w,s24w,s25w,s26w,s27w);
                                        strreplace(s04w,\"\\\"\",\"\");
       strreplace(s05w,\"\\\"\",\"\");
       strreplace(s09w,\"\\\"\",\"\");        strreplace(s10w,\"\\\"\",\"\");
       strreplace(s11w,\"\\\"\",\"\");        strreplace(s12w,\"\\\"\",\"\");
       strreplace(s13w,\"\\\"\",\"\");        strreplace(s14w,\"\\\"\",\"\");
       strreplace(s15w,\"\\\"\",\"\");        strreplace(s16w,\"\\\"\",\"\");
       strreplace(s17w,\"\\\"\",\"\");        strreplace(s18w,\"\\\"\",\"\");
       strreplace(s19w,\"\\\"\",\"\");        strreplace(s20w,\"\\\"\",\"\");
       strreplace(s21w,\"\\\"\",\"\");        strreplace(s22w,\"\\\"\",\"\");
       strreplace(s23w,\"\\\"\",\"\");        strreplace(s24w,\"\\\"\",\"\");
       strreplace(s25w,\"\\\"\",\"\");        strreplace(s26w,\"\\\"\",\"\");
       strreplace(s27w,\"\\\"\",\"\");
/*
       sprintf(dstr,
\" Ca: %d %d %d %d %s %s %d %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
              s00i,  s01i,s02i,s03i,s04w,s05w, s06i,s07i,s08i,s09w,s10w,
              s11w,s12w,s13w,s14w,s15w,s16w,   s17w,s18w,s19w,s20w,s21w,s22w,
              s23w,s24w,s25w,s26w,s27w);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\",dstr);delay(2);/* Debug */
       unit = s02i;
//       unit = s02i - 1;
       host = s06i; if(host >= 99)   /* End of Unit ConfigFile              */
       { break;
       } else
       {   if(host > 9)
         { sprintf(estr,
           \" Reading 'Cnf_Card.txt',\\n    Host number is too much, Unit: %d\",
                        unit); 
           ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
         }
       }
       node = s07i; if(node > nmax)
       { sprintf(estr,
           \" Reading 'Cnf_Card.txt',\\n    Node number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(node == 9)
       { break;
       }
       port = s08i; if(port > pmax)
       { sprintf(estr,
           \" Reading 'Cnf_Card.txt',\\n    Port number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(port == 9)
       { break;
       }
         if(unit > umax)
       { sprintf(estr,
           \" Reading 'Cnf_Card.txt',\\n    Unit number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(unit == 99)
       { break;
       }
         if((node < nmax) && (port < pmax) && (unit < umax) && (unit !=  99))
       { rack = s01i;  crat = s02i;  card = s03i;
//       { rack = s01i - 1;  crat = s02i - 1;  card = s03i - 1;
           switch(card )
         { case  0: lvca =  0; lvix =  0;  hvca =  1; hivo = 0; break;
           case  1: lvca =  0; hvix =  0;  hvca =  1; hivo = 1; break;
           case  2: lvca =  2; lvix =  1;  hvca =  1; hivo = 0; break;
           case  3: lvca =  3; lvix =  2;  hvca =  4; hivo = 0; break;
           case  4: lvca =  3; hvix =  1;  hvca =  4; hivo = 1; break;
           case  5: lvca =  5; lvix =  3;  hvca =  4; hivo = 0; break;
           case  6: lvca =  6; lvix =  4;  hvca =  7; hivo = 0; break;
           case  7: lvca =  6; hvix =  2;  hvca =  7; hivo = 1; break;
           case  8: lvca =  8; lvix =  5;  hvca =  7; hivo = 0; break;
           case  9: lvca =  9; lvix =  6;  hvca = 10; hivo = 0; break;
           case 10: lvca =  9; hvix =  3;  hvca = 10; hivo = 1; break;
           case 11: lvca = 11; lvix =  7;  hvca = 10; hivo = 0; break;
           case 12: lvca = 12; lvix =  8;  hvca = 13; hivo = 0; break;
           case 13: lvca = 12; hvix =  4;  hvca = 13; hivo = 1; break;
           case 14: lvca = 14; lvix =  9;  hvca = 13; hivo = 0; break;
           case 15: lvca = 15; lvix = 10;  hvca = 16; hivo = 0; break;
           case 16: lvca = 15; hvix =  5;  hvca = 16; hivo = 1; break;
           case 17: lvca = 17; lvix = 11;  hvca = 16; hivo = 0; break;
           default: lvca = -1; lvix = -1;  hvca =  0; hivo = 2;
                               hvix = -1;
         }
         busn = (node * pmax) + port;
         sprintf(padr,\"Bus%02d\", busn);
         crat = (node * pmax * umax) + (port * umax) + unit;
         sprintf(stri,\"SCTmops1:Crate%02d.Iden:_original.._value\", crat);
         dpGet(stri, iden);
         sprintf(uadr,\"Crate%02d\", crat); /* Crate Name (Unit ADdRess)      */ 
           if((para == 3) || (para == 6) || (para == 10))
         {   if(hivo == 0)                /* Loading LV/HV_Card Stat        */
           { sprintf(stri,\"SCTmops1:%s.LV_card%02d.Stat:_original.._value\",
                                      uadr, lvix); 
           } else
           { sprintf(stri,\"SCTmops1:%s.HV_card%02d.Stat:_original.._value\",
                                      uadr, hvix); 
           } sscanf(s09w,\"%x\", csts);   dpSet(stri, csts);
         }
         
         sprintf(stri,\"SCTmops1:%s%s\",uadr,\".Stat:_original.._value\"); 
         dpGet(stri, usts);
           if(hivo == 0)
         { sprintf(para_adr,\"LV_card%02d.%s\", lvix, s04w);
         } else
         { sprintf(para_adr,\"HV_card%02d.%s\", hvix, s04w);
         }                          /* Loading DataPoints :                 */
           if((Serv == 0x0) || (Serv == 0x4) || (Serv == 0x8))
         { sprintf(str1,
                 \"SCTmops1:%s.%s.%s\",uadr,para_adr,\"Name:_original.._value\");
             if(hivo == 0)
           {   if(Load == 0x4)       /* Load Config State - Off             */
             {   if((lvpa == 2) || (lvpa == 3))
               {   if(lvpa == 2)
                 { sscanf(s13w,\"%x\",s13i);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13i);
                 } else
                 { sscanf(s13w,\"%f\",s13f);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13f);
                 }
               } else
               {   if((lvpa == 0) || (lvpa == 1))
                 { sscanf(s11w,\"%f\",s11f);
                   sscanf(s12w,\"%f\",s12f);
                   sscanf(s13w,\"%f\",s13f);
                   sscanf(s14w,\"%f\",s14f);
                   sscanf(s15w,\"%f\",s15f);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s13f);
                     if((usts & 0x4C) == 0x44)
                   { setAlerts(str1, 1, s11f, s12f, s14f, s15f);
                   } else
                   { setAlerts(str1, 1, -999, -99, 99, 999);
                   }
                 } else
                 { sscanf(s13w,\"%x\",s13i);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s13i);
                 }
               }
             }
               if(Load == 0x8)       /* Load Config State - Standby         */
             {   if((lvpa == 2) || (lvpa == 3))
               {   if(lvpa == 2)
                 { sscanf(s13w,\"%x\",s13i);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13i);
                 } else
                 { sscanf(s13w,\"%f\",s13f);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13f);
                 }
               } else
               {   if((lvpa == 0) || (lvpa == 1))
                 { sscanf(s17w,\"%f\",s17f);
                   sscanf(s18w,\"%f\",s18f);
                   sscanf(s19w,\"%f\",s19f);
                   sscanf(s20w,\"%f\",s20f);
                   sscanf(s21w,\"%f\",s21f);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s19f);
                     if((usts & 0x4C) == 0x44)
                   { setAlerts(str1, 1, s17f, s18f, s20f, s21f);
                   } else
                   { setAlerts(str1, 1, -999, -99, 99, 999);
                   }
                 } else
                 { sscanf(s19w,\"%x\", s19i);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s19i);
                 }
               }
             }
               if(Load == 0xC)       /* Load Config State - On              */
             {   if((lvpa == 2) || (lvpa == 3))
               {   if(lvpa == 2)
                 { sscanf(s13w,\"%x\",s13i);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13i);
                 } else
                 { sscanf(s13w,\"%f\",s13f);
                   strreplace(str1,\"Name\",\"Send\");
                   dpSet(str1, s13f);
                 }
               } else
               {   if((lvpa == 0) || (lvpa == 1))
                 { sscanf(s23w,\"%f\",s23f);
                   sscanf(s24w,\"%f\",s24f);
                   sscanf(s25w,\"%f\",s25f);
                   sscanf(s26w,\"%f\",s26f);
                   sscanf(s27w,\"%f\",s27f);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s25f);
                     if((usts & 0x4C) == 0x44)
                   { setAlerts(str1, 1, s23f, s24f, s26f, s27f);
                   } else
                   { setAlerts(str1, 1, -999, -99, 99, 999);
                   }
                 } else
                 { sscanf(s25w,\"%x\",s25i);
                   strreplace(str1,\"Name\",\"Recv\");
                   dpSet(str1, s25i);
                 }
               }
             }
           } else
           {   if(Load == 0x4)       /* Load Config State - Off             */
             { sscanf(s13w,\"%x\",s13i);
//                 if(hvpa == 0)
//               {
                 strreplace(str1,\"Name\",\"Send\");
                 dpSet(str1, s13i);
//               } else
//               { strreplace(str1,\"Name\",\"Recv\");
//                 dpSet(str1, s13i);
//               }
             }
               if(Load == 0x8)       /* Load Config State - Standby         */
             { sscanf(s19w,\"%x\",s19i);
//                 if(hvpa == 0)
//               {
                 strreplace(str1,\"Name\",\"Send\");
                 dpSet(str1, s19i);
//               } else
//               { strreplace(str1,\"Name\",\"Recv\");
//                 dpSet(str1, s19i);
//               }
             }
               if(Load == 0xC)       /* Load Config State - On              */
             { sscanf(s25w,\"%x\",s25i);
//                 if(hvpa == 0)
//               {
                 strreplace(str1,\"Name\",\"Send\");
                 dpSet(str1, s25i);
//               } else
//               { strreplace(str1,\"Name\",\"Recv\");
//                 dpSet(str1, s25i);
//               }
             }
           }
         }
/*OPC>*/
           if(/*((usts & 0x4) > 0) && */((Serv == 0x4) || (Serv == 0x8)))
         {   if((para == 0) || (para == 5)) /* LVcaStat                     */
           { sprintf(stri,\"Card%d\", lvix);
             sprintf(str4,\"SCTmops1:%s.LV_card%02d.LVcaStat.%s\",uadr, lvix,\"Send\");
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
             sprintf(str5,\"%s_%s_Send%s\", uadr, \"LVcaStat\", stri);
             sprintf(str6,\"%s_%s_Recv%s\", uadr, \"LVcaStat\", stri);
                                     /* Str7/8 - Full Item Name for Connect.*/
             sprintf(str7,\"%s.%s.%s_%s_Send%s\",
                           padr, uadr, uadr, \"LVcaStat\", stri);
             sprintf(str8,\"%s.%s.%s_%s_Recv%s\",
                           padr, uadr, uadr, \"LVcaStat\", stri);
//           fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
//                                str5, uadr, 0x2000 + lvix);
               if(lvix < 10)
             { fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  1\\n\",
                                str6, uadr, 0x180+iden, card);
             } else
             { fprintf(fpdi,\"%s = %s %x VT_UI1 %2d  1\\n\",
                                  str6, uadr, 0x180+iden, card);
             }
               if(Serv == 0x8)
             { strreplace(str4,\"Send\",\"Recv\");
               setOPCAddress(str4, str8,\"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
             }
           }
             if(para == 4)           /* HVcaStat                            */
           { sprintf(stri,\"Card%d\", hvix);
             sprintf(str4,\"SCTmops1:%s.HV_card%02d.HVcaStat.%s\",uadr, hvix,\"Send\");
                                     /* Str5/6 - OPC Item Name for Send/Recv*/
             sprintf(str5,\"%s_%s_Send%s\", uadr, \"HVcaStat\", stri);
             sprintf(str6,\"%s_%s_Recv%s\", uadr, \"HVcaStat\", stri);
                                     /* Str7/8 - Full Item Name for Connect.*/
             sprintf(str7,\"%s.%s.%s_%s_Send%s\",
                           padr, uadr, uadr, \"HVcaStat\", stri);
             sprintf(str8,\"%s.%s.%s_%s_Recv%s\",
                           padr, uadr, uadr, \"HVcaStat\", stri);
//           fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
//                              str5, uadr, 0x2200 + hvix);
             fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  1\\n\",
                           str6, uadr, 0x180+iden, card);
               if(Serv == 0x8)
             { strreplace(str4,\"Send\",\"Recv\");
               setOPCAddress(str4, str8,\"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
             }
           }
           sprintf(str4,\"SCTmops1:%s.%s.%s\",uadr, para_adr,\"Send\");
             if(hivo == 0)
           { sprintf(stri,\"Card%d\", lvix);
           } else
           { sprintf(stri,\"Card%d\", hvix);
           }                         /* Str5/6 - OPC Item Name for Send/Recv*/
           sprintf(str5,\"%s_%s_Send%s\", uadr, s04w, stri);
           sprintf(str6,\"%s_%s_Recv%s\", uadr, s04w, stri);
                                     /* Str7/8 - Full Item Name for Connect.*/
           sprintf(str7,\"%s.%s.%s_%s_Send%s\", padr, uadr, uadr, s04w, stri);
           sprintf(str8,\"%s.%s.%s_%s_Recv%s\", padr, uadr, uadr, s04w, stri);
/*
           dpSet(\"SCTmops1:Moni.Name:_original.._value\", str6);
                                                         delay(2); /* Debug */
             switch(para)
           { case  0:                  /* LVcaTemp                          */
//                      fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI1\\n\",
//                              str5, uadr, 0x2000 + lvix);
                        if(lvix < 10)
                      { fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  2\\n\",
                                str6, uadr, 0x180+iden, card);
                      } else
                      { fprintf(fpdi,\"%s = %s %x VT_UI1 %2d  2\\n\",
                                str6, uadr, 0x180+iden, card);
                      }
                        if(Serv == 0x8)
                      { strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        setConversion(str4, \"IN\", 0.0, 1.0);
//                        dpConnect(\"OneToOne_toData\", str1);
                      }
                      break;
             case  1:                  /* LVcaPowr                          */
//                      fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI1\\n\",
//                              str5, uadr, 0x2000 + lvix);
                        if(lvix < 10)
                      { fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  3\\n\",
                                str6, uadr, 0x180+iden, card);
                      } else
                      { fprintf(fpdi,\"%s = %s %x VT_UI1 %2d  3\\n\",
                                str6, uadr, 0x180+iden, card);
                      }
                        if(Serv == 0x8)
                      { strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        setConversion(str4, \"IN\", 0.0, 1.0 / 2.5);
//                        dpConnect(\"LVcaPowr_toData\", str1);
                      }
                      break;
             case  2:                  /* LVcaMask                          */
                        if(lvix < 10)
                      { fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      } else
                      { fprintf(fsdi,\"%s = %s %x 1 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      }
                        if(Serv == 0x8)
                      { setOPCAddress(str4, str7,
                                      \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                      }
                      fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  4\\n\",
                              str6, uadr, 0x180+iden, card);
                      break;
             case  3:                  /* LVcaTrip                          */
                        if(lvix < 10)
                      { fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      } else
                      { fprintf(fsdi,\"%s = %s %x 2 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      }
                        if(Serv == 0x8)
                      { setOPCAddress(str4, str7,
                                      \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                         strreplace(str1,\"Send\",\"Comm\");
                         setConversion(str4, \"OUT\", 0.0, 2.5);
//                         dpConnect(\"LVcaTrip_toSend\", str1);
                      }
//                      fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  2\\n\",
//                              str6, uadr, 0x180+iden, card);
                      break;
             case  4:                  /* HVcaMask                          */
                      fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
                              str5, uadr, 0x2300 + hvix);
                        if(Serv == 0x8)
                      { setOPCAddress(str4, str7,
                                      \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                      }
                      fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  2\\n\",
                              str6, uadr, 0x180+iden, card);
                      break;
             case  5:                  /* LVcaTemp                          */
//                      fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI1\\n\",
//                              str5, uadr, 0x2000 + lvix);
                        if(lvix < 10)
                      { fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  2\\n\",
                                str6, uadr, 0x180+iden, card);
                      } else
                      { fprintf(fpdi,\"%s = %s %x VT_UI1 %2d  2\\n\",
                                str6, uadr, 0x180+iden, card);
                      }
                        if(Serv == 0x8)
                      { strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        setConversion(str4, \"IN\", 0.0, 1.0);
//                        dpConnect(\"OneToOne_toData\", str1);
                      }
                      break;
             case  6:                  /* LVcaPowr                          */
//                      fprintf(fsdi,\"%s  = %s %x 3 IO VT_UI1\\n\",
//                              str5, uadr, 0x2000 + lvix);
                        if(lvix < 10)
                      { fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  3\\n\",
                                str6, uadr, 0x180+iden, card);
                      } else
                      { fprintf(fpdi,\"%s = %s %x VT_UI1 %2d  3\\n\",
                                str6, uadr, 0x180+iden, card);
                      }
                        if(Serv == 0x8)
                      { strreplace(str4,\"Send\",\"Recv\");
                        setOPCAddress(str4, str8,
                                      \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        setConversion(str4, \"IN\", 0.0, 1.0 / 2.5);
//                        dpConnect(\"LVcaPowr_toData\", str1);
                      }
                      break;
             case  7:                  /* LVcaMask                          */
                        if(lvix < 10)
                      { fprintf(fsdi,\"%s  = %s %x 1 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      } else
                      { fprintf(fsdi,\"%s = %s %x 1 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      }
                        if(Serv == 0x8)
                      { setOPCAddress(str4, str7,
                                      \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                      }
                      fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  4\\n\",
                              str6, uadr, 0x180+iden, card);
                      break;
             case  8:                  /* LVcaTrip                          */
                        if(lvix < 10)
                      { fprintf(fsdi,\"%s  = %s %x 2 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      } else
                      { fprintf(fsdi,\"%s = %s %x 2 IO VT_UI1\\n\",
                                str5, uadr, 0x2100 + lvix);
                      }
                        if(Serv == 0x8)
                      { setOPCAddress(str4, str7,
                                      \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                        strreplace(str1,\"Send\",\"Comm\");
                        setConversion(str4, \"OUT\", 0.0, 2.5);
//                        dpConnect(\"LVcaTrip_toSend\", str1);
                      }
//                      fprintf(fpdi,\"%s  = %s %x VT_UI1 %2d  2\\n\",
//                              str6, uadr, 0x180+iden, card);
                      break;
             default: ;
           }
         }
/*<OPC*/
/*
         sprintf(dstr,\" Rk=%d Cr=%d Ca=%d LVix=%d HVix=%d %s_%s:%s\",
                        rack, crat, card, lvix, hvix, uadr, para_adr, s04w);
         dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(1);
                                                                   /* Debug */
           if(hivo == 0)
         { lvpa++; if(lvpa >= (lvca_max - 1))
           { lvpa = 0;
           }
         } if(hivo > 0)
         { hvpa++; if(hvpa >= (hvca_max - 1))
           { hvpa = 0;
           }
         }                           /* NO LVcaStats & HVcaStat in Cnf_Card */
         para++; if(para >= (maxp - 3))
         { para = 0;
           grup++; if(grup >= 6)     /* 6 - number of Card groups: LV+HV+LV */
           { unit++;
           }
         }
       }
     } fclose(finp);
   } else
   { fclose(fopc);  fclose(fini);  fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
     sprintf(estr,\" 'Cnf_Crate.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*CRATE*/                            /* Crate(s) parameters reading from CF */
     if(open == 1)
   { sprintf(mstr,\" CRATE LOCAL PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"Cnf_Crate.txt\",\"r\");
     eror = ferror(finp);
   } else
   {
//  Debug(\" LOCAL CONFIG_FILE IS ABSENT, TRYING TO OPEN COMMON CONFIG_FILE \");
     sprintf(mstr,\" CRATE COMMON PVSS & OPC CONFIGs MAKING...\");
     finp = fopen(\"C:/SCT_DCS/Configs/Mops/Cnf_Crate.txt\",\"r\");
     eror = ferror(finp);
   } dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
     if(!eror)
   { fgets(fstr, 300, finp);         /* Skip the first line                 */
     unit=0;  while(unit < umax)
     { fgets(fstr, 300, finp);
       sscanf(fstr,\"%d %d%d%s %d%d%d%s\", s00i, s01i,s02i,s03w,
                                          s04i,s05i,s06i,s07w);
       strreplace(s03w,\"\\\"\",\"\");        strreplace(s07w,\"\\\"\",\"\");
/*
       sprintf(dstr,\" Cr: %d %d %d %s %d %d %d %s\", s00i, s01i,s02i,s03w,
                                                     s04i,s05i,s06i,s07w);
       dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(2);
                                                                   /* Debug */
       unit = s02i;
//       unit = s02i - 1;
       host = s04i; if(host == 99)   /* End of Unit ConfigFile              */
       { break;
       } else
       {   if(host > 9)
         { sprintf(estr,
           \" Reading 'Cnf_Crate.txt',\\n    Host number is too much, Unit: %d\",
                      unit); 
           ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
         }
       }
       node = s05i; if(node > nmax)
       { sprintf(estr,
           \" Reading 'Cnf_Crate.txt',\\n    Node number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(node == 9)
       { break;
       }
       port = s06i; if(port > pmax)
       { sprintf(estr,
           \" Reading 'Cnf_Crate.txt',\\n    Port number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(port == 9)
       { break;
       }
         if(unit > umax)
       { setValue(\"ErorIndi\",\"backCol\",\"Red\");
         sprintf(estr,
           \" Reading 'Cnf_Crate.txt',\\n    Unit number is too much, Unit: %d\",
                      unit); 
         ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
       } if(unit == 99)
       { break;
       }
         if((node < nmax) && (port < pmax) && (unit < umax) && (unit !=  99))
       { rack = s01i;
//       { rack = s01i - 1;
         busn = (node * pmax) + port;
         sprintf(padr,\"Bus%02d\", busn);
         crat = (node * pmax * umax) + (port * umax) + unit;
         sprintf(stri,\"SCTmops1:Crate%02d.Iden:_original.._value\", crat);
         dpGet(stri, iden);
         sprintf(uadr,\"Crate%02d\", crat); /* Crate Name (Unit ADdRess)      */
         sprintf(stri,\"SCTmops1:%s%s\",uadr,\".Stat:_original.._value\");
         sscanf(s07w,\"%x\",usts);        dpSet(stri, usts);
/*OPC>*/
           if(/*((usts & 0x4) > 0) && */((Serv == 0x4) || (Serv == 0x8)))
         { sprintf(str4,\"SCTmops1:%s.Controller\", uadr); /* For Controller  */
           para=0; while(para < crmx)
           {
               switch(para)
             { case  0:                /* CC_Reset                            */
//                        fprintf(fpdi,
//                                \"%s_Reset               = %s %x VT_UI1  0\\n\",
//                                                     uadr, uadr, 0x300+iden);
//                        sprintf(str5,\"%s.CC_Reset.Send\", str4);
//                        sprintf(str7,\"%s.%s.ResetSend\", padr, uadr);
//                          if(Serv == 0x8)
//                        { setOPCAddress(str5, str7,
//                                        \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
//                        }
                        break;
               case  1:              /* CCch_Set                            */
                        fprintf(fpdi,
                                \"%s__Set                = %s %x VT_UI2  0\\n\",
                                                     uadr, uadr, 0x400+iden);
                        sprintf(str5,\"%s.CCch_Set.Send\", str4);
                        sprintf(str7,\"%s.%s.%s__Set\", padr, uadr, uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                        \"VT_UI2\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                        break;
               case  2:              /* CCchRead                            */
                        fprintf(fpdi,
                                \"%s_Read                = %s %x VT_UI2  0\\n\",
                                                     uadr, uadr, 0x500+iden);
                        sprintf(str5,\"%s.CCchRead.Send\", str4);
                        sprintf(str7,\"%s.%s.%s_Read\", padr, uadr, uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                        \"VT_UI2\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                        break;
               case  3:              /* StartIVCurve                        */
//                        fprintf(fpdi,
//                                \"%s_IVcurve             = %s %x VT_UI1  0\\n\",
//                                                     uadr, uadr, 0x500+iden);
                        sprintf(str5,\"%s.StartIVCurve.Send\", str4);
                        sprintf(str7,\"%s.%s.StartIV_Send\", padr, uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.StartIVCurve.Recv\", str4);
                          sprintf(str8,\"%s.%s.StartIV_Recv\", padr, uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  4:              /* CCcf_Set                            */
                        fprintf(fsdi,
                            \"%s                        = %s %x 3 IO VT_UI4\\n\",
                                     \"save\", uadr, 0x1010);
//                        fprintf(fpdi,
//                                \"%s_                    = %s %x VT_UI1  0\\n\",
//                                                     uadr, uadr, 0x500+iden);
                        sprintf(str5,\"%s.CCcf_Set.Send\", str4);
                        sprintf(str7,\"%s.%s.save\", padr, uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                        \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCcf_Set.Recv\", str4);
                          sprintf(str8,\"%s.%s.save\", padr,uadr);
                          setOPCAddress(str6, str8,
                                        \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  5:              /* CCcf_RST                            */
                        fprintf(fsdi,
                                \"%s                   = %s %x 1 IO VT_UI1\\n\",
                                     \"run_state\", uadr, 0x2a01);
//                        fprintf(fpdi,
//                                \"%s_                    = %s %x VT_UI1  0\\n\",
//                                                     uadr, uadr, 0x500+iden);
                        sprintf(str5,\"%s.CCcf_RST.Send\", str4);
                        sprintf(str7,\"%s.%s.run_state\", padr,uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCcf_RST.Recv\", str4);
                          sprintf(str8,\"%s.%s.run_state\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  6:              /* CCce_NMT                            */
                        sprintf(str5,\"%s.CCie_NMT.Send\", str4);
                        sprintf(str7,\"%s.%s.NMT\", padr,uadr);
                          if(Serv == 0x8)
                        { setOPCAddress(str5, str7,
                                       \"VT_UI1\",\"OUT\",\"CANopen\",1,\"Comm\");
                        }
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCie_NMT.Recv\", str4);
                          sprintf(str8,\"%s.%s.NMT\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  7:              /* CC_error                            */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CC_error.Recv\", str4);
                          sprintf(str8,\"%s.%s.Error\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  8:              /* CCieStat                            */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieStat.Recv\", str4);
                          sprintf(str8,\"%s.%s.State\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case  9:              /* CCieBoot                            */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieBoot.Recv\", str4);
                          sprintf(str8,\"%s.%s.bootUpMessage\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 10:              /* CCieEcod                            */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod.Recv\", str4);
                          sprintf(str8,\"%s.%s.emergencyErrorCode\", padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 11:              /* CCieEcod1                           */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod1.Recv\", str4);
                          sprintf(str8,\"%s.%s.specificErrorCodeByte1\",padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 12:              /* CCieEcod2                           */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod2.Recv\", str4);
                          sprintf(str8,\"%s.%s.specificErrorCodeByte2\",padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 13:              /* CCieEcod3                           */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod3.Recv\", str4);
                          sprintf(str8,\"%s.%s.specificErrorCodeByte3\",padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 14:              /* CCieEcod4                           */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod4.Recv\", str4);
                          sprintf(str8,\"%s.%s.specificErrorCodeByte4\",padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 15:              /* CCieEcod5                           */
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCieEcod5.Recv\", str4);
                          sprintf(str8,\"%s.%s.specificErrorCodeByte5\",padr,uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI1\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               case 16:              /* CCcf_Ack                            */
                        fprintf(fpdi,
                                \"%s_Ackn                = %s %x VT_UI2  0\\n\",
                                                     uadr, uadr, 0x540+iden);
                          if(Serv == 0x8)
                        { sprintf(str6,\"%s.CCcf_Ack.Recv\", str4);
                          sprintf(str8,\"%s.%s.%s_Ackn\",padr, uadr, uadr);
                          setOPCAddress(str6, str8,
                                       \"VT_UI2\",\"IN\",\"CANopen\",1,\"Moni\");
                        }
                        break;
               default: ;
             }
/*
             sprintf(dstr,\" Para = %d, Str4: %s\", para, str4);
             dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(2);  /* Debug */
             para++;
           }
         }
/*<OPC*/
       } unit++; 
     } fclose(finp);
   } else
   { fclose(fopc);  fclose(fini);  fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
     sprintf(estr,\" 'Cnf_Crate.txt' File opening \");
     ErrorStop(estr,\" PUSH EXIT [X], CHECK CONFIG FILE & RESTART \");
   }
/*OPC>*/
     if((Serv == 0x4) || (Serv == 0x8))
   {                                 /* Cooling subSyst Alert Flag          */
     setOPCAddress(\"SCTmops1:Monitoring.Crate_Ramp_Off\",
        \"Cooling_emergency_rampdown\",\"VT_FLOAT8\", \"IN\",\"CANopen\",1,\"Moni\");
                                     /* Environmental   Alert Flag          */
     setOPCAddress(\"SCTmops1:Fatl.Numb\",
                         \"Fatl_Numb\",\"VT_FLOAT8\", \"IN\",\"CANopen\",1,\"Moni\");
                                     /* Environmental   Alert Acknowledge   */
     setOPCAddress(\"SCTmops1:Fatl.Indx\",
                         \"Fatl_Indx\",\"VT_FLOAT8\",\"OUT\",\"CANopen\",1,\"Comm\");
     fclose(fsdi);  fclose(fpdo);  fclose(fpdi);
     host = 1;
     node=0; while(node < nmax)
     { port=0; while(port < pmax)
       { busn = (node * pmax) + port;
           if(busn < 10)
         { sprintf(bnam,\"Bus0%d\", busn);
         } else
         { sprintf(bnam,\"Bus%d\" , busn);
         }
         sprintf(stri,
                \"SCTmops1:Host0%d.Node0%d.Port0%d.Stat:_original.._value\",
                          host, node, port);
         dpGet(stri, stat);
           if((stat & 0xC) > 0x0)
         { fprintf(fini,\"%s.NMT               = 1\\n\"  , bnam);
         } port++;
       } node++;
     }
     fprintf(fini,\"\\n[ITEM]\\nCooling_emergency_rampdown = 0\\n\");
     node=0; while(node < nmax)      /* Conversion for the Temperatures     */
     { port=0; while(port < pmax)
       { busn = (node * pmax) + port;
           if(busn < 10)
         { sprintf(bnam,\"Bus0%d\", busn);
         } else
         { sprintf(bnam,\"Bus%d\" , busn);
         }
         sprintf(stri,
                \"SCTmops1:Host0%d.Node0%d.Port0%d.Stat:_original.._value\",
                          host, node, port);
         dpGet(stri, stat);
           if((stat & 0xC) > 0x0)
         { crat=0; while(crat < umax)
           {   if(crat < 10)
             { sprintf(cadr,\"Crate0%d\",crat);
             } else
             { sprintf(cadr,\"Crate%d\" ,crat);
             } crat++;
sprintf(stri,\"%s_%s_MOch_Tm0_RecvChan[0..47:1] = 1.0/(log(%s.%s.%s_MOch_Tm0_RecvChan[0:1]*2.5/800.0)/3435.0+0.0033557)-273.0\\n\",bnam, cadr, bnam, cadr, cadr);
             fprintf(fini, stri);
sprintf(stri,\"%s_%s_MOch_Tm1_RecvChan[0..47:1] = 1.0/(log(%s.%s.%s_MOch_Tm1_RecvChan[0:1]*2.5/800.0)/3435.0+0.0033557)-273.0\\n\",bnam, cadr, bnam, cadr, cadr);
             fprintf(fini, stri);
           }
         } port++;
       } node++;
     }
     fclose(fini);
     fsdi= fopen(\"OPCsdi.bak\",\"r\");  /* ConfigFile for OPC SDoItem param-s  */
     fpdo= fopen(\"OPCpdo.bak\",\"r\");  /* ConfigFile for OPC PDO  parameters  */
     fpdi= fopen(\"OPCpdi.bak\",\"r\");  /* ConfigFile for OPC PDoItem param-s  */
     fini= fopen(\"OPCini.bak\",\"r\");  /* ConfigFile for OPC INItial param-s  */
     int2= 2 + (800 * umax);         /* 800 - SDO lines number_Max in Crate */
     int1=0; while(int1 < int2)
     { fgets(fstr, 300, fsdi);       // int3 = fstr;
         if(1)//int3 != 0)
       { fprintf(fopc, fstr);
       } else
       { break;
       } int1++;
     }
     int2 = 2 + (10 * umax);         /* 10 - PDO lines number_Max in Crate  */
     int1=0; while(int1 < int2)
     { fgets(fstr, 300, fpdo);       // int3 = fstr;
         if(1)//int3 != 0)
       { fprintf(fopc, fstr);
       } else
       { break;
       } int1++;
     }
     int2 = 2 + 80 * umax;           /* 80 - PDO_I lines number_Max in Crate*/
     int1=0; while(int1 < int2)
     { fgets(fstr, 300, fpdi);       // int3 = fstr;
         if(1)//int3 != 0)
       { fprintf(fopc, fstr);
       } else
       { break;
       } int1++;
     }
     int2 = 10 + (2 * umax);         /* 2 - Init lines number_Max in Crate  */
     int1=0; while(int1 < int2)
     { fgets(fstr, 300, fini);       // int3 = fstr;
         if(1)//int3 != 0)
       { fprintf(fopc, fstr);
       } else
       { break;
       } int1++;
     } fclose(fsdi);  fclose(fpdo);  fclose(fpdi);  fclose(fini);
       fclose(fopc);
   }
/*<OPC*/
/*ARCH*/
     if(Load == 0x4)
   { dpGet(\"SCTmops1:Arch.Stat:_original.._value\", arch);
       if(arch > 0)
     { sprintf(mstr,\" ARCHIVE CONNECTIONS (~20 sec)...\");
     } else
     { sprintf(mstr,\" ARCHIVE DISCONNECTIONS (~20 sec)...\");
     }
     dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr); delay(1);/* Debug */
/*chan*/   
     node=0; while(node < nmax)
     { port=0; while(port < pmax)
       { unit=0; while(unit < umax)
         { crat = (node * pmax * umax) + (port * umax) + unit;
             if(crat < 10)
           { sprintf(uadr,
                     \"SCTmops1:Crate0%d%s\",crat,\".Stat:_original.._value\");
           } else
           { sprintf(uadr,
                     \"SCTmops1:Crate%d%s\" ,crat,\".Stat:_original.._value\");
           }
           dpGet(uadr, usts);
           strreplace(uadr,\".Stat:_original.._value\",\"\");
           chan=0; while(chan < cmax)
           {   if(chan < 10)
             { sprintf(cadr,\"%s%s%d.HV_Stat:_original.._value\",
                             uadr,\".Channel0\",chan);
             } else
             { sprintf(cadr,\"%s%s%d.HV_Stat:_original.._value\",
                             uadr,\".Channel\" ,chan);
             } dpGet(cadr, stat);
               if(1)
             { strreplace(cadr,\".HV_Stat:_original.._value\",
                               \".HVchStat.Recv:_archive.._type\");
                 if(((usts & 0xC) >= 0x4) && ((stat & 0xC) >= 0x4) &&
                     (arch > 0))
               { para=0; while(para < hvmx)
                 {   switch(para)
                   { case  1: strreplace(cadr,\"HVchStat\",\"HVchVolt\");  break;
                     case  2: strreplace(cadr,\"HVchVolt\",\"HVchCurr\");  break;
//                     case  3: strreplace(cadr,\"HVchCurr\",\"HVchITrp\");  break;
//                     case  4: strreplace(cadr,\"HVchITrp\",\"HVchRamp\");  break;
                     default: ;
                   }
                   sprintf(str9,\"%s\",cadr);
                   strreplace(str9,\"_archive.._type\",\"_archive.._archive\");
                   sprintf(str8,\"%s\",cadr);
                   strreplace(str8,\"_archive.._type\",\"_archive.1._type\");
                   sprintf(str7,\"%s\",cadr);
                   strreplace(str7,\"_archive.._type\",\"_archive.1._class\");
                   sprintf(str6,\"%s\",\"SCTmops1:_ValueArchive_1\");
                   eror = dpSet(cadr, DPCONFIG_DB_ARCHIVEINFO,
                                str9, TRUE,
                                str8, DPATTR_ARCH_PROC_VALARCH, str7, str6);
                   sprintf(str5,\"%s\",\"DP_ARCH IS SET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               } else
               { para=0; while(para < hvmx)
                 {   switch(para)
                   { case  1: strreplace(cadr,\"HVchStat\",\"HVchVolt\");  break;
                     case  2: strreplace(cadr,\"HVchVolt\",\"HVchCurr\");  break;
//                     case  3: strreplace(cadr,\"HVchCurr\",\"HVchITrp\");  break;
//                     case  4: strreplace(cadr,\"HVchITrp\",\"HVchRamp\");  break;
                     default: ;
                   }
                   eror = dpSet(cadr, DPCONFIG_NONE);
                   sprintf(str7,\"%s\",cadr);
                   sprintf(str5,\"%s\",\"DP_ARCH  RESET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               }
                 if(((usts & 0xC) >= 0x4) && ((stat & 0xC) >= 0x4) &&
                     (arch > 0))
               { para=0; while(para < lvmx)
                 {   switch(para)
//                   { case  0: strreplace(cadr,\"HVchRamp\",\"LVchStat\");  break;
                   { case  0: strreplace(cadr,\"HVchCurr\",\"LVchStat\");  break;
                     case  1: strreplace(cadr,\"LVchStat\",\"LVch_Vcc\");  break;
                     case  2: strreplace(cadr,\"LVch_Vcc\",\"LVps_Vcc\");  break;
                     case  3: strreplace(cadr,\"LVps_Vcc\",\"LVretVcc\");  break;
                     case  4: strreplace(cadr,\"LVretVcc\",\"LVch_Icc\");  break;
                     case  5: strreplace(cadr,\"LVch_Icc\",\"LVch_Vdd\");  break;
                     case  6: strreplace(cadr,\"LVch_Vdd\",\"LVps_Vdd\");  break;
                     case  7: strreplace(cadr,\"LVps_Vdd\",\"LVretVdd\");  break;
                     case  8: strreplace(cadr,\"LVretVdd\",\"LVch_Idd\");  break;
                     case  9: strreplace(cadr,\"LVch_Idd\",\"LVchVCSV\");  break;
                     case 10: strreplace(cadr,\"LVchVCSV\",\"LVchVCSI\");  break;
                     case 11: strreplace(cadr,\"LVchVCSI\",\"LVchPINV\");  break;
                     case 12: strreplace(cadr,\"LVchPINV\",\"LVchPINI\");  break;
                     case 13: strreplace(cadr,\"LVchPINI\",\"MOch_Tm0\");  break;
                     case 14: strreplace(cadr,\"MOch_Tm0\",\"MOch_Tm1\");  break;
//                     case 15: strreplace(cadr,\"MOch_Tm1\",\"LVchDTrp\");  break;
//                     case 16: strreplace(cadr,\"LVchDTrp\",\"LVchCTrp\");  break;
//                     case 17: strreplace(cadr,\"LVchCTrp\",\"LVchTLim\");  break;
//                     case 18: strreplace(cadr,\"LVchTLim\",\"LVchTTrp\");  break;
//                     case 19: strreplace(cadr,\"LVchTTrp\",\"LVchCLKS\");  break;
//                     case 20: strreplace(cadr,\"LVchCLKS\",\"LVchCLKR\");  break;
//                     case 21: strreplace(cadr,\"LVchCLKR\",\"LVchVOut\");  break;
                     default: ;
                   }
                   sprintf(str9,\"%s\",cadr);
                   strreplace(str9,\"_archive.._type\",\"_archive.._archive\");
                   sprintf(str8,\"%s\",cadr);
                   strreplace(str8,\"_archive.._type\",\"_archive.1._type\");
                   sprintf(str7,\"%s\",cadr);
                   strreplace(str7,\"_archive.._type\",\"_archive.1._class\");
                   sprintf(str6,\"%s\",\"SCTmops1:_ValueArchive_1\");
                   eror = dpSet(cadr, DPCONFIG_DB_ARCHIVEINFO,
                                str9, TRUE,
                                str8, DPATTR_ARCH_PROC_VALARCH, str7, str6);
                   sprintf(str5,\"%s\",\"DP_ARCH IS SET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               } else
               { para=0; while(para < lvmx)
                 {   switch(para)
//                   { case  0: strreplace(cadr,\"HVchRamp\",\"LVchStat\");  break;
                   { case  0: strreplace(cadr,\"HVchCurr\",\"LVchStat\");  break;
                     case  1: strreplace(cadr,\"LVchStat\",\"LVch_Vcc\");  break;
                     case  2: strreplace(cadr,\"LVch_Vcc\",\"LVps_Vcc\");  break;
                     case  3: strreplace(cadr,\"LVps_Vcc\",\"LVretVcc\");  break;
                     case  4: strreplace(cadr,\"LVretVcc\",\"LVch_Icc\");  break;
                     case  5: strreplace(cadr,\"LVch_Icc\",\"LVch_Vdd\");  break;
                     case  6: strreplace(cadr,\"LVch_Vdd\",\"LVps_Vdd\");  break;
                     case  7: strreplace(cadr,\"LVps_Vdd\",\"LVretVdd\");  break;
                     case  8: strreplace(cadr,\"LVretVdd\",\"LVch_Idd\");  break;
                     case  9: strreplace(cadr,\"LVch_Idd\",\"LVchVCSV\");  break;
                     case 10: strreplace(cadr,\"LVchVCSV\",\"LVchVCSI\");  break;
                     case 11: strreplace(cadr,\"LVchVCSI\",\"LVchPINV\");  break;
                     case 12: strreplace(cadr,\"LVchPINV\",\"LVchPINI\");  break;
                     case 13: strreplace(cadr,\"LVchPINI\",\"MOch_Tm0\");  break;
                     case 14: strreplace(cadr,\"MOch_Tm0\",\"MOch_Tm1\");  break;
//                     case 15: strreplace(cadr,\"MOch_Tm1\",\"LVchDTrp\");  break;
//                     case 16: strreplace(cadr,\"LVchDTrp\",\"LVchCTrp\");  break;
//                    case 17: strreplace(cadr,\"LVchCTrp\",\"LVchTLim\");  break;
//                     case 18: strreplace(cadr,\"LVchTLim\",\"LVchTTrp\");  break;
//                     case 19: strreplace(cadr,\"LVchTTrp\",\"LVchCLKS\");  break;
//                     case 20: strreplace(cadr,\"LVchCLKS\",\"LVchCLKR\");  break;
//                     case 21: strreplace(cadr,\"LVchCLKR\",\"LVchVOut\");  break;
                     default: ;
                   }
                   eror = dpSet(cadr, DPCONFIG_NONE);
                   sprintf(str7,\"%s\",cadr);
                   sprintf(str5,\"%s\",\"DP_ARCH  RESET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               }
             } chan++;
           }
/*hv_card*/
           card=0; while(card < 6)
           {   if(Load == 0x8)
             { sprintf(cadr,\"%s.HV_card0%d.HVcaStat.Recv:_archive.._type\",
                               uadr, card);
                 if(((usts & 0xC) >= 0x4) && (arch > 0))
               { para=0; while(para < hvca_max)
                 {   switch(para)
                   {
//                     case  1: strreplace(cadr,\"HVcaStat\",\"HVcaMask\");  break;
                     default: ;
                   }
                   sprintf(str9,\"%s\",cadr);
                   strreplace(str9,\"_archive.._type\",\"_archive.._archive\");
                   sprintf(str8,\"%s\",cadr);
                   strreplace(str8,\"_archive.._type\",\"_archive.1._type\");
                   sprintf(str7,\"%s\",cadr);
                   strreplace(str7,\"_archive.._type\",\"_archive.1._class\");
                   sprintf(str6,\"%s\",\"SCTmops1:_ValueArchive_1\");
                   eror = dpSet(cadr, DPCONFIG_DB_ARCHIVEINFO,
                                str9, TRUE,
                                str8, DPATTR_ARCH_PROC_VALARCH, str7, str6);
                   sprintf(str5,\"%s\",\"DP_ARCH IS SET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               } else
               { para=0; while(para < hvca_max)
                 {   switch(para)
                   {
//                     case  1: strreplace(cadr,\"HVcaStat\",\"HVcaMask\");  break;
                     default: ;
                   }
                   eror = dpSet(cadr, DPCONFIG_NONE);
                   sprintf(str7,\"%s\",cadr);
                   sprintf(str5,\"%s\",\"DP_ARCH  RESET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               }
             } card++;
           }
/*lv_card*/
           card=0; while(card < 12)
           {   if(Load == 0x8)
             {   if(card < 10)
               { sprintf(cadr,\"%s.LV_card0%d.LVcaStat.Recv:_archive.._type\",
                               uadr, card);
               } else
               { sprintf(cadr,\"%s.LV_card%d.LVcaStat.Recv:_archive.._type\",
                               uadr, card);
               }
                 if(((usts & 0xC) >= 0x4) && (arch > 0))
               { para=0; while(para < lvca_max)
                 {   switch(para)
                   { case  1: strreplace(cadr,\"LVcaStat\",\"LVcaTemp\");  break;
                     case  2: strreplace(cadr,\"LVcaTemp\",\"LVcaPowr\");  break;
                     case  3: strreplace(cadr,\"LVcaPowr\",\"LVcaMask\");  break;
//                     case  4: strreplace(cadr,\"LVcaMask\",\"LVcaTrip\");  break;
                     default: ;
                   }
                   sprintf(str9,\"%s\",cadr);
                   strreplace(str9,\"_archive.._type\",\"_archive.._archive\");
                   sprintf(str8,\"%s\",cadr);
                   strreplace(str8,\"_archive.._type\",\"_archive.1._type\");
                   sprintf(str7,\"%s\",cadr);
                   strreplace(str7,\"_archive.._type\",\"_archive.1._class\");
                   sprintf(str6,\"%s\",\"SCTmops1:_ValueArchive_1\");
                   eror = dpSet(cadr, DPCONFIG_DB_ARCHIVEINFO,
                                str9, TRUE,
                                str8, DPATTR_ARCH_PROC_VALARCH, str7, str6);
                   sprintf(str5,\"%s\",\"DP_ARCH IS SET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               } else
               { para=0; while(para < hvmx)
                 {   switch(para)
                   { case  1: strreplace(cadr,\"LVcaStat\",\"LVcaTemp\");  break;
                     case  2: strreplace(cadr,\"LVcaTemp\",\"LVcaPowr\");  break;
                     case  3: strreplace(cadr,\"LVcaPowr\",\"LVcaMask\");  break;
//                     case  4: strreplace(cadr,\"LVcaMask\",\"LVcaTrip\");  break;
                     default: ;
                   }
                   eror = dpSet(cadr, DPCONFIG_NONE);
                   sprintf(str7,\"%s\",cadr);
                   sprintf(str5,\"%s\",\"DP_ARCH  RESET\");
/*
                   sprintf(dstr,\" %s: %s\", cadr, str5);
                   strreplace(dstr,\":_archive.._type\",\"\");
                   strreplace(dstr,\"SCTmops1:\",\"\");
                   dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                   para++;
                 }
               }
             } card++;
           } unit++;
         }
/*crate*/
         crat=0; while(crat < umax)  /* Just Example for 'Send' parameters  */
         {   if(0)//Load == 0x8)
           {   if(crat < 10)
             { sprintf(cadr,
                      \"%s.Crate0%d.Controller.CC_Reset.Send:_archive.._type\",
                             uadr, crat);
             } else
             { sprintf(cadr,
                      \"%s.Crate%d.Controller.CC_Reset.Send:_archive.._type\",
                             uadr, crat);
             }
               if(((usts & 0xC) >= 0x4) && (arch > 0))
             { para=0; while(para < crmx)
               {   switch(para)
                 { case  1: strreplace(cadr,\"CC_Reset\",\"CCch_Set\");  break;
                   case  2: strreplace(cadr,\"CCch_Set\",\"CCchRead\");  break;
                   default: ;
                 }
                 sprintf(str9,\"%s\",cadr);
                 strreplace(str9,\"_archive.._type\",\"_archive.._archive\");
                 sprintf(str8,\"%s\",cadr);
                 strreplace(str8,\"_archive.._type\",\"_archive.1._type\");
                 sprintf(str7,\"%s\",cadr);
                 strreplace(str7,\"_archive.._type\",\"_archive.1._class\");
                 sprintf(str6,\"%s\",\"SCTmops1:_ValueArchive_1\");
                 eror = dpSet(cadr, DPCONFIG_DB_ARCHIVEINFO,
                              str9, TRUE,
                              str8, DPATTR_ARCH_PROC_VALARCH, str7, str6);
                 sprintf(str5,\"%s\",\"DP_ARCH IS SET\");
/*
                 sprintf(dstr,\" %s: %s\", cadr, str5);
                 strreplace(dstr,\":_archive.._type\",\"\");
                 strreplace(dstr,\"SCTmops1:\",\"\");
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                 para++;
               }
             } else
             { para=0; while(para < crmx)
               {   switch(para)
                 { case  1: strreplace(cadr,\"CC_Reset\",\"CCch_Set\");  break;
                   case  2: strreplace(cadr,\"CCch_Set\",\"CCchRead\");  break;
                   default: ;
                 }
                 eror = dpSet(cadr, DPCONFIG_NONE);
                 sprintf(str7,\"%s\",cadr);
                 sprintf(str5,\"%s\",\"DP_ARCH  RESET\");
/*
                 sprintf(dstr,\" %s: %s\", cadr, str5);
                 strreplace(dstr,\":_archive.._type\",\"\");
                 strreplace(dstr,\"SCTmops1:\",\"\");
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);
                                                        delay(1);  /* Debug */
                 para++;
               }
             }
           } crat++;
         } port++;
       } node++;
     }
       if(arch == 0x4)
     { dpSet(\"SCTmops1:Arch.Stat:_original.._value\", 0x8);
     }
   }
   dpSet(\"SCTmops1:Moni.Stat:_original.._value\",0x0);    /* Green Background*/
   setValue(\"CtrlIndi\",\"backCol\",\"Green\");
   sprintf(dstr,\" Enter PASSword for    Control Panel access: \");
   setValue(\"CtrlIndi\",\"text\", dstr);
   setValue(\"DiagIndi\",\"backCol\",\"Green\");
   sprintf(dstr,\" Enter PASSword for Diagnostic Panel access: \");
   setValue(\"DiagIndi\",\"text\", dstr);
 }

/* STOP ON ERROR, SHOW ERR0R & DEBUG TEXTs IN THE ERROR & MONI INDICATORs   */
/*                                                                          */
/*                      Estr - Error STRing (text) for Error Indicator      */
/*                      Dstr - Debug STRing (text) for Moni  Indicator      */
/*                                                                          */
 ErrorStop(string Estr, string Dstr)
 { string estr;
 
   dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1);   /* Red Background  */
   dpSet(\"SCTmops1:Moni.Stat:_original.._value\", 0x2);   /*Yellow Background*/
   sprintf(estr,\"%s\\n           PROJECT SCRIPTS ARE STOPPED ! \", Estr);
   dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
   setValue(\"MoniIndi\",\"text\", Dstr); 
   dpSet(\"SCTmops1:Conf.Numb:_original.._value\", 3);      /* Panel  Flag    */
   dpSet(\"SCTmops1:Conf.Stat:_original.._value\", 0x0);
   dpSet(\"SCTmops1:Conf.Data:_original.._value\", 0.0);
   dpSet(\"SCTmops1:Conf.Indx:_original.._value\", 3);      /* Script Flag    */
   while(1) { delay(1); }
 }
 
/* STOP ON PREDEFINED NUMBER, RESET SYNCHRO-SIGNALS FOR PROJECT CLOSING     */
/*                                                                          */
/*                      Dstr - Debug STRing   (text)                        */
/*                      Numb - Selected NUMBer (int)                        */
/*                      Maxi - Selected number MAXImal value                */
/*                                                                          */
 StepStop(string Dstr, float Numb, float Maxi)
 { string dstr;
 
     if(Numb < Maxi)
   { sprintf(dstr,\"\\n  PASS_DEBUGGER! %s: %2.1f < %2.1f; \\n\",Dstr,Numb,Maxi);
     Debug(dstr);
   } else
   { sprintf(dstr,
\"\\n  STOP_DEBUGGER! %s: %2.1f >= %2.1f; CLICK ON EXIT [X]\\n\",Dstr, Numb,Maxi);
     Debug(dstr);
   dpSet(\"SCTmops1:Conf.Numb:_original.._value\", 3);      /* Panel  Flag    */
   dpSet(\"SCTmops1:Conf.Stat:_original.._value\", 0x0);
   dpSet(\"SCTmops1:Conf.Data:_original.._value\", 0.0);
   dpSet(\"SCTmops1:Conf.Indx:_original.._value\", 3);      /* Script Flag    */
     while(1) { delay(1); }
   }
 }" 0
EE E E 1 -1 -1 0  0 790
"" 0 1
EE 2
"CBRef""0"
"EClose"E
""
DISPLAY_LAYER, 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
LAYER, 0 
1
LANG:1 6 Layer1
6 0
"Border1"
""
1 0 795 E E E 1 E 1 E N {0,0,0} E N {51,102,153} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 0 0 1000 800
2 1
"ErorIndi"
""
1 115 1727 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
"/* Error Indicator
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                         ERROR INDICATION PANEL                           */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        S.G.Basiladze

   DESIGN ISSUEs:  This object has a colour indicator of an error message

   MODIF_HISTORY:  01.03.2001 - first version
                   01.09.2003 - 2-nd  version, Error Indicator is modified
                   14.02.2004 - 3-rd  version, OPC Errors & Alerts are added
  ===================================-======================================*/

main()
{ int    host, node, nmax, port, pmax, unit, umax, crate, busn;
  string stri;
  dyn_errClass eror;

   dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x0);
   dpSet(\"SCTmops1:Eror.Numb:_original.._value\", 0);
   dpSet(\"SCTmops1:Eror.Name:_original.._value\", \"\");
   setValue(\"ErorIndi\",\"backCol\",\"Yellow\");
   setValue(\"ErorIndi\",\"text\",
\" WARNING: DON'T USE [X] button for Project CLOSING\\n          CLICK 'OUT' button for CORRECT TERMINATION\");
   dpSet(\"SCTmops1:Fatl.Numb:_original.._value\", 0x0); 
   dpSet(\"SCTmops1:Fatl.Indx:_original.._value\", 0x0); 
   delay(10);
   dpGet(\"SCTmops1:Nmax.Numb:_original.._value\", nmax);       /* Node_Max   */
   dpGet(\"SCTmops1:Pmax.Numb:_original.._value\", pmax);       /* Port_Max   */
   dpGet(\"SCTmops1:Umax.Numb:_original.._value\", umax);       /* Unit_Max   */
   host = 0;
   node=0; while(node < nmax)
   { port=0; while(port < pmax)
     { busn = (node * pmax) + port;
       sprintf(stri,\"SCTmops1:Bus%02d.BusPortError.Recv:_original.._value\",
                                  busn);
       dpSet(stri, 0x0);
       strreplace(stri,\"original\",\"online\");
       dpConnect(\"PortError\", stri);
//       sprintf(stri,\"SCTmops1:Bus%02d.BusPortErrorCode:_original.._value\",
//                                  busn);
//       dpSet(stri, 0x0);
//       strreplace(stri,\"original\",\"online\");
//       dpConnect(\"PortError\", stri);
       unit=0; while(unit < umax)
       { crate = (node * pmax * umax) + (port * umax) + unit;
         sprintf(stri,
       \"SCTmops1:Crate%02d.Controller.CC_error.Recv:_original.._value\",crate);
         dpSet(stri, 0x0);
         strreplace(stri,\"original\",\"online\");
         dpConnect(\"UnitError\", stri);
         sprintf(stri,
       \"SCTmops1:Crate%02d.Controller.CCieEcod.Recv:_original.._value\",crate);
         dpSet(stri, 0x0);
         strreplace(stri,\"original\",\"online\");
         dpConnect(\"UnitError\", stri);
           unit++;
       } port++;
     } node++;
   }                                 /* First Error will be indicated :     */
/**/
   dpConnect(\"ErrorIndicator\",\"SCTmops1:Eror.Stat:_online.._value\");      /**/
                                     /* Last  Error will be indicated :     */
/*
   dpConnect(\"ErrorIndicator\",\"SCTmops1:Eror.Numb:_online.._value\");      /**/
   eror = getLastError();
     if(dynlen(eror) > 0)
   { setValue(\"\", \"color\", \"_dpdoesnotexist\");
   }
 }

/* SHOW DCS ERRORs IN TEXT PANEL                                            */
/*                                                                          */
/*                      Ecod - Error CODe - ALWAYS is ODD                   */
/*                             Bits  0- 1:  Severity of Error:              */
/*                                            0 - Normal (No Error),        */
/*                                            2 - Warning,                  */
/*                                            1 - Alarm,                    */
/*                                            3 - Fatal                     */
/*                                                                          */
 ErrorIndicator(string Dapo, int Eror)
 { int    ecod, enmb;
   string estr, stri, date;
   time   tyme;
   
   dpGet(\"SCTmops1:Eror.Stat:_original.._value\", ecod);
     if((ecod & 0x3) > 0)
   { tyme = getCurrentTime();
     date = formatTime(\"%H:%M:%S %d/%m/%Y\", tyme);
     dpGet(\"SCTmops1:Eror.Name:_original.._value\", estr);
       if((ecod & 0x1) == 0)
     { setValue(\"ErorIndi\",\"backCol\",\"Yellow\");
       dpGet(\"SCTmops1:Warn.Numb:_original.._value\", enmb);
       enmb++;
       dpSet(\"SCTmops1:Warn.Numb:_original.._value\", enmb);
       sprintf(stri,\" WARNING %3d;  Time %s\\n   %s \", enmb, date, estr);
     } else
     { setValue(\"ErorIndi\",\"backCol\",\"Red\");
       dpGet(\"SCTmops1:Eror.Numb:_original.._value\", enmb);
       enmb++;
       dpSet(\"SCTmops1:Eror.Numb:_original.._value\", enmb);
       sprintf(stri,\" ERROR %3d;  Time %s\\n   %s \", enmb, date, estr);
     }
     setValue(\"ErorIndi\",\"text\", stri);
/**/
     sprintf(stri,\"\\n %s \\n\", stri);
     Debug(stri);                                             /* Debugger   */
   } else
   { setValue(\"ErorIndi\",\"backCol\",\"Green\");
     setValue(\"ErorIndi\",\"text\",\" NO ERROR EVENTs\");
   }
 }

/* CAN_BUS AND ELMB ERRORS FROM OPC_SERVER                                  */
/*                                                                          */
 PortError(string Dapo, int Eror)
 { string name, addr, mess, estr;

     if(Eror)
   { sprintf(name,\"%s\", Dapo);
     strreplace(name,\"SCTmops1:\",\"\");
     strreplace(name,\":online..value\",\"\");
     strreplace(name,\":_online.._value\",\"\");
     sprintf(addr,\"%s\", Dapo);
     strreplace(addr,\"BusPortError\",\"BusPortErrorCode\");
     dpGet(addr, mesg);
     dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x1); /* Red Background  */
     sprintf(estr,\" %s = %2Xh\\n    %s \", name, Eror, mesg); 
     dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
/*
     sprintf(name,\"%s%s%s\",\"SCTmops1:\",name,\":_original.._value\");
     dpSet(name, 0x0);               /* Reset Error (option)                */
   }
 }
 
  UnitError(string Dapo, int Eror)
 { int    len1, len2, err1, err2, err3, err4, err5;
   string name, stri, estr;

     if(Eror)
   { sprintf(name,\"%s\", Dapo);
     strreplace(name,\"SCTmops1:\",\"\");
     strreplace(name,\":online..value\",\"\");
     strreplace(name,\":_online.._value\",\"\");
     sprintf(stri,\"%s\", name);       len1 = strlen(stri);
     strreplace(stri,\"CCieEcod\",\"\"); len2 = strlen(stri);
       if(len2 < len1)
     { strreplace(stri,\"CCieEcod\",\"CCieEcod1\");
       sprintf(stri,\"%s%s%s\",\"SCTmops1:\",stri,\":_original.._value\");
                                                  dpGet(stri, err1);
       strreplace(stri,\"CCieEcod1\",\"CCieEcod2\");  dpGet(stri, err2);
       strreplace(stri,\"CCieEcod2\",\"CCieEcod3\");  dpGet(stri, err3);
       strreplace(stri,\"CCieEcod3\",\"CCieEcod4\");  dpGet(stri, err4);
       strreplace(stri,\"CCieEcod4\",\"CCieEcod5\");  dpGet(stri, err5);
       sprintf(estr,
\" %s = %Xh\\n    Byte1 Byte2 Byte3 Byte4 Byte5\\n    %2Xh,  %2Xh,  %2Xh,  %2Xh,  %2Xh\",
                     name, Eror, err1, err2, err3, err4, err5); 
       dpSet(\"SCTmops1:Eror.Stat:_original.._value\",0x2);    /* Yellow Backg*/
       dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr); 
     } else
     {   if(Eror == 0x10)            /* If Henk message - 'SDO Absent' got  */
       { dpSet(\"SCTmops1:Eror.Stat:_original.._value\",0x2);  /* Yellow Backg*/
       } else
       { dpSet(\"SCTmops1:Eror.Stat:_original.._value\",0x1);  /* Red Backgr-d*/
       } sprintf(estr,\" %s = %2Xh \", name, Eror);
       dpSet(\"SCTmops1:Eror.Name:_original.._value\", estr);
     }
   }
 }" 0
 "/* Error Indicator
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
  dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x0);
  dpSet(\"SCTmops1:Eror.Numb:_original.._value\", 0);
  dpSet(\"SCTmops1:Eror.Name:_original.._value\", \"\");
}" 0
 0 1 1 0 1 E U  1 E 12 722 428 788
1 2 0 "s" 0 0 0 64 0 0  12 722
 1
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
1
LANG:1 16  NO ERROR EVENTs
4 28
"Line13"
""
1 10 791 E E E 1 E 1 E N {255,255,255} E N {255,255,255} E E
 E E
9 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 2 1 0 1 E  990 791 10 791
4 27
"Line12"
""
1 10 792 E E E 1 E 1 E N {0,0,0} E N {255,255,255} E E
 E E
8 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E  990 792 10 792
2 29
"MoniIndi"
""
1 1107 2995 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
10 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
"/* Monitor & Debug Indicator
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                 MONITOR & DEBUGGER INDICATION OBJECT                     */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        S.G.Basiladze

   DESIGN ISSUEs:  This object has a colour indicator of the Monitoring
                   and Debugger messages

   MODIF_HISTORY:  01.03.2001 - first version
                   22.12.2002 -  2-nd version, Colours made standard
                   27.09.2003 -  3-rd version, Message is taking from DaPo
  ===================================-======================================*/

main()
{ dyn_errClass eror;

  dpSet(\"SCTmops1:Moni.Name:_original.._value\", \"\");
  dpConnect(\"MoniDebugger\",\"SCTmops1:Moni.Name:_original.._value\");
  eror = getLastError();
    if(dynlen(eror) > 0)
  { setValue(\"\", \"color\", \"_dpdoesnotexist\");
  }
}

/* SHOW 'WHAT SYSTEM IS DOING' AND DEBUG MESSAGES IN THE TEXT PANEL         */
/*                                                                          */
 MoniDebugger(string Dapo, int Stat)
 { int    stat;
   string mstr;

   dpGet(\"SCTmops1:Moni.Stat:_original.._value\", stat);
   switch(stat & 0x7)
   { case  0:                        /* Normal Status                       */
              setValue(\"MoniIndi\",\"backCol\",\"Green\");
              break;
     case  2:                        /* Warning Status                      */
              setValue(\"MoniIndi\",\"backCol\",\"Yellow\");
              break;
     case  1:                        /* Alarm   Status                      */
              setValue(\"MoniIndi\",\"backCol\",\"Red\");
              break;
     case  3:                        /* Disable Status                      */
              setValue(\"MoniIndi\",\"backCol\",\"Grey\");
              break;
     default: setValue(\"MoniIndi\",\"backCol\",\"Blue\");
   }
   dpGet(\"SCTmops1:Moni.Name:_original.._value\", mstr);
   setValue(\"MoniIndi\",\"text\", mstr);
 }" 0
 E 0 1 1 0 1 E U  1 E 597 722 988 743
1 2 0 "s" 0 0 0 64 0 0  597 722
 1
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
1
LANG:1 34                 Monitor & Debugger
1 35 0 "11" 6
0
1 36 0 "12" 6
0
1 37 0 "13" 6
0
1 38 0 "14" 6
0
1 39 0 "15" 6
0
1 40 0 "16" 6
0
1 41 0 "17" 6
0
1 42 0 "18" 6
0
14 3
"DiagIndi"
""
1 592 767 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
3 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
592 765 991 791
3 "s" 0 0 0 0 0 0 
"/* PASSword Diagnostic
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Green\");
  setValue(\"\",\"text\",\"\");
}" 0

"/* PASSword Diagnostic
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                PASSWORD DIAGNOSTIC & INDICATION OBJECT                   */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        S.G.Basiladze

   DESIGN ISSUEs:  This object may be used for password diagnostic and
                   as indicator of system structure messages

   MODIF_HISTORY:  01.03.2001 - first version
  ===================================-======================================*/

main()
{ 
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Black\");
  setValue(\"\",\"text\",\" Enter PASSword for Diagnostic Panel access: \");
}" 0

"/* PASSword Diagnostic
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{ string pass;

  getValue(\"\",\"text\", pass);
    if(pass == \"\")
  { ChildPanelOnCentralModal(\"_SCT_Diagn_MoPS.pnl\",\"\",\"\");
  } else
  { setValue(\"\",\"backCol\",\"Red\");
    setValue(\"\",\"foreCol\",\"Blue\");
    setValue(\"\", \"text\",\" Incorrect password, please try again...\");
  } delay(2);
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Black\");
  setValue(\"\",\"text\",\" Enter PASSword for Diagnostic Panel access: \");
}" 0

14 4
"CtrlIndi"
""
1 592 745 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
4 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
592 743 991 769
3 "s" 0 0 0 0 0 0 
"/* PASSword Control
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Green\");
  setValue(\"\",\"text\",\"\");
}" 0

"/* PASSword Control
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                 PASSWORD CONTROL & INDICATION OBJECT                     */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        S.G.Basiladze

   DESIGN ISSUEs:  This object may be used for password control and
                   as indicator of system structure messages

   MODIF_HISTORY:  01.03.2001 - first version
  ===================================-======================================*/

main()
{ 
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Black\");
  setValue(\"\",\"text\",\" Enter PASSword for Control    Panel access: \");
}" 0

"/* PASSword Control
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{ string pass;

  getValue(\"\",\"text\", pass);
    if(pass == \"\")
  { ChildPanelOnCentralModal(\"_SCT_Ctrl_MoPS.pnl\",\"\",\"\");
  } else
  { setValue(\"\",\"backCol\",\"Red\");
    setValue(\"\",\"foreCol\",\"Blue\");
    setValue(\"\", \"text\",\" Incorrect password, please try again...\");
  } delay(2);
  setValue(\"\",\"backCol\",\"Green\");
  setValue(\"\",\"foreCol\",\"Black\");
  setValue(\"\",\"text\",\" Enter PASSword for Control    Panel access: \");
}" 0

1 18 0 "" 12
0
1 19 0 "" 11
0
1 20 0 "" 24
0
1 23 0 "" 13
0
1 34 0 "" 49
0
1 43 0 "19" 9
0
1 44 0 "20" 9
0
1 45 0 "21" 9
0
1 46 0 "22" 9
0
1 47 0 "23" 9
0
1 48 0 "24" 9
0
1 25 1 "" 1
0
14 30
"ScanIndi"
""
1 897 10 E E E 1 E 1 E N {0,0,0} E N {255,255,255} E E
 E E
10 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
895 8 991 34
3 "s" 0 0 0 0 0 0 
E
"/* Scan Indicator
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{ dyn_errClass eror;

  dpConnect(\"MonitoringScan\",\"SCTmops1:Syst.Stat:_original.._value\");
  dpConnect(\"MonitoringScan\",\"SCTmops1:Busy.Numb:_original.._value\");
//  dpConnect(\"ShowScan\"      ,\"SCTmops1:Scan.Numb:_original.._value\");
  setValue(\"ScanIndi\",\"backCol\",\"Green\");
  setValue(\"ScanIndi\",\"text\",\" Scan:     0\");
  eror = getLastError();
    if(dynlen(eror) > 0)
  { setValue(\"\", \"color\", \"_dpdoesnotexist\");
  }
}

// ShowScan(string Dapo, int Scan)
// { int    scan;
//   string stri;
// 
//   setValue(\"ScanIndi\",\"backCol\",\"Yellow\");
//   dpGet(\"SCTmops1:Scan.Numb:_original.._value\", scan);
//   sprintf(stri,\" Scan: %5d\", scan);
//   setValue(\"ScanIndi\",\"text\", stri);
//   delay(1);
//   setValue(\"ScanIndi\",\"backCol\",\"Green\");
// }

/* MONITORING_SCAN NUMBER TO INDICATOR AND DATA RANDOM_SIMULATION           */
/*                                                                          */
 MonitoringScan(string Dapo, int Stat)
 { int    host, hmax, node, nmax, port, pmax, unit, umax, usys, crat;
   int    warn, warn_max, alrm, alrm_max, int1;
   int    stat, syss, stus, used, pmon, scan, simu, wait;
   string mstr, stri;
 
   dpGet(\"SCTmops1:Syst.Stat:_original.._value\", syss);
   dpGet(\"SCTmops1:Host.Stat:_original.._value\", stat);
   dpGet(\"SCTmops1:Conf.Indx:_original.._value\", used);  /* Check Scri Flag */
     if(((stat & 0x3C) == 0) && ((syss & 0x3C) == 0) && (used == 2))
   { delay(3);
     dpSet(\"SCTmops1:Conf.Numb:_original.._value\", 0);   /* Reset Panel Flag*/
     PanelOff();
   }
     if((syss & 0x3C) == 0x2C)       /* Local 'ON' State                    */
   { dpGet(\"SCTmops1:Host.Numb:_original.._value\", host);
     sprintf(stri,\"SCTmops1:Host0%d.Pmon:_original.._value\", host);
     dpGet(stri, pmon);                 delay(pmon);
     sprintf(stri,\"SCTmops1:Host0%d.Simu:_original.._value\", host);
     dpGet(stri, simu);
     dpGet(\"SCTmops1:Hmax.Numb:_original.._value\", hmax);
     dpGet(\"SCTmops1:Nmax.Numb:_original.._value\", nmax);
     dpGet(\"SCTmops1:Pmax.Numb:_original.._value\", pmax);
     dpGet(\"SCTmops1:Umax.Numb:_original.._value\", umax);
     dpGet(\"SCTmops1:Warn.Indx:_original.._value\", warn_max);
     dpGet(\"SCTmops1:Alrm.Indx:_original.._value\", alrm_max);
     dpGet(\"SCTmops1:Scan.Numb:_original.._value\", scan);
     usys= hmax * nmax * pmax * umax;/* Number of Units in the SYStem       */
       while(1)
     { dpGet(\"SCTmops1:Host.Stat:_original.._value\", stat);
         if((stat & 0xC) != 0xC)
       { break;
       }       
       scan++; dpSet(\"SCTmops1:Scan.Numb:_original.._value\", scan);
       setValue(\"ScanIndi\",\"backCol\",\"Yellow\");
       sprintf(stri,\" Scan: %5d\", scan);
       setValue(\"ScanIndi\",\"text\", stri);
         if(simu)                    /* Data Simulation mode                */
       { sprintf(mstr,\" SIMULATION SCAN...\");
         dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr);
         wait = pmon;
           if((scan & 0x1) == 1)     /* Odd Scan number                     */
         { int1=0; while(int1 < usys)/* Simulation From start Chan =  0     */
           { RandomData_24Chan(int1,  0);
             int1++; if(wait > 8)
             { wait = wait - 8;
             }
           }
         } else                      /* Even Scan number                    */
         { int1=0; while(int1 < usys)/* Simulation From start Chan = 32     */
           { RandomData_24Chan(int1, 24);
             int1++; if(wait > 8)
             { wait = wait - 8;
             }
           }
         }
       } else
       { sprintf(mstr,\" MONITORING SCAN...\");
         dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr);
         wait = pmon;
       } warn = 0;    alrm = 0;
       host=0; //while(host < hmax)
       { node=0; while(node < nmax)
         { port=0; while(port < pmax)
           { unit=0; while(unit < umax)
             { crat = (node * pmax * umax) + (port * umax) + unit;
                 if(crat < 10)
               { sprintf(stri,
                     \"SCTmops1:Crate0%d%s\",crat,\".Stat:_original.._value\");
               } else
               { sprintf(stri,
                     \"SCTmops1:Crate%d%s\" ,crat,\".Stat:_original.._value\");
               } dpGet(stri, stat);
                 if((stat & 0xC) > 0x0)   /* If Unit is included in SystConf*/
               { dpGet(\"SCTmops1:Syst.Stat:_original.._value\", syss);
                 stus = syss & 0x3;
                   if((stat & 0x3) == 0x0)
                 {   if((warn < warn_max) && (alrm < alrm_max))
                   {   if((stus == 1) || (stus == 2))
                     { syss = syss & 0x7FFFFFFC;   /* Set System Norm_status*/
                       dpSet(\"SCTmops1:Syst.Stat:_original.._value\", syss);
                     }
                   }
                 }
                   if((stat & 0x3) == 0x2)
                 { warn++; if(warn >=warn_max)/*   Set System Warning status*/
                   {   if((stus == 0) || (stus == 1))
                     { syss = (syss & 0x7FFFFFFC) | 0x2;
                       dpSet(\"SCTmops1:Syst.Stat:_original.._value\", syss);
                     }
                   }
                 } 
                   if((stat & 0x3) == 0x1)
                 { alrm++; if(alrm >=alrm_max)/*   Set System Alarm status  */
                   {   if((stus == 0) || (stus == 2))
                     { syss = (syss & 0x7FFFFFFC) | 0x1;
                       dpSet(\"SCTmops1:Syst.Stat:_original.._value\", syss);
                     }
                   }
                 }
/*
                 sprintf(mstr,
                      \" Cr=%d syS=%Xh, unS=%Xh; W=%d, Wmx=%d; F=%d, Fmx=%d\",
                        crat, syss, stat, warn, warn_max, alrm, alrm_max);
                 dpSet(\"SCTmops1:Moni.Name:_original.._value\",mstr); delay(2);
                                                                   /* Debug */
               } unit++;
             } port++;
           } node++;
         } //host++;
       }
       setValue(\"ScanIndi\",\"backCol\",\"Green\");
         while(wait > 0)
       { delay(1);                      wait--;
         dpGet(\"SCTmops1:Host.Stat:_original.._value\", stat);
           if((stat & 0xC) == 0xC)
         { sprintf(mstr,\" WAIT %2d sec...\", wait);
           dpSet(\"SCTmops1:Moni.Name:_original.._value\", mstr);
         } else
         { break;
         }
       }
     }
   }
 }
 
/* CHAN DATA RANDOM GAUSSIAN SIMULATION AROUND OF THE NORMAL VALUE          */
/*                                                                          */
/*                      Unum - Crate (Unit) system NUMber                   */
/*                      From - Start FROM what Chan       ( '0' or '24' )   */
/*                                                                          */
 RandomData_24Chan(int Unum, int From)
 { int     chan, usts, stat, int1;
   float   bias, rndm, warl, warh;
   dyn_int inpi, outi;
   string  uadr, cadr, dstr;
   
     if(Unum < 10)
   { sprintf(uadr,\"SCTmops1:Crate0%d.Stat:_original.._value\", Unum);
   } else
   { sprintf(uadr,\"SCTmops1:Crate%d.Stat:_original.._value\" , Unum);
   } dpGet(uadr, usts);
   strreplace(uadr,\".Stat:_original.._value\",\"\");
     if((usts & 0x4C) == 0x44)
   { chan=From; while(chan < (From + 24))
     {   if(chan < 10)
       { sprintf(cadr,\"%s.Channel0%d.Stat:_original.._value\",uadr, chan);
       } else
       { sprintf(cadr,\"%s.Channel%d.Stat:_original.._value\" ,uadr, chan);
       } dpGet(cadr, stat);
         if((stat & 0x4C) == 0x44)
       { //strreplace(cadr,\"HV_Stat\",\"LV_Stat\");
         //dpGet(cadr, stat);
           if((stat & 0x4C) == 0x44) /* If HV_Para & LV_Para are included   */
         { inpi = makeDynInt();      /* '32 Random Raw Values' subroutine   */
           inpi[1] = 10000;          /* Random value Peak   = 10000 / 2     */
           inpi[2] =    10;          /* Gaussian distribution Form          */
           int1=0; while(int1 < 32)  /* Random values shift = 0             */
           { inpi[int1 + 3] = 0;        int1++;
           }
           outi = makeDynInt();
           userDefFunc(\"DllPvss\", \"Random32integers_C\", inpi, outi);

           strreplace(cadr,\"Stat\",\"HVchStat.Recv\");
           bias = 0.0;
           dpSet(cadr, bias);
           
           strreplace(cadr,\":_original.._value\",\"\");
           strreplace(cadr,\"HVchStat\",\"HVchVolt\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[ 2] - 5000;
           rndm = rndm / 10000.0;               /* Sigma Control: ~ 2        */
           dpSet(cadr + \":_original.._value\", bias + rndm);

           strreplace(cadr,\"HVchVolt\",\"HVchCurr\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[ 3] - 5000;
           rndm = rndm / 10000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
//           strreplace(cadr,\"HVchCurr\",\"HVchITrp\");
//           strreplace(cadr,\"HVchITrp\",\"HVchRamp\");

           strreplace(cadr,\"HVchCurr\",\"LVchStat\");
           bias =   0.0;
           dpSet(cadr + \":_original.._value\", bias);
           
           strreplace(cadr,\"LVchStat\",\"LVch_Vcc\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[ 7] - 5000;
           rndm = rndm / 100000.0;             /* Sigma Control: ~ 0.2      */
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVch_Vcc\",\"LVps_Vcc\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[ 8] - 5000;
           rndm = rndm / 100000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVps_Vcc\",\"LVretVcc\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[ 9] - 5000;
           rndm = rndm / 1000000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVretVcc\",\"LVch_Icc\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[10] - 5000;
           rndm = rndm / 20.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVch_Icc\",\"LVch_Vdd\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[11] - 5000;
           rndm = rndm / 100000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVch_Vdd\",\"LVps_Vdd\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[12] - 5000;
           rndm = rndm / 100000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVps_Vdd\",\"LVretVdd\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[13] - 5000;
           rndm = rndm / 1000000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVretVdd\",\"LVch_Idd\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[14] - 5000;
           rndm = rndm / 20.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVch_Idd\",\"LVchVCSV\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[15] - 5000;
           rndm = rndm / 100000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVchVCSV\",\"LVchVCSI\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[16] - 5000;
           rndm = rndm / 100000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVchVCSI\",\"LVchPINV\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[17] - 5000;
           rndm = rndm / 10000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVchPINV\",\"LVchPINI\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[18] - 5000;
           rndm = rndm / 1000000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"LVchPINI\",\"MOch_Tm0\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[19] - 5000;
           rndm = rndm / 1000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
           
           strreplace(cadr,\"MOch_Tm0\",\"MOch_Tm1\");
           dpGet(cadr + \":_alert_hdl.3._l_limit\", warl,
                 cadr + \":_alert_hdl.3._u_limit\", warh);
           bias = (warl + warh) / 2;  rndm = outi[20] - 5000;
           rndm = rndm / 1000.0;
           dpSet(cadr + \":_original.._value\", bias + rndm);
//           strreplace(cadr,\"MOch_Tm1\",\"LVchDTrp\");
//           strreplace(cadr,\"LVchDTrp\",\"LVchCTrp\");
//           strreplace(cadr,\"LVchCTrp\",\"LVchTLim\");
//           strreplace(cadr,\"LVchTLim\",\"LVchTTrp\");
//           strreplace(cadr,\"LVchTTrp\",\"LVchCLKS\");
//           strreplace(cadr,\"LVchCLKS\",\"LVchCLKR\");
//           strreplace(cadr,\"LVchCLKR\",\"LVchVOut\");
/*
             if((Unum == 0) && (chan== 0))
           { sprintf(dstr,\" %s Bias=%3.1f Rand=%3.1f\",cadr, bias, rndm);
             strreplace(dstr,\"SCTmops1:\",\"\");
             dpSet(\"SCTmops1:Moni.Name:_original.._value\", dstr);  delay(1);
           }                                                       /* Debug */
         }
       } chan++;
     }
   }
 }" 0

E
0
LAYER, 1 
1
LANG:1 6 Layer2
0
LAYER, 2 
1
LANG:1 6 Layer3
0
LAYER, 3 
1
LANG:1 6 Layer4
0
LAYER, 4 
1
LANG:1 6 Layer5
0
LAYER, 5 
1
LANG:1 6 Layer6
0
LAYER, 6 
1
LANG:1 6 Layer7
0
LAYER, 7 
1
LANG:1 6 Layer8
0
3 0 ""
"_SCT_Stat_MoPS.pnl" 440 710 T 6 1 0 1  -1 23  
0
3 1 ""
"objects\\SCT_mTAB_MoPS.pnl" 10 10 T 7 1 0 1  -20 442  
0
0