예제 #1
0
void Object::Rafinery::OnUpdate()
{
	if(m_Enabled && m_Conctructed)
	{
		if(GetStorage() && dynamic_cast<Model::Building*>(GetStorage())->IsConstructed())
		{
			if(m_Timer.Update(true) && GetStorage()->RequireSupply(Component::Storage::SupplyOil, 1))
			{
				GetStorage()->AddSupply(Component::Storage::SupplyPackage, 5);
				m_Timer.Reset();
			}
		}
		else if(m_Conctructed)
			Indicate(1);
	}
}
예제 #2
0
파일: Timer.c 프로젝트: alex262/MB90F591
// р рывани  Reload Timer 0 
__interrupt void ReloadTimer0(void) 
{   
	BYTE i;
	TMCSR0_UF = 0;       			/* reset underflow interrupt request flag */
//	timerInterrupt(1);
//	if(program.watch_dog>254) RESET;	//~1с
//		else program.watch_dog++;


	TimerService();// декрементирование пользовательских таймеров	
	
	//===========================================================================
	if(program.TimerCan0<TIME_OUT_CAN)	//(ok)
	{
		program.TimerCan0++;
		ClearError(ind_COMA);
		program.ErrorCAN&=(~Err_CAN1);
		(*STATE_BLOCK)&=~ST_Can1; 
	}
	if(program.TimerCan1<TIME_OUT_CAN)//(ok)
	{
		program.TimerCan1++;
		ClearError(ind_COMA);
		program.ErrorCAN&=(~Err_CAN2);
		(*STATE_BLOCK)&=~ST_Can2; 
	}
	program.COUNT++;
	Indicate(&program.COUNT,BLINK_LED/*200*/); //ok
	//===========================================================================
	//#ifdef PLATA_FSU22
	//	Fsu22.Timer++;
	//#endif
	//===========================================================================
	#ifdef PLATA_FSU22C
		Fsu22C.Timer++;			//not
	#endif
	//===========================================================================
	#ifdef PLATA_FSU
		//Fsu.Timer_Test++;
		Fsu.Timer++;	//ok
		Fsu.Timer2++;	//ok
	#endif
	//===========================================================================
	#ifdef PLATA_NDD
		Ndd.Timer++;	//not
		Ndd.Timer2++;	//not
		Ndd.TimerTest++;//ok
	#endif
	//===========================================================================
	#ifdef PLATA_ADC
		//Adc.TimerTem++;
		Adc.TimerTest++;	//not
		Adc.Timer++;
		//ReadAdcInt();
	#endif
	//===========================================================================
	#ifdef PLATA_DAC9
		Dac9.TimerErrDac++;	//not
		Dac9.TimerMaster++;
		#ifdef READ_TEMP
			Dac9.TimerTem++;	
		#endif
		ReadAdcInt();
		//SelectMasterDAC();
	#endif
	//===========================================================================
	#ifdef PLATA_AVV2C
		Avv.TimerTem++;
		Avv.Timer++;
	#endif
	#ifdef PLATA_RVV3C
		Rvv.Timer++;
	#endif
	//===========================================================================
	#ifdef PLATA_KVV
		Kvv.Timer++;
		Kvv.Timer2++;
	#endif
	#ifdef PLATA_KCU
		Kcu.Timer++;	//ok
	#endif
	//===========================================================================
	#ifdef PLATA_NDD20P1
//		Ndd.Timer1++;
		for(i=0;i<4;i++)
			Ndd.Timer2[i]++;
	#endif
	#ifdef PLATA_NDD20
		Ndd.Timer1++;
		Ndd.Timer2++;
	#endif
	//===========================================================================
	#ifdef PLATA_RVV5C
		Rvv.Timer++;
	#endif
	//===========================================================================
	#ifdef PLATA_RVV6
		Rvv.Timer++;
	#endif
	//===========================================================================
	#ifdef PLATA_NDD21
		Ndd.Timer++;
		Ndd.Timer2++;
	#endif
	//===========================================================================
	#ifdef PLATA_DAC10
		Dac10.Timer++;
		Dac10.TimerDin++;
		//Dac10.TimerAin++;
		Dac10.TimerTemp++;
		Dac10.TimerDout++;
		//Dac10.TimerErrDac++;
		Dac10.TimerMaster++;
		Dac10.TimerMasterError++;
	#endif
//===========================================================================
}
예제 #3
0
파일: AsukaLib.cpp 프로젝트: naka2/asukalib
/*** ローカルフックされたゲームウィンドウのウィンドウプロシージャ ***/
LRESULT CALLBACK Hook_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    DWORD PriorityClass[] = {0, IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS
                             , HIGH_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS
                            };
    RECT WindowRect,DesktopRect,ClientRect;
    int LocX,LocY;
    switch(message)
    {
    case WM_DESTROY:
        if(Ini.SaveWindowSettings)
        {
            GetWindowRect(MainWnd,&WindowRect);
            Ini.WindowLoc_h = WindowRect.top;
            Ini.WindowLoc_l = WindowRect.left;
            Ini.WindowSize_h = WindowRect.bottom - WindowRect.top;
            Ini.WindowSize_l = WindowRect.right - WindowRect.left;
        }

        break;
    case WM_NCACTIVATE:
        if(bFullscreen || lparam)
        {
            break;
        }

        if(!wparam)
        {
            bActive = FALSE;
            if(!Ini.EnableSound)
                SetVolumeForeachSoundBufferChain(TYPE_ALL,DSBVOLUME_MIN);
        }
        else
        {
            bActive = TRUE;
            if(!Ini.EnableSound)
            {
                SetVolumeForeachSoundBufferChain(TYPE_ALL,VOLUME_ALL);
            }
        }

        Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
        DefWindowProc(hwnd,message,wparam,lparam);

        if(Ini.EnableDraw)
        {
            return FALSE;
        }

        break;

    case WM_SIZE:
        if(wparam == SIZE_RESTORED)
        {
            SetCursor(LoadCursor(NULL, IDC_ARROW));
        }
        else if(wparam == SIZE_MINIMIZED)
        {
            SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
            bMinimize = 1;
            Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
        }
        else if(wparam == SIZE_MAXIMIZED)
        {
            SetPriorityClass(GetCurrentProcess(), PriorityClass[Ini.Priority]);
            bMinimize = 0;
            Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
        }
        break;

    case WM_SETCURSOR:
        if((HWND)wparam == MainWnd && Ini.WindowResizable)
        {
            switch(lparam&0xFFFF )
            {
            case HTTOP:
            case HTBOTTOM:
                SetCursor(LoadCursor(NULL,IDC_SIZENS));
                break;
            case HTLEFT:
            case HTRIGHT:
                SetCursor(LoadCursor(NULL,IDC_SIZEWE));
                break;
            case HTTOPLEFT:
            case HTBOTTOMRIGHT:
                SetCursor(LoadCursor(NULL,IDC_SIZENWSE));
                break;
            case HTTOPRIGHT:
            case HTBOTTOMLEFT:
                SetCursor(LoadCursor(NULL,IDC_SIZENESW));
                break;
            default:
                SetCursor(LoadCursor(NULL,IDC_ARROW));
                break;
            }
            return 1;
        }
        return 0;

    case WM_SIZING:
        if(Ini.WindowResizable)
        {
            RECT *rect = (RECT *)lparam;
            GetClientRect(MainWnd,&ClientRect);
            GetWindowRect(MainWnd,&WindowRect);
            double Ratio = ((double)(ClientRect.right-ClientRect.left)/(double)(ClientRect.bottom-ClientRect.top));
            int width = rect->right-rect->left-((WindowRect.right-WindowRect.left)-(ClientRect.right-ClientRect.left));
            int height = rect->bottom-rect->top-((WindowRect.bottom-WindowRect.top)-(ClientRect.bottom-ClientRect.top));
            int dw = (int)(height * Ratio + 0.5) - width;
            int dh = (int)(width / Ratio + 0.5) - height;

            switch(wparam)
            {
            case WMSZ_TOP:
                SetCursor(LoadCursor(NULL,IDC_SIZENS));
                if(Ini.HoldAspectRatio)
                {
                    rect->right += dw;
                }
                break;

            case WMSZ_BOTTOM:
                SetCursor(LoadCursor(NULL,IDC_SIZENS));
                if(Ini.HoldAspectRatio)
                {
                    rect->right += dw;
                }
                break;

            case WMSZ_LEFT:
                SetCursor(LoadCursor(NULL,IDC_SIZEWE));
                if(Ini.HoldAspectRatio)
                {
                    rect->bottom += dh;
                }
                break;

            case WMSZ_RIGHT:
                SetCursor(LoadCursor(NULL,IDC_SIZEWE));
                if(Ini.HoldAspectRatio)
                {
                    rect->bottom += dh;
                }
                break;

            case WMSZ_TOPLEFT:
                SetCursor(LoadCursor(NULL,IDC_SIZENWSE));
                if(Ini.HoldAspectRatio)
                {
                    if(dw > 0) rect->left -= dw;
                    else rect->top -= dh;
                }
                break;

            case WMSZ_TOPRIGHT:
                SetCursor(LoadCursor(NULL,IDC_SIZENESW));
                if(Ini.HoldAspectRatio)
                {
                    if(dw > 0) rect->right += dw;
                    else rect->top -= dh;
                }
                break;

            case WMSZ_BOTTOMLEFT:
                SetCursor(LoadCursor(NULL,IDC_SIZENESW));
                if(Ini.HoldAspectRatio)
                {
                    if(dw > 0) rect->left -= dw;
                    else rect->bottom += dh;
                }
                break;

            case WMSZ_BOTTOMRIGHT:
                SetCursor(LoadCursor(NULL,IDC_SIZENWSE));
                if(Ini.HoldAspectRatio)
                {
                    if(dw > 0) rect->right += dw;
                    else rect->bottom += dh;
                }
                break;
            }
        }
        break;

    case WM_KEYDOWN:
        if(!bActive)
        {
            return true;
        }
        if(!Ini.LockConfig)
        {
            if(GetKeyState(VK_CONTROL) & 0x8000)
            {
                if(GetKeyState(VK_SHIFT) & 0x8000)
                {
                    if(wparam == VK_UP) Ini.WaitVal += 1;
                    if(wparam == VK_DOWN && Ini.WaitVal) Ini.WaitVal -= 1;
                    if(wparam == VK_PRIOR) Ini.SEVol += 100;
                    if(wparam == VK_NEXT) Ini.SEVol -= 100;
                    // WaitValを0~1000の範囲に収める
                    Ini.WaitVal = Ini.WaitVal <= 1000 ? Ini.WaitVal >=0 ? Ini.WaitVal : 0 : 1000;
                    // SEVolを-10000~0の範囲に収める
                    Ini.SEVol = Ini.SEVol <= 0 ? Ini.SEVol >= -10000 ? Ini.SEVol : -10000 : 0;
                    Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
                    SetVolumeForeachSoundBufferChain(TYPE_SE,VOLUME_SE);
                    break;
                }
                if(wparam == VK_UP) Ini.Priority ++;
                if(wparam == VK_DOWN) Ini.Priority --;
                if(wparam == VK_PRIOR) Ini.BGMVol += 100;
                if(wparam == VK_NEXT) Ini.BGMVol -= 100;
                // Priorityを1~4の範囲に収める
                Ini.Priority = Ini.Priority <= 4 ? Ini.Priority >= 1 ? Ini.Priority : 1 : 4;
                SetPriorityClass(GetCurrentProcess(), PriorityClass[Ini.Priority]);
                // BGMVolを-10000~0の範囲に収める
                Ini.BGMVol = Ini.BGMVol <= 0 ? Ini.BGMVol >=-10000 ? Ini.BGMVol : -10000 : 0;
                SetVolumeForeachSoundBufferChain(TYPE_BGM,VOLUME_BGM);
                Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
            }
        }
        break;

    case WM_RBUTTONUP:
        POINT pt;
        pt.x = LOWORD(lparam);
        pt.y = HIWORD(lparam);
        ClientToScreen(hwnd, &pt);
        TrackPopupMenu(SubPopup,TPM_LEFTALIGN,(int)pt.x,pt.y,0,hwnd,NULL);
        break;

    case WM_COMMAND:
        switch(LOWORD(wparam)) {
        case IDM_CONFIG:
            if(DialogBox((HINSTANCE)hDLL,MAKEINTRESOURCE(IDD_CONFIG),hwnd,ConfigDialogProc)) {
                SetVolumeForeachSoundBufferChain(TYPE_ALL,VOLUME_ALL);
                Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
            }
            break;
        case IDM_MUTE_BGM:
            Ini.BGMMute = !Ini.BGMMute;
            if(Ini.BGMMute)
                CheckMenuItem(SubPopup,IDM_MUTE_BGM,MF_CHECKED);
            else
                CheckMenuItem(SubPopup,IDM_MUTE_BGM,MF_UNCHECKED);
            SetVolumeForeachSoundBufferChain(TYPE_BGM,VOLUME_BGM);
            Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
            break;
        case IDM_MUTE_SE:
            Ini.SEMute = !Ini.SEMute;
            if(Ini.SEMute)
                CheckMenuItem(SubPopup,IDM_MUTE_SE,MF_CHECKED);
            else
                CheckMenuItem(SubPopup,IDM_MUTE_SE,MF_UNCHECKED);
            SetVolumeForeachSoundBufferChain(TYPE_SE,VOLUME_SE);
            Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
            break;
        case IDM_LOCK_CONFIG:
            Ini.LockConfig = !Ini.LockConfig;
            if(Ini.LockConfig)
                CheckMenuItem(SubPopup,IDM_LOCK_CONFIG,MF_CHECKED);
            else
                CheckMenuItem(SubPopup,IDM_LOCK_CONFIG,MF_UNCHECKED);
            Indicate(Ini.Priority,Ini.WaitVal,Ini.BGMVol,Ini.SEVol);
            break;
        case IDM_RESIZABLE:
            Ini.WindowResizable = !Ini.WindowResizable;
            if(Ini.WindowResizable) {
                CheckMenuItem(SubPopup,IDM_RESIZABLE,MF_CHECKED);
                EnableMenuItem(SubPopup,IDM_HOLDASPECTRATIO,MF_ENABLED);
                EnableMenuItem(SubPopup,IDM_SIZE_640,MF_ENABLED);
                EnableMenuItem(SubPopup,IDM_SIZE_800,MF_ENABLED);
                EnableMenuItem(SubPopup,IDM_SIZE_960,MF_ENABLED);
                SetWindowLong(MainWnd,GWL_STYLE,GetWindowLong(MainWnd,GWL_STYLE)|WS_MAXIMIZEBOX|WS_THICKFRAME);
            } else {
                CheckMenuItem(SubPopup,IDM_RESIZABLE,MF_UNCHECKED);
                EnableMenuItem(SubPopup,IDM_HOLDASPECTRATIO,MF_GRAYED);
                EnableMenuItem(SubPopup,IDM_SIZE_640,MF_GRAYED);
                EnableMenuItem(SubPopup,IDM_SIZE_800,MF_GRAYED);
                EnableMenuItem(SubPopup,IDM_SIZE_960,MF_GRAYED);
                SetWindowLong(MainWnd,GWL_STYLE,GetWindowLong(MainWnd,GWL_STYLE)^WS_MAXIMIZEBOX^WS_THICKFRAME);
            }
            InvalidateRect(NULL , NULL , TRUE);
            break;

        case IDM_HOLDASPECTRATIO:
            Ini.HoldAspectRatio = !Ini.HoldAspectRatio;
            if(Ini.HoldAspectRatio)
                CheckMenuItem(SubPopup,IDM_HOLDASPECTRATIO,MF_CHECKED);
            else
                CheckMenuItem(SubPopup,IDM_HOLDASPECTRATIO,MF_UNCHECKED);
            break;

        case IDM_SIZE_640:
            GetWindowRect(MainWnd,&WindowRect);
            GetClientRect(MainWnd,&ClientRect);
            SetWindowPos(MainWnd,NULL,0,0
                         ,(WindowRect.right-WindowRect.left)-(ClientRect.right-ClientRect.left)+640
                         ,(WindowRect.bottom-WindowRect.top)-(ClientRect.bottom-ClientRect.top)+480
                         ,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
            break;
        case IDM_SIZE_800:
            GetWindowRect(MainWnd,&WindowRect);
            GetClientRect(MainWnd,&ClientRect);
            SetWindowPos(MainWnd,NULL,0,0
                         ,(WindowRect.right-WindowRect.left)-(ClientRect.right-ClientRect.left)+800
                         ,(WindowRect.bottom-WindowRect.top)-(ClientRect.bottom-ClientRect.top)+600
                         ,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
            break;
        case IDM_SIZE_960:
            GetWindowRect(MainWnd,&WindowRect);
            GetClientRect(MainWnd,&ClientRect);
            SetWindowPos(MainWnd,NULL,0,0
                         ,(WindowRect.right-WindowRect.left)-(ClientRect.right-ClientRect.left)+960
                         ,(WindowRect.bottom-WindowRect.top)-(ClientRect.bottom-ClientRect.top)+720
                         ,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
            break;

        case IDM_LOC_LEFTTOP:
            SetWindowPos(MainWnd,NULL,0,0,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
            break;
        case IDM_LOC_LEFTBOTTOM:
            GetWindowRect(MainWnd,&WindowRect);
            GetWindowRect(GetDesktopWindow(),&DesktopRect);
            LocX = 0;
            LocY = DesktopRect.bottom - (WindowRect.bottom-WindowRect.top);
            SetWindowPos(MainWnd,NULL,LocX,LocY,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
            break;
        case IDM_LOC_RIGHTTOP:
            GetWindowRect(MainWnd,&WindowRect);
            GetWindowRect(GetDesktopWindow(),&DesktopRect);
            LocX = DesktopRect.right - (WindowRect.right-WindowRect.left);
            LocY = 0;
            SetWindowPos(MainWnd,NULL,LocX,LocY,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
            break;
        case IDM_LOC_RIGHTBOTTOM:
            GetWindowRect(MainWnd,&WindowRect);
            GetWindowRect(GetDesktopWindow(),&DesktopRect);
            LocX = DesktopRect.right - (WindowRect.right-WindowRect.left);
            LocY = DesktopRect.bottom - (WindowRect.bottom-WindowRect.top);
            SetWindowPos(MainWnd,NULL,LocX,LocY,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
            break;
        case IDM_LOC_CENTER:
            GetWindowRect(MainWnd,&WindowRect);
            GetWindowRect(GetDesktopWindow(),&DesktopRect);
            LocX = (DesktopRect.right - (WindowRect.right-WindowRect.left))/2;
            LocY = (DesktopRect.bottom - (WindowRect.bottom-WindowRect.top))/2;
            SetWindowPos(MainWnd,NULL,LocX,LocY,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
            break;

        }
        break;
    }
    return (*pWindowProc)(hwnd, message, wparam, lparam);
}
 void SetCurrentValue( double value ) { m_currentValue = value; Indicate(); }
 void AddCurrentValue( double value ) { m_currentValue += value; Indicate(); }
 void SetUnits( const string& units ) { m_units = units; Indicate(); }
 void SetMessage( const string& message ) { m_message = message; Indicate(); }
 virtual void Increment() { m_currentValue += m_increment; Indicate(); }