コード例 #1
0
void __fastcall TAcquireThread::Draw() {
	switch(mm) {
	case 0:
//		StatusRecForm->Label1->Caption = s;
//		StatusRecForm->Label2->Caption = s1;
		break;
	case 1:
		StatusRecForm->Close();
		MainForm->StartMonitoring();
		break;
	case 2:
//		StatusRecForm->Label2->Caption = "Количество блоков " + IntToStr
//			(num_blocks);
		break;
	case 3:
//		StatusRecForm->ProgressBar1->Position = pos;
		break;
	case 4:
		TFormatSettings FormatSettings;
		GetLocaleFormatSettings(GetSystemDefaultLCID(), FormatSettings);
		FormatSettings.ThousandSeparator = 160;
		FormatSettings.CurrencyString = "";
		FormatSettings.CurrencyDecimals = 0;

		MainForm->ListView2->Items->Item[0]->SubItems[0].Text = FloatToStr(t)
			+ " нс";
		MainForm->ListView2->Items->Item[1]->SubItems[0].Text = FloatToStrF
			(AcfParams._time * 1e-6, ffFixed, 5, 2) + " с";
		MainForm->ListView2->Items->Item[2]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((double(AcfParams.vybr))), FormatSettings);
		MainForm->ListView2->Items->Item[3]->SubItems[0].Text = FloatToStr
			(AcfParams.zashk / n0 * 100) + "%";
		MainForm->ListView2->Items->Item[4]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((1e6 * n1 / AcfParams._time)), FormatSettings);
		MainForm->ListView2->Items->Item[5]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((double(n1))), FormatSettings);

		int ind = 0;
		for (int i = 0; i < n1; i++) {
			if (RawData_t.a[i] > 1e6) {
				ind = i - 1;
				break;
			}
		}

		int m = Floor(ind / 1e3);
		MainForm->Series1->Clear();
		for (int i = 0; i < 1e3; i++) {
			if (!(RawData.a[i * m] == 0)) {
				MainForm->Series1->AddXY(RawData_t.a[i * m] * 1e-6, 1e9 /
					(RawData.a[i * m] * t));
			}
			else {
				MainForm->Series1->AddNullXY(RawData_t.a[i * m] * 1e-6, 0);
			}
		}
		break;
	}

}
コード例 #2
0
//---------------------------------------------------------------------------
void __fastcall TfrmHomePhotosBase::InitializeFrame()
{
    TDataSet* dsHomes;
    TdxTileControlItem* AItem;
    TFormatSettings AFmtSettings;
    GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, AFmtSettings);
    tcHomePhotos->BeginUpdate();
    __try
    {
        dsHomes = DMRealtorWorld->clHomesAndHomes;
        dsHomes->First();
        while (!dsHomes->Eof)
        {
            AItem = tcHomePhotos->CreateItem(true);
            AItem->Glyph->Image->LoadFromFieldValue(dsHomes->FieldByName("Photo")->Value);
            AItem->Glyph->Mode = ifmStretch;
            AItem->Text2->Value = " " + dsHomes->FieldByName("Beds")->AsString + " Beds" + "\n" + " " + dsHomes->FieldByName("Baths")->AsString + " Baths ";
            AItem->Text2->IndentHorz = 0;
            AItem->Text2->Font->Size = 13;
            AItem->Text2->IndentVert = 0;
            AItem->Text2->Transparent = false;
            AItem->Text3->Value = " " + FloatToStrF(dsHomes->FieldByName("Price")->AsFloat, ffCurrency, 10, 0, AFmtSettings) + " ";
            AItem->Text3->IndentHorz = 0;
            AItem->Text3->IndentVert = 0;
            AItem->Text3->Font->Size = 13;
            AItem->Text3->Transparent = false;
            AItem->Tag = dsHomes->FieldByName("ID")->AsInteger;
            AItem->OnClick = OnItemClick;
            dsHomes->Next();
        }
    }
    __finally
    {
        tcHomePhotos->EndUpdate();
    }
}
コード例 #3
0
ファイル: UReportForm.cpp プロジェクト: aquatter/DLS-App-test
void __fastcall TReportForm::ToolButton6Click(TObject *Sender)
{
	Variant ExcelApp, ExcelBooks, Book, WorkSheet, Cells, EmptyParam;
	TDateTime dtReport = Date();
	UnicodeString s=ExtractFileDir(Application->ExeName)+"\\template.xls";

	if (!FileExists(s))
	{
		ShowMessage("Файл шаблона не найден");
		return;
	}

	TVirtualNode *t_root=VirtualStringTree1->RootNode->FirstChild;
	TVirtualNode *t_child;
	TReportData *data_root, *data_child;

	try
	{
		ExcelApp = GetActiveOleObject("Excel.Application");
		ExcelBooks = ExcelApp.OlePropertyGet("WorkBooks");
	}
	catch (...)
	{
		try
		{
			ExcelApp = CreateOleObject("Excel.Application");
			ExcelBooks = ExcelApp.OlePropertyGet("WorkBooks");

		}
		catch (...)
		{
		  ShowMessage("Microsoft Excel не установлен");
		return;
		}
	}

	int i = 27;
	int j = 2;
	TFormatSettings format_settings;
	GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, format_settings);
	format_settings.DecimalSeparator = ',';

	try
	{
    	ExcelApp.OlePropertySet("Visible", false);
		Book = ExcelBooks.OleFunction("Add", s.t_str());
		WorkSheet = Book.OlePropertyGet("Worksheets").OlePropertyGet("Item", 1);
		Cells = WorkSheet.OlePropertyGet("Cells");
		Cells.OlePropertyGet("Item",4,3).OlePropertySet("Value", dtReport.FormatString("dd.mm.yyyy").t_str());
		Cells.OlePropertyGet("Item",8,1).OleProcedure("Select");
		MainForm->Chart5->CopyToClipboardMetafile(true);
		WorkSheet.OleProcedure("Paste");
		Variant shapes = WorkSheet.OlePropertyGet("Shapes").OleFunction("Item", 1);
		shapes.OleFunction("ScaleWidth", 0.9, EmptyParam, EmptyParam);
		shapes.OleFunction("ScaleHeight", 0.9, EmptyParam, EmptyParam);


		for (size_t k=0; k < VirtualStringTree1->RootNodeCount; k++)
		{
			if (t_root)
			{
				data_root = (TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_root);
				if (data_root)
				{
					s=data_root->Name;
					Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", s.t_str());
					i++;
				}


				t_child=t_root->FirstChild;
				while (t_child)
				{
					data_child=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_child);
					if (data_root)
					{
						s=data_child->Name;
						Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", s.t_str());
						Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_child->pcs, ffFixed, 5, 2, format_settings).t_str());
						Cells.OlePropertyGet("Item",i,j+2).OlePropertySet("Value", FloatToStrF(data_child->pi, ffFixed, 5, 2, format_settings).t_str());
						Cells.OlePropertyGet("Item",i,j+3).OlePropertySet("Value", FloatToStrF(data_child->angle, ffFixed, 5, 2,format_settings).t_str());
						i++;

					}
					t_child = t_child->NextSibling;
				}

				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "Средний диаметр");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->pcs, ffFixed, 5, 2, format_settings).t_str());
				i++;
				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "Средний ПДД");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->pi, ffFixed, 5, 2, format_settings).t_str());
				i++;
				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "СКО");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->rms, ffFixed, 5, 2, format_settings).t_str());
				i++;
			}

			t_root=t_root->NextSibling;
		}
	}
	__finally
	{
		ExcelApp.OlePropertySet("Visible", true);
		ExcelApp=Unassigned();
	}

}
コード例 #4
0
ファイル: server.cpp プロジェクト: MaxBelkov/visualsyslog
//---------------------------------------------------------------------------
bool TSyslogMessage::FromStringSyslogd(char * p, int size, sockaddr_in * from_addr)
{
  if( from_addr )
    SourceAddr = inet_ntoa(from_addr->sin_addr);
  else
    SourceAddr = "";

  PRI = -1; // not exist
  if( *p == '<' )
  {
    for(int i=1; i<5 && p[i]; i++)
    {
      if( p[i] == '>' )
      {
        PRI = atoi(p+1);
        p += i + 1;
        break;
      }
      if( ! isdigit(p[i]) )
        break;
    }
  }
  if( PRI >= 0 )
  {
    // invalid facility number not allowed: message filtering mechanism will fail
    // replace invalid facility number by LOGALERT
    if( LOG_FAC(PRI) >= LOG_NFACILITIES )
      PRI = LOG_PRI(PRI) | LOG_LOGALERT;

    Facility = getcodetext(LOG_FAC(PRI) << 3, facilitynames);
    Priority = getcodetext(LOG_PRI(PRI), prioritynames);
  }

  if( IsValidSyslogDate(p) )
  {
    DateStr = String(p, 15);
    p += 16; // including space
  }
  else
  {
    // month names in english in compliance to syslog rfc
    TFormatSettings fs;
    GetLocaleFormatSettings(0x0409, fs); // usa
    DateStr = FormatDateTime("mmm dd hh:nn:ss", Now(), fs);
  }

  // try to find host name
  for(int i=0; i<255 && p[i]; i++)
  {
    if( p[i] == ' ' )
    {
      // found
      HostName = String(p, i);
      p += i + 1;
      break;
    }
    else if( p[i] == ':' || p[i] == '[' || p[i] == ']' )
    {
      // host name not exist - this is program name
      break;
    }
  }

  // try to find program name
  for(int i=0; i<(48+2) && p[i]; i++)
  {
    if( p[i] == ':' && p[i+1] == ' ' )
    {
      // found
      Tag = String(p, i);
      p += i + 2;
      break;
    }
  }

  // and now - process message
  // Replace all tabs by spaces,
  // cut all carriage returns and line feeds,
  // replace all chars 0..32 by '.'
  Msg = "";
  for(int i=0; p[i]; i++)
  {
    if( p[i] == '\t' || p[i] == '\n' )
      Msg += ' ';
    else if( p[i] == '\r' )
      ;
    else if( p[i] >= 0 && p[i] < 32 )
      Msg += '.';
    else
      Msg += p[i];
  }

  if( MainCfg.bReceiveUTF8 )
    Msg = Utf8ToAnsi(Msg);

  return true;
}