Exemplo n.º 1
0
int sc_main(int, char **)
{
	sc_signal<bool> a, b, f;
	sc_clock clk("Clk", 20, SC_NS);	// 时钟周期为 20ns
	
	// 分别定义模块 NAND 和 TB 的实例,并通过局部变量(如 a、b)将这两个实例连接起来
	nand NAND("NAND");
	NAND.A(a);
	NAND.B(b);
	NAND.F(f);

	tb TB("TB");
	TB.clk(clk);
	TB.a(a);
	TB.b(b);
	TB.f(f);

	// 生成仿真结果波形文件
	sc_trace_file *tf = sc_create_vcd_trace_file("NAND");
	sc_trace(tf, NAND.A, "A");
	sc_trace(tf, NAND.B, "B");
	sc_trace(tf, NAND.F, "F");
	sc_trace(tf, TB.clk, "CLK");
	sc_start(200, SC_NS);	// 仿真时长 200ns
	sc_close_vcd_trace_file(tf);

	return 0;
}
Exemplo n.º 2
0
int sc_main(int ac, char *av[])
{
  sc_clock clock("Clock", CLOCK_PERIOD, SC_NS, DUTY_CYCLE, 0, SC_NS);
 
  sc_signal<bool> reset_sig;

  sc_signal<int> i1;
  sc_signal<int> i2;
  sc_signal<int> i3;
  sc_signal<int> i4;
  sc_signal<int> i5;
  
  sc_signal<bool> cont1;
  sc_signal<bool> cont2;
  sc_signal<bool> cont3;
  
  sc_signal<int> o1;
  sc_signal<int> o2;
  sc_signal<int> o3;
  sc_signal<int> o4;
  sc_signal<int> o5;

  test TEST ("TEST", clock, reset_sig, i1, i2, i3, i4, i5,
	 cont1, cont2, cont3, o1, o2, o3, o4, o5);
  tb TB ("TB", clock, reset_sig, i1, i2, i3, i4, i5,
	 cont1, cont2, cont3, o1, o2, o3, o4, o5);

  // Simulation Run Control
  sc_start();
  return 0;
}
//*********************************
//zwróæ wartoœæ indeksu do tabelek z temperaturami na podstawie bie¿¹cego czasu gt_Time
uint8_t TempBuffCurrIdx(uint8_t pi_BuffType) {
	uint16_t vi_Idx;
#if TEMP_USE_BUFF
	uint16_t vi_DayNo = TimeGetDayNo(gt_CurrTime[TDay],gt_CurrTime[TMonth],gt_CurrTime[TYear]);
#endif
	switch (pi_BuffType) {
		case TEMP_BUFF12m: vi_Idx = (gt_CurrTime[THour]*5)+(gt_CurrTime[TMin]/12); break;
#ifdef TEMP_BUFF1h5
		case TEMP_BUFF1h5: vi_Idx = gt_CurrTime[TWeekDay]*16+(gt_CurrTime[THour]*2+gt_CurrTime[TMin]/30)/3; break;
#endif
#ifdef TEMP_BUFF6h
		case TEMP_BUFF6h: vi_Idx = vi_DayNo*4+gt_CurrTime[THour]/4; break;
#endif
#ifdef TEMP_BUFF1D
		case TEMP_BUFF1D: vi_Idx = vi_DayNo; break;
#endif
#ifdef TEMP_BUFF1W
		case TEMP_BUFF1W: vi_Idx = (vi_DayNo-2/*TimeGetDayNo(3,1,00)*//*poniedzia³ek*/)/7; break;
#endif
#ifdef TEMP_BUFF1M
		case TEMP_BUFF1M: vi_Idx = gt_CurrTime[TYear]*12+gt_CurrTime[TMonth]; break;
#endif
#ifdef TEMP_BUFF3M
		case TEMP_BUFF3M: vi_Idx = gt_CurrTime[TYear]*4+TimeSeason(gt_CurrTime[TDay],gt_CurrTime[TMonth],gt_CurrTime[TYear]); break;
#endif
		default: case TEMP_BUFF24m: vi_Idx = ((gt_CurrTime[THour]*5)+(gt_CurrTime[TMin]/12))/2; break;
	}
	return TruncIdx16(vi_Idx,TB(pi_BuffType,Size));
} //TempBuffCurrIdx
void UInputTouchDelegateBinding::BindToInputComponent(UInputComponent* InputComponent) const
{
	TArray<FInputTouchBinding> BindsToAdd;

	for (int32 BindIndex=0; BindIndex<InputTouchDelegateBindings.Num(); ++BindIndex)
	{
		const FBlueprintInputTouchDelegateBinding& Binding = InputTouchDelegateBindings[BindIndex];

		FInputTouchBinding TB( Binding.InputKeyEvent );
		TB.bConsumeInput = Binding.bConsumeInput;
		TB.bExecuteWhenPaused = Binding.bExecuteWhenPaused;
		TB.TouchDelegate.BindDelegate(InputComponent->GetOwner(), Binding.FunctionNameToBind);

		if (Binding.bOverrideParentBinding)
		{
			for (int32 ExistingIndex = InputComponent->TouchBindings.Num() - 1; ExistingIndex >= 0; --ExistingIndex)
			{
				if (InputComponent->TouchBindings[ExistingIndex].KeyEvent != TB.KeyEvent)
				{
					InputComponent->TouchBindings.RemoveAt(ExistingIndex);
				}
			}
		}

		// To avoid binds in the same layer being removed by the parent override temporarily put them in this array and add later
		BindsToAdd.Add(TB);
	}

	for (int32 Index=0; Index < BindsToAdd.Num(); ++Index)
	{
		InputComponent->TouchBindings.Add(BindsToAdd[Index]);
	}
}
//*********************************
//zwróæ wartoœæ temperatury jako obliczenie z buforów z mniejsz¹ kompresj¹ czasow¹
void TempBuffGetCurr(
  uint8_t pi_BuffType //>12m
 ,int16_t pt_Temps[]
) {
	uint8_t vi_SubBuffType;
	int16_t vi_FirstIdx;
	uint8_t vi_Idx;

	switch (pi_BuffType) {
#ifdef TEMP_BUFF1h5
		case TEMP_BUFF1h5: vi_SubBuffType = TEMP_BUFF12m; vi_FirstIdx = ((gt_TempBuffsIdx[TEMP_BUFF12m]*2)-(gt_TempBuffsIdx[TEMP_BUFF12m]*2)%15)/2; break;
#endif
#ifdef TEMP_BUFF6h
		case TEMP_BUFF6h: vi_SubBuffType = TEMP_BUFF12m; vi_FirstIdx = gt_TempBuffsIdx[TEMP_BUFF12m]-gt_TempBuffsIdx[TEMP_BUFF12m]%30; break;
#endif
#ifdef TEMP_BUFF1D
		case TEMP_BUFF1D: vi_SubBuffType = TEMP_BUFF12m; vi_FirstIdx = 0; break;
#endif
#ifdef TEMP_BUFF1W
		case TEMP_BUFF1W: vi_SubBuffType = TEMP_BUFF1D; vi_FirstIdx = gt_TempBuffsIdx[TEMP_BUFF1D]-(gt_Temp1dLastDate[TDay+1]+6)%7; break;
#endif
#ifdef TEMP_BUFF1M
		case TEMP_BUFF1M: vi_SubBuffType = TEMP_BUFF1D; vi_FirstIdx = TimeGetDayNo(1,gt_Temp1dLastDate[TMonth],gt_Temp1dLastDate[TYear]); break;
#endif
#ifdef TEMP_BUFF3M
		case TEMP_BUFF3M:
			vi_SubBuffType = TEMP_BUFF1D;
			uint8_t vt_Time[TDay+1];
			vt_Time[TYear]  = gt_Temp1dLastDate[TYear];
			vt_Time[TMonth] = gt_Temp1dLastDate[TMonth];
			vt_Time[TDay]   = gt_Temp1dLastDate[TDay];
			TimeSeasonFirstDay(vt_Time);
			vi_FirstIdx = TimeGetDayNo(vt_Time[TDay],vt_Time[TMonth],vt_Time[TYear]);
			break;
#endif
		default: vi_SubBuffType = 0; vi_FirstIdx = 0; break;
	}

	TempBuffGet(vi_SubBuffType,TEMP_FULLNO,TruncIdx16(vi_FirstIdx,TB(vi_SubBuffType,Size)),gt_TempBuffsIdx[vi_SubBuffType],pt_Temps,1);
	if (TB(pi_BuffType,SubSize)==1) {
		pt_Temps[TEMP_MIN] = pt_Temps[TEMP_AVG];
		pt_Temps[TEMP_MAX] = pt_Temps[TEMP_AVG];
	}
	for (vi_Idx=TEMP_MIN; vi_Idx<=TEMP_MAX; vi_Idx++)
		gt_TempBuffCurrCache[vi_Idx] = pt_Temps[vi_Idx];

} //TempBuffGetCurr
Exemplo n.º 6
0
int main()
{
int x = 0xff;
printf("%d \n",T(x,16));
TB(x);//将x转化为二进制数
printf("\n");

return 0;
}
Exemplo n.º 7
0
int TB(int m)
{
	if(m>0)
	{
		TB(m/2);
		printf("%d ",m%2);
	}
	else
		return;
}
Exemplo n.º 8
0
int sc_main(int, char **)
{
	sc_signal<sc_uint<ENABLESIZE> > en_n;
	sc_signal<sc_uint<INPUTSIZE> > dataIn;
	sc_signal<sc_uint<SELECTSIZE> > selIn;
	sc_signal<sc_uint<OUTPUTSIZE> > dataOut;
	sc_signal<sc_uint<OUTPUTSIZE> > flag;
	sc_clock clk("Clk", 20, SC_NS);
	
	// Connect modules ------------------------------------------
	mux_8_1 MUX_8_1("MUX_8_1");
	MUX_8_1.en_n(en_n);
	MUX_8_1.dataIn(dataIn);
	MUX_8_1.selIn(selIn);
	MUX_8_1.dataOut(dataOut);
	MUX_8_1.flag(flag);

	tb TB("TB");
	TB.clk(clk);
	TB.en_n(en_n);
	TB.dataIn(dataIn);
	TB.selIn(selIn);
	TB.dataOut(dataOut);
	TB.flag(flag);

	// Initialize keys ------------------------------------------
	cout << "Setting up FHEW" << endl;
	FHEW::Setup();
	cout << "Generating secret key ... " << endl;
	//LWE::SecretKey LWEsk;
	LWE::KeyGen(LWEsk);
	cout << "Done." << endl;
	cout << "Generating evaluation key ... this may take a while ... " << endl;
	//FHEW::EvalKey Ek;
	FHEW::KeyGen(&Ek, LWEsk);
	cout << "Done." << endl << endl;

	// Create trace files ----------------------------------------
	sc_trace_file *tf = sc_create_vcd_trace_file("Mux_8_1");
	sc_trace(tf, MUX_8_1.en_n, "en_n");
	sc_trace(tf, MUX_8_1.dataIn, "dataIn");
	sc_trace(tf, MUX_8_1.selIn, "selIn");
	sc_trace(tf, MUX_8_1.dataOut, "dataOut");
	sc_trace(tf, MUX_8_1.flag, "flag");
	sc_trace(tf, TB.clk, "CLK");
	sc_start(400, SC_NS);
	sc_close_vcd_trace_file(tf);

	return 0;
}
//*********************************
//pobierz temperaturê z bie¿¹cych odczytów
int16_t TempGet(
  uint8_t pi_Sensor   //numer termometru
 ,uint8_t pi_TempType //TEMP_TICK/TEMP_CURR/TEMP_MIN/TEMP_AVG/TEMP_MAX
) {
	int16_t vt_Temps[TEMP_MAX+1];

	if (pi_TempType&0x10) {
		uint8_t vi_sreg = SREG;
		cli();
		if (pi_TempType==TEMP_TICK)
			vt_Temps[0] = gt_TempsVar[pi_Sensor].Tick.I12.I12;
		else
			vt_Temps[0] = gt_TempsVar[pi_Sensor].Curr.I12.I12;
		SREG = vi_sreg;
		pi_TempType = 0;
	}
	else
		TempBuffGet(TEMP_BUFF12m,pi_Sensor,0,(pi_Sensor==TEMP_FULLNO)?TB(TEMP_BUFF12m,Size)-1:TEMP_12MSIZE-1,vt_Temps,1);

	return vt_Temps[pi_TempType];
} //TempGet
Exemplo n.º 10
0
int fast_hgt2(suf_t *ISA, suf_t *SA, uchar *T, suf_t *H, i64 n)
{
  i64 p,q,h,i,r;
  FILE *f;
  int w,j;
  int CtoB[SIGMA+1], BtoC[SIGMA+1], C[SIGMA+1];
  
  for (i=0; i<=SIGMA; i++) C[i] = 0;
  for (i=0; i<n; i++) C[T[i]+1] = 1;
  C[0] = 1;
  CtoB[-1+1] = 0;  BtoC[0] = -1;
  r = 1; // 出現する文字の数
  for (i=0; i<SIGMA; i++) {
    if (C[i+1]>0) { // 文字 i が T に出現
      CtoB[i+1] = r; // 文字 i が r にマップされる
      BtoC[r] = i; // r の元の文字は i ($ は -1)
      r++;
    }
  }
  w = blog(r)+1; // r 個の文字を格納するのに必要なビット数
  printf("w = %d\n",w);
  for (i=0; i<r; i++) {
    printf("%3d (%c) -> ",BtoC[i],isprint(BtoC[i])?BtoC[i]:' ');
    for (j=0; j<w; j++) putchar('0' + ((i>>(w-1-j))&1));
    printf("\n");
  }

  for (i=0; i<=n; i++) ISA[SA[i]] = i;

  f = fopen("output.hb","wb");

  h = 0;
  for (p=0; p<=n; p++) {
    int c1,c2;
    r = 0;
    i = ISA[p];
//    printf("isa[%ld] = %ld\n",p,i);
    if (i == 0) {
      H[i] = 0;
    } else {
      q = SA[i-1];
//      printf("h = %ld cmp T[%ld] T[%ld]\n",h,p+h,q+h);
      if (h == 0) {
        while ((p+h < n) && (q+h < n) && (T[p+h] == T[q+h])) h++;
        if (p+h < n) c1 = CtoB[T[p+h]+1]; else c1 = 0;
        if (q+h < n) c2 = CtoB[T[q+h]+1]; else c2 = 0;
        while (r < w && TB(c1,r,w) == TB(c2,r,w)) r++;
      } else {
        h--;
        while ((p+h < n) && (q+h < n) && (T[p+h] == T[q+h])) h++;
        if (p+h < n) c1 = CtoB[T[p+h]+1]; else c1 = 0;
        if (q+h < n) c2 = CtoB[T[q+h]+1]; else c2 = 0;
        while (r < w && TB(c1,r,w) == TB(c2,r,w)) r++;
      }
      H[i] = h * w + r;
//      printf("H[%ld] = %ld\n",i,h);
      r = H[i];
      while (r>0) {
        fputc('1',f);
        r--;
      }
      fputc('0',f);
    }
  }

  fclose(f);

}
Exemplo n.º 11
0
void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessage)
{
	TPreRedrawFuncGuard preRedrawFuncGuard(PR_ReadFileNamesMsg);
	TaskBar TB(false);

	strOriginalCurDir=strCurDir;

	if (!IsVisible() && !IgnoreVisible)
	{
		UpdateRequired=TRUE;
		UpdateRequiredMode=KeepSelection;
		return;
	}

	UpdateRequired=FALSE;
	AccessTimeUpdateRequired=FALSE;
	DizRead=FALSE;
	FAR_FIND_DATA_EX fdata;
	FileListItem *CurPtr=0,**OldData=0;
	string strCurName, strNextCurName;
	int OldFileCount=0;
	StopFSWatcher();

	if (this!=CtrlObject->Cp()->LeftPanel && this!=CtrlObject->Cp()->RightPanel)
		return;

	string strSaveDir;
	apiGetCurrentDirectory(strSaveDir);
	{
		string strOldCurDir = strCurDir;

		if (!SetCurPath())
		{
			FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте...

			if (!StrCmp(strCurDir, strOldCurDir)) //?? i??
			{
				GetPathRoot(strOldCurDir,strOldCurDir);

				if (!apiIsDiskInDrive(strOldCurDir))
					IfGoHome(strOldCurDir.At(0));

				/* При смене каталога путь не изменился */
			}

			return;
		}
	}
	SortGroupsRead=FALSE;

	if (GetFocus())
		CtrlObject->CmdLine->SetCurDir(strCurDir);

	LastCurFile=-1;
	Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(this);
	AnotherPanel->QViewDelTempName();
	size_t PrevSelFileCount=SelFileCount;
	SelFileCount=0;
	SelFileSize=0;
	TotalFileCount=0;
	TotalFileSize=0;
	CacheSelIndex=-1;
	CacheSelClearIndex=-1;

	if (Opt.ShowPanelFree)
	{
		unsigned __int64 TotalSize,TotalFree;

		if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize))
			FreeDiskSize=0;
	}

	if (FileCount>0)
	{
		strCurName = ListData[CurFile]->strName;

		if (ListData[CurFile]->Selected)
		{
			for (int i=CurFile+1; i < FileCount; i++)
			{
				CurPtr = ListData[i];

				if (!CurPtr->Selected)
				{
					strNextCurName = CurPtr->strName;
					break;
				}
			}
		}
	}

	if (KeepSelection || PrevSelFileCount>0)
	{
		OldData=ListData;
		OldFileCount=FileCount;
	}
	else
		DeleteListData(ListData,FileCount);

	ListData=nullptr;
	int ReadOwners=IsColumnDisplayed(OWNER_COLUMN);
	int ReadNumLinks=IsColumnDisplayed(NUMLINK_COLUMN);
	int ReadNumStreams=IsColumnDisplayed(NUMSTREAMS_COLUMN);
	int ReadStreamsSize=IsColumnDisplayed(STREAMSSIZE_COLUMN);
	string strComputerName;

	if (ReadOwners)
	{
		CurPath2ComputerName(strCurDir, strComputerName);
		// сбросим кэш SID`ов
		SIDCacheFlush();
	}

	SetLastError(ERROR_SUCCESS);
	int AllocatedCount=0;
	FileListItem *NewPtr;
	// сформируем заголовок вне цикла
	wchar_t Title[2048];
	int TitleLength=Min((int)X2-X1-1,(int)(ARRAYSIZE(Title))-1);
	//wmemset(Title,0x0CD,TitleLength); //BUGBUG
	//Title[TitleLength]=0;
	MakeSeparator(TitleLength, Title, 9, nullptr);
	BOOL IsShowTitle=FALSE;
	BOOL NeedHighlight=Opt.Highlight && PanelMode != PLUGIN_PANEL;

	if (!Filter)
		Filter=new FileFilter(this,FFT_PANEL);

	//Рефреш текущему времени для фильтра перед началом операции
	Filter->UpdateCurrentTime();
	CtrlObject->HiFiles->UpdateCurrentTime();
	bool bCurDirRoot = false;
	ParsePath(strCurDir, nullptr, &bCurDirRoot);
	PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot);
	bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC);

	FileCount = 0;
	string strFind = strCurDir;
	AddEndSlash(strFind);
	strFind+=L'*';
	::FindFile Find(strFind, true);
	DWORD FindErrorCode = ERROR_SUCCESS;
	bool UseFilter=Filter->IsEnabledOnPanel();
	bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0;

	DWORD StartTime = GetTickCount();

	while (Find.Get(fdata))
	{
		FindErrorCode = GetLastError();

		if ((Opt.ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName)))
		{
			if (FileCount>=AllocatedCount)
			{
				AllocatedCount+=4096;
				FileListItem **pTemp;

				if (!(pTemp=(FileListItem **)xf_realloc(ListData,AllocatedCount*sizeof(*ListData))))
					break;

				ListData=pTemp;
			}

			ListData[FileCount] = new FileListItem;
			ListData[FileCount]->Clear();
			NewPtr=ListData[FileCount];
			NewPtr->FileAttr = fdata.dwFileAttributes;
			NewPtr->CreationTime = fdata.ftCreationTime;
			NewPtr->AccessTime = fdata.ftLastAccessTime;
			NewPtr->WriteTime = fdata.ftLastWriteTime;
			NewPtr->ChangeTime = fdata.ftChangeTime;
			NewPtr->FileSize = fdata.nFileSize;
			NewPtr->AllocationSize = fdata.nAllocationSize;
			NewPtr->strName = fdata.strFileName;
			NewPtr->strShortName = fdata.strAlternateFileName;
			NewPtr->Position=FileCount++;
			NewPtr->NumberOfLinks=1;

			if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
			{
				NewPtr->ReparseTag=fdata.dwReserved0; //MSDN
			}
			if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				TotalFileSize += NewPtr->FileSize;

				if (ReadNumLinks)
					NewPtr->NumberOfLinks=GetNumberOfLinks(fdata.strFileName);
			}
			else
			{
				NewPtr->AllocationSize = 0;
			}

			NewPtr->SortGroup=DEFAULT_SORT_GROUP;

			if (ReadOwners)
			{
				string strOwner;
				GetFileOwner(strComputerName, NewPtr->strName,strOwner);
				NewPtr->strOwner = strOwner;
			}

			NewPtr->NumberOfStreams=NewPtr->FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1;
			NewPtr->StreamsSize=NewPtr->FileSize;

			if (ReadNumStreams||ReadStreamsSize)
			{
				EnumStreams(TestParentFolderName(fdata.strFileName)?strCurDir:fdata.strFileName,NewPtr->StreamsSize,NewPtr->NumberOfStreams);
			}

			if (ReadCustomData)
				CtrlObject->Plugins->GetCustomData(NewPtr);

			if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
				TotalFileCount++;

			//memcpy(ListData+FileCount,&NewPtr,sizeof(NewPtr));
