Example #1
0
int main( int argc, char *argv[] )
{
	OSStatus		err;
	
	debug_initialize( kDebugOutputTypeMetaConsole );
	debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelVerbose );
	
	err = ProcessArgs( argc, argv );
	return( (int) err );
}
CCPApp::CCPApp()
{
	debug_initialize( kDebugOutputTypeWindowsEventLog, "DNS-SD Control Panel", GetModuleHandle( NULL ) );
	debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelInfo );
}
Example #3
0
rt_public void eif_rtinit(int argc, EIF_NATIVE_CHAR **argv, EIF_NATIVE_CHAR **envp)
{
	char *eif_timeout;

		/* Retrieve root argument if any and update `argc' accordingly. */
	eif_retrieve_root(&argc, argv);

#ifdef EIF_WINDOWS
	set_windows_exception_filter();

#if defined(_MSC_VER) && _MSC_VER >= 1400 /* version 14.0+ (MSVC 8.0+)  */
		/* Ensures consistent behavior across all our platforms where we
		 * get 2-digit exponent up to 99 and then 3-digit exponent for 100 and
		 * above. */
   (void) _set_output_format(_TWO_DIGIT_EXPONENT);
#endif

#endif

#ifdef BOEHM_GC
	GC_register_displacement (OVERHEAD);
#endif

	ieee_init();
	starting_working_directory = (char *) eif_malloc (PATH_MAX + 1);
		/* Initialize directory to an empty string by default. */
	starting_working_directory [0] = '\0';

	ufill();							/* Get urgent memory chunks */

#if defined(DEBUG) && (EIF_OS != EIF_OS_VXWORKS) && !defined(EIF_WINDOWS)
	/* The following install signal handlers for signals USR1 and USR2. Both
	 * raise an immediate scanning of memory and dumping of the free list usage
	 * and other statistics. The difference is that USR1 also performrs a full
	 * GC cycle before runnning the diagnosis. If memck() is programmed to
	 * panic when inconsistencies are detected, this may raise a system failure
	 * due to race condition. There is nothing the user can do about it, except
	 * pray--RAM.
	 */

	esignal(SIGUSR1, mem_diagnose);
	esignal(SIGUSR2, mem_diagnose);
#endif

	/* Check if the user wants to override the default timeout value
	 * for interprocess communications (IPC). This new value is specified in
	 * the ISE_TIMEOUT environment variable
	 */
	eif_timeout = getenv("ISE_TIMEOUT");
	if ((eif_timeout != NULL) && (strlen(eif_timeout) > 0)) {		/* Environment variable set */
		TIMEOUT = (unsigned) atoi(eif_timeout);
	} else {
		TIMEOUT = 30;
	}

	eoption = egc_foption;

#ifdef WORKBENCH
	xinitint();							/* Interpreter initialization */
	esystem = egc_fsystem;
	eif_par_table = egc_partab;
	eif_par_table_size = egc_partab_size;
	eorg_table = egc_forg_table;
	pattern = egc_fpattern;

	debug_initialize(); /* Initialize debug information (breakpoints ...) */

	/* In workbench mode, we have a slight problem: when we link ewb in
	 * workbench mode, since ewb is a child from ised, the run-time will
	 * assume, wrongly, that the executable is started in debug mode. Therefore,
	 * we need a special run-time, with no debugging hooks involved.
	 */
#ifndef NOHOOK
	winit();					/* Did we start under ewb control? */
#endif

	/* Initialize dynamically computed variables (i.e. system dependent)
	 * Then we may call update. Eventually, when debugging the
	 * application, the values loaded from the update file will be overridden
	 * by the workbench (via winit).
	 */

	egc_einit();							/* Various static initializations */
	fcount = scount;

	{
		char temp = 0;
		int i;

		for (i=1;i<argc;i++) {
			if (0 == rt_nstrcmp (argv[i], rt_nmakestr("-ignore_updt"))) {
				temp = (char) 1;	
				break;
			}
		}
		update(temp, argv[0]);					
	}									/* Read melted information
										 * Note: the `update' function takes
										 * care of the initialization of the 
										 * temporary descriptor structures
										 */

	create_desc();						/* Create descriptor (call) tables */
	
#else

	/*
	 * Initialize the finalized system with the static data structures.
	 */
	esystem = egc_fsystem;
	eif_par_table = egc_partab;
	eif_par_table_size = egc_partab_size;
	eif_gen_conf_init (eif_par_table_size);
	nbref = egc_fnbref;
	esize = egc_fsize;

#endif

#if !defined CUSTOM || defined NEED_UMAIN_H
	umain(argc, argv, envp);			/* User's initializations */
#endif
#if !defined CUSTOM || defined NEED_ARGV_H
	rt_arg_init(argc, argv);				/* Save copy for class ARGUMENTS */
#endif
	eif_environ = envp;				/* Save pointer to environment variable storage */
	once_init();
#if defined(EIF_THREADS) && defined(WORKBENCH)
	notify_root_thread();
#endif
	initprf();						/* Initialize profiler. */
	init_emnger();					/* Initialize ISE_EXCEPTION_MANAGER */
	init_scp_manager();				/* Initialize ISE_SCOOP_MANAGER */

		/* Initialize our root class. */
	eif_init_root();
}
BOOL CPrinterSetupWizardApp::InitInstance()
{
	CString		errorMessage;
	CString		errorCaption;
	wchar_t		resource[MAX_PATH];
	int			res;
	OSStatus	err = kNoErr;

	//
	// initialize the debugging framework
	//
	debug_initialize( kDebugOutputTypeWindowsDebugger, "PrinterSetupWizard", NULL );
	debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );

	// Before we load the resources, let's load the error string

	errorMessage.LoadString( IDS_REINSTALL );
	errorCaption.LoadString( IDS_REINSTALL_CAPTION );

	// Load Resources

	res = PathForResource( NULL, L"RendezvousPrinterWizard.dll", resource, MAX_PATH );
	err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
	require_noerr( err, exit );

	g_nonLocalizedResources = LoadLibrary( resource );
	translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
	require_noerr( err, exit );

	res = PathForResource( NULL, L"RendezvousPrinterWizardLocalized.dll", resource, MAX_PATH );
	err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
	require_noerr( err, exit );

	g_localizedResources = LoadLibrary( resource );
	translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
	require_noerr( err, exit );
		
	AfxSetResourceHandle( g_localizedResources );

	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	{
		CPrinterSetupWizardSheet dlg(IDS_CAPTION);

		m_pMainWnd = &dlg;

		try
		{
			INT_PTR nResponse = dlg.DoModal();
		
			if (nResponse == IDOK)
			{
				// TODO: Place code here to handle when the dialog is
				//  dismissed with OK
			}
			else if (nResponse == IDCANCEL)
			{
				// TODO: Place code here to handle when the dialog is
				//  dismissed with Cancel
			}
		}
		catch (CPrinterSetupWizardSheet::WizardException & exc)
		{
			MessageBox(NULL, exc.text, exc.caption, MB_OK|MB_ICONEXCLAMATION);
		}
	}

