Example #1
0
//---------------------------------------------------------------------------
// Сохраняю установки измерения в файл
bool SaveSettings(MeasurInfo& measurInfo)
{
        if (access(lpIniFileName.c_str(), 0) == 0)
        {
        	//
        	TIniFile *Ini = new TIniFile(lpIniFileName);
        	//
        	try
		{
                	if (Ini->SectionExists("History"))
                	{
                		Ini->WriteInteger("History", "type_check_watt", measurInfo.type_check_watt);
                		Ini->WriteFloat("History", "begin_lw", measurInfo.begin_lw);
                		Ini->WriteFloat("History", "end_lw", measurInfo.end_lw);
                		Ini->WriteFloat("History", "step_lw", measurInfo.step_lw);
                                Ini->WriteFloat("History", "calc_lw", measurInfo.calc_lw);
                		Ini->WriteFloat("History", "time_accumulation", measurInfo.time_accumulation);
                		Ini->WriteBool("History", "makeKorK_bw", measurInfo.makeKorK_bw);
                		Ini->WriteBool("History", "makeKorK_cw", measurInfo.makeKorK_cw);
                		Ini->WriteBool("History", "makeSetZero", measurInfo.makeSetZero);
                                return true;
                        }
		}
        	__finally
		{
	        	delete Ini;
                	Ini = NULL;
		}
        }
Example #2
0
//---------------------------------------------------------------------------
void __fastcall TfmAjustes::btAjustaClick(TObject *Sender)
{
try
  {
  int nponto, conf, P;
  float kconv1, kconv2, fval;
  String S;

  nponto = edNPonto->Text.ToInt();

  S = edKConv1->Text;
  if ( ( P = S.Pos(",") ) !=0 )
    {
    S[P] = '.';
    }
  fval = atof(S.c_str());
  if ( fval >= HUGE_VAL || fval <= -HUGE_VAL || fval == 0 )
     {
     throw Exception("Invalid kconv1.");
     }
  kconv1 = fval;

  S = edKConv2->Text;
  if ( ( P = S.Pos(",") ) != 0 )
    {
    S[P] = '.';
    }
  fval = atof(S.c_str());
  if ( fval >= HUGE_VAL || fval <= -HUGE_VAL )
    {
    throw Exception("Invalid kconv2.");
    }
  kconv2 = fval;

  conf = edConf->Text.ToInt();

  if ( nponto <= 0 )
    {
    throw Exception("Invalid point number.");
    }

  if ( ( int (nponto + kconv1 + kconv2) % 11) +
       ( int (nponto + kconv1 + kconv2) % 17)
       != conf )
    {
    throw Exception("Invalid Data.");
    }

  TIniFile *pIni = new TIniFile( ".\\conf\\adjusts.ini" );
  pIni->WriteFloat( nponto, "KCONV1", kconv1 );
  pIni->WriteFloat( nponto, "KCONV2", kconv2 );
  delete pIni;

  lbErro->Caption = "OK!";
  }
catch ( Exception &E )
  {
  lbErro->Caption = "ERROR! " + E.Message;
  }

}