//      FileCount++;

			DWORD CurTime = GetTickCount();
			if (CurTime - StartTime > RedrawTimeout)
			{
				StartTime = CurTime;
				if (IsVisible())
				{
					if (!IsShowTitle)
					{
						if (!DrawMessage)
						{
							Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title);
							IsShowTitle=TRUE;
							SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE);
						}
					}

					LangString strReadMsg(MReadingFiles);
					strReadMsg << FileCount;

					if (DrawMessage)
					{
						ReadFileNamesMsg(strReadMsg);
					}
					else
					{
						TruncStr(strReadMsg,TitleLength-2);
						int MsgLength=(int)strReadMsg.GetLength();
						GotoXY(X1+1+(TitleLength-MsgLength-1)/2,Y1);
						FS<<L" "<<strReadMsg<<L" ";
					}
				}

				if (CheckForEsc())
				{
					break;
				}
			}
		}
	}

	if (!(FindErrorCode==ERROR_SUCCESS || FindErrorCode==ERROR_NO_MORE_FILES || FindErrorCode==ERROR_FILE_NOT_FOUND))
		Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MError),MSG(MReadFolderError),MSG(MOk));

	if ((Opt.ShowDotsInRoot || !bCurDirRoot) || (NetRoot && CtrlObject->Plugins->FindPlugin(Opt.KnownIDs.Network))) // NetWork Plugin
	{
		if (FileCount>=AllocatedCount)
		{
			FileListItem **pTemp;

			if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+1)*sizeof(*ListData))))
				ListData=pTemp;
		}

		if (ListData)
		{
			ListData[FileCount] = new FileListItem;

			string TwoDotsOwner;
			if (ReadOwners)
			{
				GetFileOwner(strComputerName,strCurDir,TwoDotsOwner);
			}

			FILETIME TwoDotsTimes[4]={};
			if(apiGetFindDataEx(strCurDir,fdata))
			{
				TwoDotsTimes[0]=fdata.ftCreationTime;
				TwoDotsTimes[1]=fdata.ftLastAccessTime;
				TwoDotsTimes[2]=fdata.ftLastWriteTime;
				TwoDotsTimes[3]=fdata.ftChangeTime;
			}

			AddParentPoint(ListData[FileCount],FileCount,TwoDotsTimes,TwoDotsOwner);

			FileCount++;
		}
	}

	if (IsColumnDisplayed(DIZ_COLUMN))
		ReadDiz();

	if (NeedHighlight)
	{
		CtrlObject->HiFiles->GetHiColor(ListData, FileCount);
	}

	if (AnotherPanel->GetMode()==PLUGIN_PANEL)
	{
		HANDLE hAnotherPlugin=AnotherPanel->GetPluginHandle();
		PluginPanelItem *PanelData=nullptr;
		string strPath;
		size_t PanelCount=0;
		strPath = strCurDir;
		AddEndSlash(strPath);

		if (CtrlObject->Plugins->GetVirtualFindData(hAnotherPlugin,&PanelData,&PanelCount,strPath))
		{
			FileListItem **pTemp;

			if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+PanelCount)*sizeof(*ListData))))
			{
				ListData=pTemp;

				for (size_t i=0; i < PanelCount; i++)
				{
					CurPtr = ListData[FileCount+i];
					PluginPanelItem &pfdata=PanelData[i];
					PluginToFileListItem(&PanelData[i],CurPtr);
					CurPtr->Position=FileCount;
					TotalFileSize += pfdata.FileSize;
					CurPtr->PrevSelected=CurPtr->Selected=0;
					CurPtr->ShowFolderSize=0;
					CurPtr->SortGroup=CtrlObject->HiFiles->GetGroup(CurPtr);

					if (!TestParentFolderName(pfdata.FileName) && !(CurPtr->FileAttr & FILE_ATTRIBUTE_DIRECTORY))
						TotalFileCount++;
				}

				// цветовую боевую раскраску в самом конце, за один раз
				CtrlObject->HiFiles->GetHiColor(&ListData[FileCount],PanelCount);
				FileCount+=static_cast<int>(PanelCount);
			}

			CtrlObject->Plugins->FreeVirtualFindData(hAnotherPlugin,PanelData,PanelCount);
		}
	}

	InitFSWatcher(false);
	CorrectPosition();

	if (KeepSelection || PrevSelFileCount>0)
	{
		MoveSelection(ListData,FileCount,OldData,OldFileCount);
		DeleteListData(OldData,OldFileCount);
	}

	if (SortGroups)
		ReadSortGroups(false);

	if (!KeepSelection && PrevSelFileCount>0)
	{
		SaveSelection();
		ClearSelection();
	}

	SortFileList(FALSE);

	if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName))
		if (!GoToFile(strCurName) && !strNextCurName.IsEmpty())
			GoToFile(strNextCurName);

	/* $ 13.02.2002 DJ
		SetTitle() - только если мы текущий фрейм!
	*/
	if (CtrlObject->Cp() == FrameManager->GetCurrentFrame())
		SetTitle();

	FarChDir(strSaveDir); //???
}
Exemplo n.º 12
0
int	Build2DTextures( IntroProgressDelegate& _Delegate )
{
return 0;

	DrawUtils	Draw;
	{
		TextureBuilder	TB( 512, 512 );
		Draw.SetupSurface( 512, 512, TB.GetMips()[0] );	// Let's draw into the first mip level !

/* General tests for drawing tools and filtering
 		Noise	N( 1 );
		N.Create2DWaveletNoiseTile( 6 );	// If you need to use wavelet noise...
		TB.Fill( FillNoise, &N );

		Draw.DrawLine( 20.0f, 0.0f, 400.0f, 500.0f, 10.0f, FillLine, NULL );

		Draw.SetupContext( 30.0f, 0.0f, 20.0f );
 		Draw.DrawEllipse( 10.0f, 13.4f, 497.39f, 282.78f, 40.0f, 0.0f, FillEllipse, NULL );

		Draw.SetupContext( 250.0f, 0.0f, 30.0f );
 		Draw.DrawRectangle( 10.0f, 13.4f, 197.39f, 382.78f, 40.0f, 0.5f, FillRectangle, NULL );

//		Filters::BlurGaussian( TB, 20.0f, 20.0f, true, 0.5f );
//		Filters::UnsharpMask( TB, 20.0f );
//		Filters::BrightnessContrastGamma( TB, 0.2f, 0.0f, 2.0f );
//		Filters::Emboss( TB, NjFloat2( 1, 1 ), 4.0f );
//		Filters::Erode( TB );
//		Filters::Dilate( TB );

// 		// Test the AO converter
// 		TextureBuilder	PipoTemp( TB.GetWidth(), TB.GetHeight() );
// 		PipoTemp.CopyFrom( TB );
// 		Generators::ComputeAO( PipoTemp, TB, 2.0f );

//*/

// 		// Test the dirtyness generator
//		Generators::Dirtyness( TB, N, 0.5f, 0.0f, 0.1f, 0.3f, 0.01f );

	// Test the secret marble generator
//		Generators::Marble( TB, 30, 0.2f, 0.5f, 1.0f, 0.5f, 0.5f );
//		Generators::Marble3D( TB, 16, 0.2f );


//* Test advanced drawing

 		Noise	N( 1 );
		// Draw scratches
		for ( int i=0; i < 10; i++ )
		{
			NjFloat2	Pos;
			Pos.x = _frand( 0.0f, 512.0f );
			Pos.y = _frand( 0.0f, 512.0f );
			NjFloat2	Dir;
			Dir.x = _frand( -1.0f, +1.0f );
			Dir.y = _frand( -1.0f, +1.0f );

			float	Length = _frand( 100.0f, 500.0f );
			float	Thickness = _frand( 4.0f, 5.0f );
			float	Curve = _frand( -0.05f, 0.05f );

			Draw.DrawScratch( Pos, Dir, Length, Thickness, 0.01f, Curve, 10.0f, FillScratch, &N );
		}

		// Draw splotches
		for ( int Y=0; Y < 20; Y++ )
		{
			int		Count = _rand( 10, 20 );

			float	Angle = _frand( -180.0f, +180.0f );
			float	DeltaAngle = _frand( 0.0f, 40.0f );		// Splotches rotate with time
					DeltaAngle /= Count;

			NjFloat2	Pos;
			Pos.x = _frand( -512.0f, 512.0f );
			Pos.y = _frand( -512.0f, 512.0f );

			NjFloat2	Size;
			Size.x = _frand( 40.0f, 50.0f );
			Size.y = _frand( 40.0f, 50.0f );
			float	DeltaSize = _frand( 0.0f, 30.0f );	// Splotches get bigger or smaller with time
					DeltaSize /= Count;

			float	Step = _frand( 0.25f, 1.0f ) * Size.x;	// Splotches interpenetrate

			for ( int X=0; X < Count; X++ )
			{
				Draw.SetupTransform( Pos.x, Pos.y, Angle );
				Draw.DrawRectangle( 0.0f, 0.0f, Size.x, Size.y, 0.1f * Size.Min(), 0.0f, FillSplotch, &N );

				Angle += DeltaAngle;
				float	AngleRad = DEG2RAD( Angle );
				Pos = Pos + Step * NjFloat2( cosf(AngleRad), sinf(AngleRad) );
				Size.x += DeltaSize;
			}
		}

// Draw.DrawRectangle( 0.0f, 0.0f, 100.0f, 100.0f, 10.0f, 0.0f, FillSplotch, &N );

//			Filters::BrightnessContrastGamma( TB, 0.1f, 0.7f, 2.0f );
//			Filters::Erode( TB, 3 );
//*/

		gs_pTexTestNoise = TB.CreateTexture( PixelFormatRGBA16F::DESCRIPTOR, TextureBuilder::CONV_RGBA_NxNyHR_M );
	}

	return 0;	// OK !
}
Exemplo n.º 13
0
main()
{
	vec_t test;
	vec_t tout;

#define TD(i,j) test.put(&d[i], j); cerr << "d is at " << ::dec((unsigned int)d) << endl;
#define TB(i,j) test.put(&b[i], j); cerr << "b is at " << ::dec((unsigned int)b) << endl;
#define TA(i,j) test.put(&a[i], j); cerr << "a is at " << ::dec((unsigned int)a) << endl;
#define TC(i,j) test.put(&c[i], j); cerr << "c is at " << ::dec((unsigned int)c) << endl;

	TA(0,10);
	TB(0,10);
	TC(0,10);
	TD(0,10);


	V(test, 5, 7, tout);
	V(test, 5, 10, tout);
	V(test, 5, 22, tout);

	V(test, 11, 0, tout);
	V(test, 11, 7, tout);
	V(test, 11, 9, tout);

	V(test, 30, 9, tout);
	V(test, 30, 29, tout);
	V(test, 30, 40, tout);
	V(test, 40, 30, tout);

	V(test, 100, 9, tout);

	P("{ {1   \"}\" }");
	/*{{{*/
	P("{ {3 \"}}}\"      }}");
	P("{ {30 \"xxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\"} }");
	P("{ {30 \"xxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\"}{10    \"abcdefghij\"} }");

	{
		vec_t t;
		t.reset();
		t.put("abc",3);
		for(int i=0; i<t.count(); i++) {
			cout <<"vec["<<i<<"]=("
				<<::dec((unsigned int)t.ptr(i)) <<"," <<t.len(i) <<")" << endl;
		}
		cout << "FINAL: "<< t << endl;
	}

	{
		cout << "ZVECS: " << endl;

		{
			zvec_t z(0);
			cout << "z(0).count() = " << z.count() << endl;
			cout << "z(0) is zero vec: " << z.is_zvec() << endl;
			vec_t  zv;
			zv.set(z);
			cout << "zv.set(z).count() = " << zv.count() << endl;
			cout << "zv is zero vec: " << zv.is_zvec() << endl;
		}
		{
			zvec_t z;
			cout << "z is zero vec: " << z.is_zvec() << endl;
			cout << "z.count() = " << z.count() << endl;
			vec_t  zv;
			zv.set(z);
			cout << "zv.set(z).count() = " << zv.count() << endl;
			cout << "zv(0) is zero vec: " << zv.is_zvec() << endl;
		}
	}

	{
		int n = 0x80000003;
		int m = 0xeffffffc;
		vec_t   num( (void*)&n, sizeof(n));
		vec_t   num2( (void*)&m, sizeof(m));

		cout << "vec containing 0x80000003 prints as: " << num  << endl;
		cout << "vec containing 0xeffffffc prints as: " << num2  << endl;
	}

	{
		char c = 'h';
		char last = (char)'\377';
		char last1 = '\377';
		char last2 = (char)0xff;

		vec_t   cv( (void*)&c, sizeof(c));
		vec_t   lastv( (void*)&last, sizeof(last));
		vec_t   last1v( (void*)&last1, sizeof(last1));
		vec_t   last2v( (void*)&last2, sizeof(last2));

		bool result = (bool)(cv < lastv);
		cout << "cv <= lastv: " << result << endl;
		cout << "cv prints as: " << cv <<endl;
		cout << "lastv prints as: " << lastv <<endl;
		cout << "last1 prints as: " << last1v <<endl;
		cout << "last2 prints as: " << last2v <<endl;
	}
}
Exemplo n.º 14
0
EffectParticles::EffectParticles() : m_ErrorCode( 0 )
{
	//////////////////////////////////////////////////////////////////////////
	// Create the materials
	CHECK_MATERIAL( m_pMatCompute = CreateMaterial( IDR_SHADER_PARTICLES_COMPUTE, "./Resources/Shaders/ParticlesCompute.hlsl", VertexFormatPt4::DESCRIPTOR, "VS", NULL, "PS" ), 1 );
	CHECK_MATERIAL( m_pMatDisplay = CreateMaterial( IDR_SHADER_PARTICLES_DISPLAY, "./Resources/Shaders/ParticlesDisplay.hlsl", VertexFormatPt4::DESCRIPTOR, "VS", "GS", "PS" ), 2 );
	CHECK_MATERIAL( m_pMatDebugVoronoi = CreateMaterial( IDR_SHADER_PARTICLES_DISPLAY, "./Resources/Shaders/ParticlesDisplay.hlsl", VertexFormatPt4::DESCRIPTOR, "VS_DEBUG", NULL, "PS_DEBUG" ), 3 );


	//////////////////////////////////////////////////////////////////////////
	// Build the awesome particle primitive
// 	{
// 		VertexFormatP3	Vertices;
// 		m_pPrimParticle = new Primitive( gs_Device, 1, &Vertices, 0, NULL, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, VertexFormatP3::DESCRIPTOR );
// 	}

	//////////////////////////////////////////////////////////////////////////
	// Build our voronoï texture & our initial positions & data
	NjFloat2*	pCellCenters = new NjFloat2[EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT];
	{
		TextureBuilder		TB( 1024, 1024 );
		VertexFormatPt4*	pVertices = new VertexFormatPt4[EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT];
		BuildVoronoiTexture( TB, pCellCenters, pVertices );

		TextureBuilder::ConversionParams	Conv =
		{
			0,		// int		PosR;
			1,		// int		PosG;
			-1,		// int		PosB;
			-1,		// int		PosA;
			false,

					// Position of the height & roughness fields
			-1,		// int		PosHeight;
			-1,		// int		PosRoughness;

					// Position of the Material ID
			-1,		// int		PosMatID;

					// Position of the normal fields
//			1.0f,	// float	NormalFactor;	// Factor to apply to the height to generate the normals
			true,
			-1,		// int		PosNormalX;
			-1,		// int		PosNormalY;
			-1,		// int		PosNormalZ;

					// Position of the AO field
//			1.0f,	// float	AOFactor;		// Factor to apply to the height to generate the AO
			-1,		// int		PosAO;
		};

		m_pTexVoronoi = TB.CreateTexture( PixelFormatRG32F::DESCRIPTOR, Conv );


		m_pPrimParticle = new Primitive( gs_Device, EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT, pVertices, 0, NULL, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, VertexFormatPt4::DESCRIPTOR );

		// Build cell centers
		for ( int ParticleIndex=0; ParticleIndex < EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT; ParticleIndex++ )
			pCellCenters[ParticleIndex].Set( 0.5f * (pVertices[ParticleIndex].Pt.x + pVertices[ParticleIndex].Pt.z), 0.5f * (pVertices[ParticleIndex].Pt.y + pVertices[ParticleIndex].Pt.w) );

		delete[] pVertices;
	}

	//////////////////////////////////////////////////////////////////////////
	// Build the initial positions & orientations of the particles from the surface of a torus
	PixelFormatRGBA32F*	pInitialPositions = new PixelFormatRGBA32F[EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT];
	PixelFormatRGBA32F*	pInitialNormals = new PixelFormatRGBA32F[EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT];
	PixelFormatRGBA32F*	pInitialTangents = new PixelFormatRGBA32F[EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT];
	PixelFormatRGBA32F*	pScanlinePosition = pInitialPositions;
	PixelFormatRGBA32F*	pScanlineNormal = pInitialNormals;
	PixelFormatRGBA32F*	pScanlineTangent = pInitialTangents;

	int		TotalCount = EFFECT_PARTICLES_COUNT*EFFECT_PARTICLES_COUNT;
	int		ParticlesPerDimension = U32(floorf(powf( float(TotalCount), 1.0f/3.0f )));
	float	R = 0.5f;	// Great radius of the torus
	float	r = 0.2f;	// Small radius of the torus

	for ( int Y=0; Y < EFFECT_PARTICLES_COUNT; Y++ )
		for ( int X=0; X < EFFECT_PARTICLES_COUNT; X++, pScanlinePosition++, pScanlineNormal++, pScanlineTangent++ )
		{
			NjFloat2&	CellCenter = pCellCenters[EFFECT_PARTICLES_COUNT*Y+X];
			float		Alpha = TWOPI * X / EFFECT_PARTICLES_COUNT;	// Angle on the great circle
			float		Beta = TWOPI * Y / EFFECT_PARTICLES_COUNT;	// Angle on the small circle

			NjFloat3	T( cosf(Alpha), 0.0f, -sinf(Alpha) );		// Gives the direction to the center on the great circle in the Z^X plane
			NjFloat3	Center = NjFloat3( 0, 0.8f, 0 ) + R * T;	// Center on the great circle
			NjFloat3	Ortho( T.z, 0, -T.x );						// Tangent to the great circle in the Z^X plane
			NjFloat3	B( 0, 1, 0 );								// Bitangent is obviously, always the Y vector

			NjFloat3	Normal = cosf(Beta) * T + sinf(Beta) * B;	// The normal to the small circle, also the direction to the point on the surface
			NjFloat3	Tangent = Ortho;
			NjFloat3	Pos = Center + r * Normal;					// Position on the surface of the small circle

			float		Radius = R + r * cosf(Beta);				// Radius of the circle where the particle is standing
			float		Perimeter = TWOPI * Radius;					// Perimeter of that circle
			float		ParticleSize = 0.5f * Perimeter;			// Size of a single particle on that circle

			float		ParticleLife = -1.0f - 4.0f * (1.0f - Normal.y);	// Start with a negative life depending on height
 
// DEBUG Generate on a plane for verification
// Pos.x = 2.0f * (CellCenter.x - 0.5f);
// Pos.y = 0.5f;
// Pos.z = -2.0f * (CellCenter.y - 0.5f);
// Normal.Set( 0, 1, 0 );	// Facing up
// Tangent.Set( 1, 0, 0 );	// Right
// ParticleSize = 1.0f;// / EFFECT_PARTICLES_COUNT;	// Size of a single particle on that circle
// DEBUG


			pScanlinePosition->R = Pos.x;
			pScanlinePosition->G = Pos.y;
			pScanlinePosition->B = Pos.z;
			pScanlinePosition->A = ParticleLife;

			pScanlineNormal->R = Normal.x;
			pScanlineNormal->G = Normal.y;
			pScanlineNormal->B = Normal.z;
//			pScanlineNormal->A = (0.025f + 0.002f) * EFFECT_PARTICLES_COUNT;	// Half size + a little epsilon to make the tiles join correctly
//			pScanlineNormal->A = (0.1f + 0*0.002f) * EFFECT_PARTICLES_COUNT;	// Half size + a little epsilon to make the tiles join correctly
			pScanlineNormal->A = ParticleSize;

			pScanlineTangent->R = Tangent.x;
			pScanlineTangent->G = Tangent.y;
			pScanlineTangent->B = Tangent.z;
			pScanlineTangent->A = Normal.y > 0.0f ? 1.0f : -1.0f;	// Determines the particle's behavior...
		}

	delete[]	pCellCenters;

	// Unfortunately, we need to create Textures to initialize our RenderTargets
	void*		ppContentPositions[1];
				ppContentPositions[0] = (void*) pInitialPositions;
	Texture2D*	pTempPositions = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, ppContentPositions );
	delete[]	pInitialPositions;

	void*		ppContentNormals[1];
				ppContentNormals[0] = (void*) pInitialNormals;
	Texture2D*	pTempNormals = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, ppContentNormals );
	delete[]	pInitialNormals;

	void*		ppContentTangents[1];
				ppContentTangents[0] = (void*) pInitialTangents;
	Texture2D*	pTempTangents = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, ppContentTangents );
	delete[]	pInitialTangents;

	// Finally, create the render targets and initialize them
	m_ppRTParticlePositions[0] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticlePositions[1] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticlePositions[2] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticlePositions[0]->CopyFrom( *pTempPositions );
	m_ppRTParticlePositions[1]->CopyFrom( *pTempPositions );
	m_ppRTParticlePositions[2]->CopyFrom( *pTempPositions );
	delete	pTempPositions;

	m_ppRTParticleNormals[0] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticleNormals[1] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticleNormals[0]->CopyFrom( *pTempNormals );
	m_ppRTParticleNormals[1]->CopyFrom( *pTempNormals );
	delete pTempNormals;

	m_ppRTParticleTangents[0] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticleTangents[1] = new Texture2D( gs_Device, EFFECT_PARTICLES_COUNT, EFFECT_PARTICLES_COUNT, 1, PixelFormatRGBA32F::DESCRIPTOR, 1, NULL );
	m_ppRTParticleTangents[0]->CopyFrom( *pTempTangents );
	m_ppRTParticleTangents[1]->CopyFrom( *pTempTangents );
	delete pTempTangents;


	//////////////////////////////////////////////////////////////////////////
	// Create the constant buffers
	m_pCB_Render = new CB<CBRender>( gs_Device, 10 );
	m_pCB_Render->m.DeltaTime.Set( 0, 1 );
}
//*********************************
//pobierz trzy temperatury z dowolnego przedzia³u dowolnego bufora
void TempBuffGet(
  uint8_t pi_BuffType //typ bufora TEMP_BUFF12m/...
 ,uint8_t pi_Sensor   //numer termometru
//dla pi_Sensor==TEMP_FULLNO
//bie¿¹cy indeks: gt_TempBuffsIdx[pi_BuffType], rozmiar bufora: TempBuff(pi_BuffType,Size)
//dla pi_Sensor!=TEMP_FULLNO
//bie¿¹cy indeks: gi_Temps12mIdx, rozmiar bufora: TEMP_12MSIZE
 ,uint8_t pi_FirstIdx //pocz¹tkowy indeks
 ,uint8_t pi_LastIdx  //koñcowy indeks
 ,int16_t pt_Temps[]  //zwrócone temperatury [TEMP_MIN] [TEMP_AVG] [TEMP_MAX] tabelka MUSI mieæ 3 elementy
 ,uint8_t pi_Type //0: min/max liczone z buff[TEMP_AVG] 1: min/max liczone z buff[TEMP_MIN/TEMP_MAX]
) {

	int16_t  vt_Temps[TEMP_MAX+1];
	int32_t  vi_TempAVGSum;
	uint8_t  vi_TempCount;
	uint8_t  vi_Buff8Idx,vi_BuffSize,vi_CurrBuffIdx;
	uint16_t vi_BuffIdx,vi_LastIdx;
	int16_t *vt_TempsBuff;
	uint8_t vi_MinTempType,vi_MaxTempType;
	if (pi_Type) {
		vi_MinTempType = TEMP_MIN;
		vi_MaxTempType = TEMP_MAX;
	}
	else {
		vi_MinTempType = TEMP_AVG;
		vi_MaxTempType = TEMP_AVG;
	}

	pt_Temps[TEMP_MIN] = 0x7FFF;
	pt_Temps[TEMP_MAX] = 0x8000;
	vi_TempAVGSum  = 0;
	vi_TempCount   = 0;
	vt_TempsBuff   = 0;
	vi_CurrBuffIdx = gt_TempBuffsIdx[pi_BuffType];

	if (pi_BuffType) {
		vi_BuffSize    = TB(pi_BuffType,Size);
	}
	else if (pi_Sensor==TEMP_FULLNO) {
		vt_TempsBuff = gt_TempBuff12m;
		vi_BuffSize  = TB(TEMP_BUFF12m,Size);
	}
	else {
		vt_TempsBuff = gt_TempsVar[pi_Sensor].Buff12m;
		vi_BuffSize  = TEMP_12MSIZE;
	}

	vi_LastIdx = pi_LastIdx;
	if (vi_LastIdx<pi_FirstIdx)
		vi_LastIdx += TB(pi_BuffType,Size);

	for (vi_BuffIdx = pi_FirstIdx; vi_BuffIdx<=vi_LastIdx; vi_BuffIdx++) {

		vi_Buff8Idx = vi_BuffIdx%vi_BuffSize;
		if (pi_BuffType==TEMP_BUFF24m) {
			uint8_t vi_Buff8Idx2 = vi_Buff8Idx*2;
			TempBuffGet(TEMP_BUFF12m,pi_Sensor,vi_Buff8Idx2,
			  (vi_Buff8Idx!=gt_TempBuffsIdx[TEMP_BUFF24m] || vi_Buff8Idx2<gt_TempBuffsIdx[TEMP_BUFF12m])?vi_Buff8Idx2+1:vi_Buff8Idx2,
			  vt_Temps,0);
			vt_Temps[TEMP_MIN] = vt_Temps[TEMP_AVG];
			vt_Temps[TEMP_MAX] = vt_Temps[TEMP_AVG];
		}
		else
#if TEMP_USE_BUFF
		if (vt_TempsBuff)
#endif //TEMP_USE_BUFF
		{
			uint8_t vi_sreg = SREG;
			cli();
			vt_Temps[TEMP_MIN] = vt_TempsBuff[vi_Buff8Idx];
			SREG = vi_sreg;
			vt_Temps[TEMP_AVG] = vt_Temps[TEMP_MIN];
			vt_Temps[TEMP_MAX] = vt_Temps[TEMP_MIN];
		}
#if TEMP_USE_BUFF
		else
			if (vi_Buff8Idx == vi_CurrBuffIdx && gi_TempBuffCurrMode!=TEMP_BCM_READFROMEE)
				if (gi_TempBuffCurrMode==TEMP_BCM_READFROMCACHE)
					for (uint8_t vi_Idx=TEMP_MIN; vi_Idx<=TEMP_MAX; vi_Idx++)
						vt_Temps[vi_Idx] = gt_TempBuffCurrCache[vi_Idx];
				else
					TempBuffGetCurr(pi_BuffType,vt_Temps);
			else
				TempBuffRead(pi_BuffType,vi_Buff8Idx,vt_Temps);
#endif //TEMP_USE_BUFF

		if (vt_Temps[TEMP_MIN]!=TEMP_NONE16) {
			vi_TempCount++;
			if (vt_Temps[vi_MinTempType]<pt_Temps[TEMP_MIN]) pt_Temps[TEMP_MIN] = vt_Temps[vi_MinTempType];
			vi_TempAVGSum += vt_Temps[TEMP_AVG];
			if (vt_Temps[vi_MaxTempType]>pt_Temps[TEMP_MAX]) pt_Temps[TEMP_MAX] = vt_Temps[vi_MaxTempType];
		}
	}

	if (vi_TempCount)
		pt_Temps[TEMP_AVG] = DivL(vi_TempAVGSum,vi_TempCount);
	else
		MemClear_I16(&pt_Temps[TEMP_MIN],3);

} //TempBuffGet
//==============================================================
// PUBLIC PROCEDURES
//==============================================================
//int16_t gt_TempDebug[TEMP_MAX+1];
//*********************************
//inicjalizuj modu³
void TempInit(void) {
	uint8_t vi_Idx;
	
	TempStoreCurrTime();

	for (vi_Idx=0; vi_Idx<TEMP_COUNT; vi_Idx++) {
		MemClear_I16(gt_TempsVar[vi_Idx].Buff12m,TEMP_12MSIZE);
		gt_TempsVar[vi_Idx].ErrorCount = TEMP_MAX_ERRORS;
	}
	MemClear_I16(gt_TempBuff12m,TB(TEMP_BUFF12m,Size));

	//ustaw indeksy do buforów temperatur
	for (vi_Idx=0; vi_Idx<=TEMP_BUFFCOUNT; vi_Idx++)
		gt_TempBuffsIdx[vi_Idx] = TempBuffCurrIdx(vi_Idx);

#if TEMP_USE_BUFF
	//wyczyϾ wszystkie bufory EEPROM
	for (vi_Idx=1; vi_Idx<TEMP_BUFFCOUNT; vi_Idx++)
		if (TB(vi_Idx,EEMem))
			if (eeprom_read_byte(&gb_TempBuffsEEInitialized)!=1)
				EEMemClear_I8(TBAddr(vi_Idx),TB(vi_Idx,Size)*TB(vi_Idx,SubSize));
			else ;
		else
			MemClear_I8(TBAddr(vi_Idx),TB(vi_Idx,Size)*TB(vi_Idx,SubSize));
	eeprom_write_byte(&gb_TempBuffsEEInitialized,1);
#endif //TEMP_USE_BUFF

#ifdef TEMP_BUFF1D
	//ustaw w temps12m œredni¹/min/max zapisane w gt_Temps1D
	int16_t vt_Temps[TEMP_MAX+1];
	TempBuffRead(TEMP_BUFF1D,gt_TempBuffsIdx[TEMP_BUFF1D],vt_Temps);
	for (vi_Idx=0; vi_Idx<5*24; vi_Idx++)
		gt_TempBuff12m[vi_Idx] = vt_Temps[TEMP_AVG];
	gt_TempBuff12m[1] = vt_Temps[TEMP_MIN];
	gt_TempBuff12m[2] = vt_Temps[TEMP_MAX];
#endif //TEMP_BUFF1D

#if TEMP_USE_BUFF
	gt_Temp1dLastDate[TYear]  = gt_CurrTime[TYear];
	gt_Temp1dLastDate[TMonth] = gt_CurrTime[TMonth];
	gt_Temp1dLastDate[TDay]   = gt_CurrTime[TDay];
	gt_Temp1dLastDate[TDay+1] = gt_CurrTime[TWeekDay];
#endif //TEMP_USE_BUFF

/*	//uzupe³nianie bufora 1W z bufora 1D
	gi_TempBuffCurrMode = TEMP_BCM_READFROMEE;
	gt_TimeCheck[TDay] = 22;
	gt_TimeCheck[TWeekDay] = 0;
	gt_Temp1dLastDate[TDay] = 22;
	gt_Temp1dLastDate[TDay+1] = 0;
	int16_t vt_Temps[10];
	for (vi_Idx=0; vi_Idx<10; vi_Idx++) {
		TempBuffGetCurr(TEMP_BUFF1W,vt_Temps);
		TempBuffWrite(TEMP_BUFF1W,gt_TempBuffsIdx[TEMP_BUFF1W],vt_Temps);
		TimeGetDateFromDayNo(TimeGetDayNo(gt_TimeCheck[TDay],gt_TimeCheck[TMonth],gt_TimeCheck[TYear])-7,gt_Temp1dLastDate);
		gt_TimeCheck[TMonth] = gt_Temp1dLastDate[TMonth];
		gt_TimeCheck[TDay] = gt_Temp1dLastDate[TDay];
		gt_TempBuffsIdx[TEMP_BUFF1D] = TempBuffCurrIdx(TEMP_BUFF1D);
		gt_TempBuffsIdx[TEMP_BUFF1W] = TempBuffCurrIdx(TEMP_BUFF1W);
	}
	while (1);*/

	TimeAddHthProcedure(&TempExecuteHthSec);

} //TempInit