exit:

	if ( err )
	{
		MessageBox( NULL, errorMessage, errorCaption, MB_ICONERROR | MB_OK );
	}

	if ( g_nonLocalizedResources )
	{
		FreeLibrary( g_nonLocalizedResources );
	}

	if ( g_localizedResources )
	{
		FreeLibrary( g_localizedResources );
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Example #5
0
File: main.c Project: bielskij/avr
int main(void) {
	// Output direction for PWM OC0B. It is not
	// automatically set when timer starts
	DDRB |= _BV(PIN1);

#if defined(DEBUG) && DEBUG == 1
	debug_initialize();

	debug_sendByte(0xff);
#endif

	{
		// Prescaler 64, ~5,7 kSps (F_CPU / 128 / 13)
		ADCSRA = _BV(ADPS0) | _BV(ADPS1) | _BV(ADPS2);

		// Only the highest 8 bits are used (PB3)
		// 1.1V internal voltage reference
		ADMUX = _BV(ADLAR) | _BV(REFS0);

		// Disable Digital Input circuit for analog pins
		DIDR0 |= (_BV(ADC0D) | _BV(ADC2D) | _BV(ADC3D));

		// Eable ADC
		ADCSRA |= _BV(ADEN);
	}

	_delay_ms(200);

	// Disable analog comparator
	ACSR |= _BV(ACD);

	{
		// Fast PWM - mode 7
		// Clear OC0B on Compare Match, set OC0B at TOP
		TCCR0A = _BV(WGM00) | _BV(WGM01) | _BV(COM0B1);
		TCCR0B = _BV(WGM02);

		OCR0A = TIMER_TOP;
		OCR0B = 0;

		// Start timer - no prescaling
		// In fast pwm mode frequency is ~147kHz
		TCCR0B |= _BV(CS00);
	}

	sei();

	// Dummy read - first conversion is much longer
	_getAdcValue(0);

	while (1) {
		uint8_t currentValue = _getAdcValue(ADC_PIN_CURRENT);
		uint8_t voltageValue = _getAdcValue(ADC_PIN_VOLTAGE);

#if defined(DEBUG) && DEBUG == 1
		debug_sendByte(currentValue);
		debug_sendByte(voltageValue);
		debug_sendByte(OCR0B);
#endif

		if (voltageValue >= PWM_ADC_VOLTAGE_MAX) {
			if (OCR0B >= 2) {
				OCR0B -= 2;

			} else {
				OCR0B = 0;
			}

			continue;
		}

		if (currentValue < PWM_ADC_CURRENT_MAX - PWM_ADC_CURRENT_TRESHOLD_MIN) {
			if (OCR0B < PWM_OCR_MAX) {
				OCR0B++;
			}

		} else if (currentValue > PWM_ADC_CURRENT_MAX + PWM_ADC_CURRENT_TRESHOLD_MAX) {
			if (OCR0B > 0) {
				OCR0B--;
			}
		}
	}

	return 0;
}
BOOL
CCPApp::InitInstance()
{
    CCommandLineInfo	commandLine;
    wchar_t				resource[MAX_PATH];
    CString				errorMessage;
    CString				errorCaption;
    int					res;
    OSStatus			err = kNoErr;

    HeapSetInformation( NULL, HeapEnableTerminationOnCorruption, NULL, 0 );

    //
    // initialize the debugging framework
    //
    debug_initialize( kDebugOutputTypeWindowsDebugger, "ControlPanel", NULL );
    debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );

    // Before we load the resources, let's load the error string

    errorMessage.LoadString( IDS_REINSTALL );
    errorCaption.LoadString( IDS_REINSTALL_CAPTION );

    res = PathForResource( NULL, L"ControlPanelResources.dll", resource, MAX_PATH );
    err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
    require_noerr( err, exit );

    g_nonLocalizedResources = LoadLibrary( resource );
    translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
    require_noerr( err, exit );

    res = PathForResource( NULL, L"ControlPanelLocalized.dll", resource, MAX_PATH );
    err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
    require_noerr( err, exit );

    g_localizedResources = LoadLibrary( resource );
    translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
    require_noerr( err, exit );

    AfxSetResourceHandle( g_localizedResources );

    // InitCommonControls() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.

    InitCommonControls();

    CWinApp::InitInstance();

    AfxEnableControlContainer();

    ParseCommandLine( commandLine );

    if ( commandLine.m_nShellCommand == CCommandLineInfo::AppRegister )
    {
        CString		localizedName;
        CString		toolTip;
        TCHAR		iconPath[ MAX_PATH + 12 ]	= TEXT( "" );
        TCHAR		exePath[ MAX_PATH ]			= TEXT( "" );
        DWORD		nChars;
        OSStatus	err;

        nChars = GetModuleFileName( NULL, exePath, sizeof_array( exePath ) );

        err = translate_errno( nChars > 0, (OSStatus) GetLastError(), kUnknownErr );

        require_noerr( err, exit );

        wsprintf( iconPath, L"%s,-%d", exePath, IDR_APPLET );

        localizedName.LoadString( IDS_APPLET_NAME );
        toolTip.LoadString( IDS_APPLET_TOOLTIP );

        Register( g_controlPanelGUID, g_controlPanelName, g_controlPanelCanonicalName, g_controlPanelCategory, localizedName, toolTip, iconPath, exePath );
    }
    else if ( commandLine.m_nShellCommand == CCommandLineInfo::AppUnregister )
    {
        Unregister( g_controlPanelGUID );
    }
    else
    {
        CString					name;
        CConfigPropertySheet	dlg;

        name.LoadString( IDR_APPLET );
        dlg.Construct( name, NULL, 0 );

        m_pMainWnd = &dlg;

        try
        {
            INT_PTR nResponse = dlg.DoModal();

            if (nResponse == IDOK)
            {
                // TODO: Place code here to handle when the dialog is
                //  dismissed with OK
            }
            else if (nResponse == IDCANCEL)
            {
                // TODO: Place code here to handle when the dialog is
                //  dismissed with Cancel
            }
        }
        catch (...)
        {
            MessageBox(NULL, L"", L"", MB_OK|MB_ICONEXCLAMATION);
        }
    }

    if ( err )
    {
        MessageBox( NULL, L"", L"", MB_ICONERROR | MB_OK );
    }

exit:

    if ( err )
    {
        MessageBox( NULL, errorMessage, errorCaption, MB_ICONERROR | MB_OK );
    }

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}