Ejemplo n.º 1
0
bool MenuState::onEnter()
{
	SoundManager::Instance()->playMusic("SongMenu", -1);
	SDL_Renderer* render;
	render = Game::Instance()->getRender();
	SDL_SetRenderDrawColor(render, 255, 229, 204, 255);
	Game::Instance()->setRender(render);
	// parse the state
	StateParser stateParser;
	stateParser.parseState("assets/images.xml", s_menuID, &m_gameObjectsMenuState, &m_textureIDList);
	m_callbacksMenu.push_back(0); //pushback 0 callbackID start from 1
	m_callbacksMenu.push_back(s_menuToPlay);
	m_callbacksMenu.push_back(s_exitFromMenu);
	// set the callbacks for menu items
	setCallbacks(m_callbacksMenu);

	return true;
}
Ejemplo n.º 2
0
int main()
{
	int i,result;
	fd_set readfds;
	struct timeval tv;
	printf("Initializing OSIP\n");
	TRACE_INITIALIZE(END_TRACE_LEVEL,NULL);
	if(networkInit() < 0){
		printf("ERROR Initializing NETWORK\n");
		return -1;
	}
	i=osip_init(&osip);
	if (i!=0)
		return -1;
	printf("Setting Callbacks\n");
	setCallbacks(osip);
	printf("Entering Main loop 1\n");
	OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"Check OSIP_TRACE init\n"));
	bSipRegister("This is Test Cookie");
	while(1){
		FD_ZERO(&readfds);
		FD_SET(sipSock,&readfds);
		tv.tv_sec = 0;
		tv.tv_usec = 100000;
		result = select(FD_SETSIZE,&readfds,0,0,&tv);
		if(result < 0){
			perror("main: select error");
			exit(1);
		}
		if(FD_ISSET(sipSock,&readfds)){
			printf("main: Received SIP message\n");
			processSipMsg();
		}
		osip_ict_execute(osip);
		osip_ist_execute(osip);
		osip_nict_execute(osip);
		osip_nist_execute(osip);
		osip_timers_ict_execute(osip);
		osip_timers_ist_execute(osip);
		osip_timers_nict_execute(osip);
		osip_timers_nist_execute(osip);
	}
	return 0;
}
Ejemplo n.º 3
0
bool MenuState::onEnter() {

	if (!TextureManager::Instance()->load("play.bmp", "play", Game::Instance()->getRender())) {
		return false;
	}
	if (!TextureManager::Instance()->load("exit.bmp", "exit", Game::Instance()->getRender())) {
		return false;
	}

	StateParser stateParser;
	stateParser.parseState("XMLFile.xml", s_menuID, &m_gameObjects, &m_textureIDList);

	m_callbacks.push_back(0); //El primero vacío
	m_callbacks.push_back(s_menuToPlay);
	m_callbacks.push_back(s_exitFromMenu);
	setCallbacks(m_callbacks);
	
	return true;
}
Ejemplo n.º 4
0
bool PlayState::onEnter() {

	StateParser stateParser;
	stateParser.parseState("./Data/Tiny.xml", s_playID, &m_gObjects, &m_TextureIDList);

	LevelParser levelParser;
	pLevel = levelParser.parseLevel("./Data/mapaObjetos.tmx");

	//layerParser.parseTileLayer("./Data/mapa1.tmx");
	

	m_callbacks.push_back(0);
	setCallbacks();

	SoundManager::Instance()->playMusic("play", -1);

	/*player = new Player();
	zep = new Zep();
	gordo = new Gordo();

	TextureManager::Instance()->load("Kirby.bmp", "player", Game::Instance()->getRender());
	TextureManager::Instance()->load("ZepS.bmp", "zep", Game::Instance()->getRender());
	TextureManager::Instance()->load("GordoS.bmp", "gordo", Game::Instance()->getRender());

	load = new LoaderParams(100, 100, 35, 32,10, "player",0);
	load2 = new LoaderParams(200, 200, 89, 78,4, "zep",0);
	load3 = new LoaderParams(400, 300, 50, 70,4, "gordo", 0);

	player->load(load);
	m_gObjects.push_back(player);

	zep->load(load2);
	m_gObjects.push_back(zep);

	gordo->load(load3);
	m_gObjects.push_back(gordo);*/

	

	return true;
}
Ejemplo n.º 5
0
void VlcQmlVideoObject::connectToMediaPlayer(VlcMediaPlayer *player)
{
    setCallbacks(player);
}
Ejemplo n.º 6
0
int main(int argc, const char **argv)
#endif
{
	bContext *C = CTX_create();
	SYS_SystemHandle syshandle;

#ifndef WITH_PYTHON_MODULE
	bArgs *ba;
#endif

#ifdef WIN32
	wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
	int argci = 0;
	char **argv = MEM_mallocN(argc * sizeof(char *), "argv array");
	for (argci = 0; argci < argc; argci++) {
		argv[argci] = alloc_utf_8_from_16(argv_16[argci], 0);
	}
	LocalFree(argv_16);
#endif

#ifdef WITH_PYTHON_MODULE
#ifdef __APPLE__
	environ = *_NSGetEnviron();
#endif

#undef main
	evil_C = C;
#endif



#ifdef WITH_BINRELOC
	br_init(NULL);
#endif

#ifdef WITH_LIBMV
	libmv_initLogging(argv[0]);
#endif

	setCallbacks();
#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
	/* patch to ignore argument finder gives us (pid?) */
	if (argc == 2 && strncmp(argv[1], "-psn_", 5) == 0) {
		extern int GHOST_HACK_getFirstFile(char buf[]);
		static char firstfilebuf[512];

		argc = 1;

		if (GHOST_HACK_getFirstFile(firstfilebuf)) {
			argc = 2;
			argv[1] = firstfilebuf;
		}
	}

#endif

#ifdef __FreeBSD__
	fpsetmask(0);
#endif

	/* initialize path to executable */
	BLI_init_program_path(argv[0]);

	BLI_threadapi_init();

	initglobals();  /* blender.c */

	IMB_init();
	BKE_images_init();

	BKE_brush_system_init();

	BLI_callback_global_init();

#ifdef WITH_GAMEENGINE
	syshandle = SYS_GetSystem();
#else
	syshandle = 0;
#endif

	/* first test for background */
#ifndef WITH_PYTHON_MODULE
	ba = BLI_argsInit(argc, (const char **)argv); /* skip binary path */
	setupArguments(C, ba, &syshandle);

	BLI_argsParse(ba, 1, NULL, NULL);

	if (use_crash_handler) {
		/* after parsing args */
		signal(SIGSEGV, blender_crash_handler);
	}
#else
	G.factory_startup = true;  /* using preferences or user startup makes no sense for py-as-module */
	(void)syshandle;
#endif

#ifdef WITH_FFMPEG
	IMB_ffmpeg_init();
#endif

	/* after level 1 args, this is so playanim skips RNA init */
	RNA_init();

	RE_engines_init();
	init_nodesystem();
	/* end second init */


#if defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS)
	G.background = true; /* python module mode ALWAYS runs in background mode (for now) */
#else
	/* for all platforms, even windos has it! */
	if (G.background) {
		signal(SIGINT, blender_esc);  /* ctrl c out bg render */
	}
#endif

	/* background render uses this font too */
	BKE_vfont_builtin_register(datatoc_bfont_pfb, datatoc_bfont_pfb_size);

	/* Initialize ffmpeg if built in, also needed for bg mode if videos are
	 * rendered via ffmpeg */
	sound_init_once();
	
	init_def_material();

	if (G.background == 0) {
#ifndef WITH_PYTHON_MODULE
		BLI_argsParse(ba, 2, NULL, NULL);
		BLI_argsParse(ba, 3, NULL, NULL);
#endif
		WM_init(C, argc, (const char **)argv);

		/* this is properly initialized with user defs, but this is default */
		/* call after loading the startup.blend so we can read U.tempdir */
		BLI_init_temporary_dir(U.tempdir);

#ifdef WITH_SDL
		BLI_setenv("SDL_VIDEODRIVER", "dummy");
#endif
	}
	else {
#ifndef WITH_PYTHON_MODULE
		BLI_argsParse(ba, 3, NULL, NULL);
#endif

		WM_init(C, argc, (const char **)argv);

		/* don't use user preferences temp dir */
		BLI_init_temporary_dir(NULL);
	}
#ifdef WITH_PYTHON
	/**
	 * NOTE: the U.pythondir string is NULL until WM_init() is executed,
	 * so we provide the BPY_ function below to append the user defined
	 * python-dir to Python's sys.path at this point.  Simply putting
	 * WM_init() before #BPY_python_start() crashes Blender at startup.
	 */

	/* TODO - U.pythondir */
#else
	printf("\n* WARNING * - Blender compiled without Python!\nthis is not intended for typical usage\n\n");
#endif
	
	CTX_py_init_set(C, 1);
	WM_keymap_init(C);

#ifdef WITH_FREESTYLE
	/* initialize Freestyle */
	FRS_initialize();
	FRS_set_context(C);
#endif

	/* OK we are ready for it */
#ifndef WITH_PYTHON_MODULE
	BLI_argsParse(ba, 4, load_file, C);
	
	if (G.background == 0) {
		if (!G.file_loaded)
			if (U.uiflag2 & USER_KEEP_SESSION)
				WM_recover_last_session(C, NULL);
	}

#endif

#ifndef WITH_PYTHON_MODULE
	BLI_argsFree(ba);
#endif

#ifdef WIN32
	while (argci) {
		free(argv[--argci]);
	}
	MEM_freeN(argv);
	argv = NULL;
#endif

#ifdef WITH_PYTHON_MODULE
	return 0; /* keep blender in background mode running */
#endif

	if (G.background) {
		/* actually incorrect, but works for now (ton) */
		WM_exit(C);
	}
	else {
		if (G.fileflags & G_FILE_AUTOPLAY) {
			if (G.f & G_SCRIPT_AUTOEXEC) {
				if (WM_init_game(C)) {
					return 0;
				}
			}
			else {
				if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
					G.f |= G_SCRIPT_AUTOEXEC_FAIL;
					BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Game AutoStart");
				}
			}
		}

		if (!G.file_loaded) {
			WM_init_splash(C);
		}
	}

	WM_main(C);

	return 0;
} /* end of int main(argc, argv)	*/
Ejemplo n.º 7
0
int main()
{
    const std::string checkFile = "shader/flush.frag";
    if (!std::ifstream(checkFile).good()) {
        glow::fatal("Seems that Elemate is running in a wrong working directory.");
        glow::fatal("(Cannot find %;)", checkFile);
        fgetc(stdin);
        return -1;
    }

    if (!glfwInit()) {
        glow::fatal("Could not initialize glfw.");
        return -1;
    }

    glfwSetErrorCallback(errorCallback);

    const int initialWidth = 640;
    const int initialHeight = 480;


    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, MajorVersionRequire);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, MinorVersionRequire);

#ifndef BUMBLEBEE // Running with bumblebee causes the following commands to crash.
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    if (MajorVersionRequire >= 3 && MinorVersionRequire >= 2)
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif

    GLFWwindow * window = glfwCreateWindow(initialWidth, initialHeight, "Elemate", NULL, NULL);
    if (!window)
    {
        glow::fatal("glfw window creation failed.");
        glfwTerminate();
        return -1;
    }


    glfwMakeContextCurrent(window);
    setCallbacks(window);

    checkVersion();

    // GLOW takes care of initializing GLEW correctly.
    if (!glow::init())
    {
        glow::fatal("GLOW initialization failed.");
        return -1;
    }

    glow::debugmessageoutput::enable();
    

    Game * game = new Game(*window);
    eventHandler = new EventHandler(*window, *game);
    eventHandler->handeResizeEvent(initialWidth, initialHeight);

    game->start();

    delete eventHandler;
    delete game;

    glfwTerminate();

    return 0;
}
Ejemplo n.º 8
0
void AboutState::initCallbacks() {
    m_callbacks.push_back(0); // pushback 0 callbackID start from 1
    m_callbacks.push_back(s_exitFromAbout);
    // set the callbacks for menu items
    setCallbacks(m_callbacks);
}
Ejemplo n.º 9
0
/**
Start the Module and join a network, using the AF/ZDO interface. Reads RF Operating Region (US/EU) from GPIO.
@param moduleConfiguration the settings to use to start the module
@param applicationConfiguration the settings to use to start the Zigbee Application
@see struct moduleConfiguration in module_utilities.h for information about each field of the moduleConfiguration
@see struct applicationConfiguration in application_configuration.h for information about each field of the applicationConfiguration
@see module.c for more information about each of these steps.
*/
moduleResult_t startModule(const struct moduleConfiguration* mc, const struct applicationConfiguration* ac)
{
	printf("Module Startup\r\n");
    /* Initialize the Module */
    RETURN_RESULT_IF_FAIL(moduleReset(), METHOD_START_MODULE);
    /* Clear out any old network or state information (if requested) */
    RETURN_RESULT_IF_FAIL(setStartupOptions(mc->startupOptions), METHOD_START_MODULE);   

/* This section is for reading Operating region from GPIO pins - omit if using different method */
    /* First, configure GPIOs as inputs: */
    RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_DIRECTION , GPIO_DIRECTION_ALL_INPUTS), METHOD_START_MODULE);    
    RETURN_RESULT_IF_FAIL(sysGpio(GPIO_SET_INPUT_MODE , GPIO_INPUT_MODE_ALL_PULL_UPS), METHOD_START_MODULE); 
    /* Now, read GPIO inputs 0 & 1: */
    RETURN_RESULT_IF_FAIL(sysGpio(GPIO_READ, (GPIO_0 | GPIO_1)), METHOD_START_MODULE);
    /* The operating region (US vs. EU etc.) is based on DIP Switch settings, read from GPIO 0 & 1 */
    uint16_t moduleRegion = zmBuf[SYS_GPIO_READ_RESULT_FIELD];
    
/*** Done reading GPIO inputs. If application needs them as outputs then configure accordingly ***/
    
    /* Reset the Module to apply the changes we just set */
    RETURN_RESULT_IF_FAIL(moduleReset(), METHOD_START_MODULE);
    /* Read the productId - this indicates the model of module used. */
    uint8_t productId = zmBuf[SYS_RESET_IND_PRODUCTID_FIELD]; 
    /* If this is not valid (bad firmware) then stop */
    RETURN_RESULT_IF_EXPRESSION_TRUE((productId < MINIMUM_BUILD_ID), METHOD_START_MODULE,
                                     ZM_INVALID_MODULE_CONFIGURATION);       
    /* Configure the module's RF output */
    setModuleRfPower(productId, moduleRegion);
    /* Set any end device options */
    if (mc->deviceType == END_DEVICE)
	    RETURN_RESULT_IF_FAIL(setPollRate(mc->endDevicePollRate), METHOD_START_MODULE);
    /* Configure which RF Channels to use. If none set then this will default to 11. */
    RETURN_RESULT_IF_FAIL(setZigbeeDeviceType(mc->deviceType), METHOD_START_MODULE);     // Set Zigbee Device Type
    RETURN_RESULT_IF_FAIL(setChannelMask(mc->channelMask), METHOD_START_MODULE);
    RETURN_RESULT_IF_FAIL(setPanId(mc->panId), METHOD_START_MODULE);
    RETURN_RESULT_IF_FAIL(setCallbacks(CALLBACKS_ENABLED), METHOD_START_MODULE);
    
	                                                    // Note: ZCD_NV_SECURITY_MODE defaults to 01
	  if (mc->securityMode != SECURITY_MODE_OFF)        // Note: If a coordinator has ZCD_NV_SECURITY_MODE = 00, router must have ZCD_NV_SECURITY_MODE = 01 or else they won't communicate
	  {
	      RETURN_RESULT_IF_FAIL(setSecurityMode(mc->securityMode), METHOD_START_MODULE);
	      RETURN_RESULT_IF_FAIL(setSecurityKey(mc->securityKey), METHOD_START_MODULE);
	  }

	  if (ac == GENERIC_APPLICATION_CONFIGURATION)	  //TODO: use custom applicationFramework if this isn't null:
	  {
	    RETURN_RESULT_IF_FAIL(afRegisterGenericApplication(), METHOD_START_MODULE);    // Configure the Module for our application
	  } else {
	    printf("Custom Application Frameworks not supported\r\n");
	    return INVALID_PARAMETER;
	  }
	  RETURN_RESULT_IF_FAIL(zdoStartApplication(), METHOD_START_MODULE);		// Start your engines

	  /* Wait until this device has joined a network. Device State will change to DEV_ROUTER,
      DEV_END_DEVICE, or DEV_COORD to indicate that the device has correctly joined a network. */

	#ifdef ZDO_STATE_CHANGE_IND_HANDLED_BY_APPLICATION  //if you're handling this in your application instead...
	  return MODULE_SUCCESS;
	#else
	#define TEN_SECONDS 10000
	#define FIFTEEN_SECONDS 15000
	#define START_TIMEOUT FIFTEEN_SECONDS
	  RETURN_RESULT(waitForDeviceState(getDeviceStateForDeviceType(mc->deviceType), START_TIMEOUT), METHOD_START_MODULE);
	#endif

}
Ejemplo n.º 10
0
/**
Starts module using an operating region as a parameter. This does NOT read the GPIO pin to set the region.
@param mc the module configuration - what RF channel, which PAN ID, etc. These options are used in
this expressStartModule function as arguments to the various functions.
@param ac the Zigbee application configuration - which endpoint to use and other global settings. 
If not using GENERIC_APPLICATION_CONFIGURATION then you must #define the compilation option 
SUPPORT_CUSTOM_APPLICATION_CONFIGURATION. Normally this option is NOT defined to reduce code size.
@param moduleRegion - which region of the world to use to ensure FCC/ETSI compliance.
*/
moduleResult_t expressStartModule(const struct moduleConfiguration* mc, const struct applicationConfiguration* ac, const uint8_t moduleRegion)
{
    printf("Express Startup ");
    
    /* Initialize the Module */
    RETURN_RESULT_IF_FAIL(moduleReset(), METHOD_EXPRESS_START_MODULE);
    
    /* Clear out any old network or state information (if requested) */
    printf("Startup Options 0x%02X\r\n", mc->startupOptions);
    RETURN_RESULT_IF_FAIL(setStartupOptions(mc->startupOptions), METHOD_EXPRESS_START_MODULE);

    /* Reset the Module to apply the changes we just set */
    RETURN_RESULT_IF_FAIL(moduleReset(), METHOD_EXPRESS_START_MODULE);
    
    /* Read the productId - this indicates the model of module used. */
    uint8_t productId = zmBuf[SYS_RESET_IND_PRODUCTID_FIELD]; 
    
    /* If this is not valid (bad firmware) then stop */
    RETURN_RESULT_IF_EXPRESSION_TRUE((productId < MINIMUM_BUILD_ID), METHOD_EXPRESS_START_MODULE, ZM_INVALID_MODULE_CONFIGURATION); 
    
    /* Configure the module's RF output */ 
    setModuleRfPower(productId, moduleRegion);
    
    /* Set any end device options */
    if (mc->deviceType == END_DEVICE)
    {
	    RETURN_RESULT_IF_FAIL(setPollRate(mc->endDevicePollRate), METHOD_EXPRESS_START_MODULE);
    }
    /* Override for testing low power operation - referenced in Basic Comms ED example*/
#ifdef DISABLE_END_DEVICE_POLLING
    RETURN_RESULT_IF_FAIL(setPollRate(0), METHOD_EXPRESS_START_MODULE);
#endif
    
    /* Configure the Zigbee Device Type (Coordinator, Router, End Device */
    RETURN_RESULT_IF_FAIL(setZigbeeDeviceType(mc->deviceType), METHOD_EXPRESS_START_MODULE);

    /* Configure which RF Channels to use. If none set then this will default to a default set. */
    RETURN_RESULT_IF_FAIL(setChannelMask(mc->channelMask), METHOD_EXPRESS_START_MODULE);
    
    /* Set the PAN ID, if you want to restrict the module to only a particular PAN ID. */
    RETURN_RESULT_IF_FAIL(setPanId(mc->panId), METHOD_EXPRESS_START_MODULE);
    RETURN_RESULT_IF_FAIL(setCallbacks(CALLBACKS_ENABLED), METHOD_EXPRESS_START_MODULE);
    
    /* Set security mode and security key if required. Note: If a coordinator has 
    ZCD_NV_SECURITY_MODE = 00 then router must have ZCD_NV_SECURITY_MODE = 01 or else they won't communicate */
    if (mc->securityMode != SECURITY_MODE_OFF)        
    {
    	RETURN_RESULT_IF_FAIL(setSecurityMode(mc->securityMode), METHOD_EXPRESS_START_MODULE);
    	RETURN_RESULT_IF_FAIL(setSecurityKey(mc->securityKey), METHOD_EXPRESS_START_MODULE);
    }

#ifdef SUPPORT_CUSTOM_APPLICATION_CONFIGURATION    
    if (ac == GENERIC_APPLICATION_CONFIGURATION)
    {
    RETURN_RESULT_IF_FAIL(afRegisterGenericApplication(), METHOD_EXPRESS_START_MODULE);    // Configure the Module for our application
    } else {
    RETURN_RESULT_IF_FAIL(afRegisterApplication(ac), METHOD_EXPRESS_START_MODULE);
    }
#else    
    if (ac == GENERIC_APPLICATION_CONFIGURATION)
    {
    RETURN_RESULT_IF_FAIL(afRegisterGenericApplication(), METHOD_EXPRESS_START_MODULE);    // Configure the Module for our application
    } else {
        /* Note: to use a custom application configuration, you must #define SUPPORT_CUSTOM_APPLICATION_CONFIGURATION. */
    return INVALID_PARAMETER;
    }    
#endif
    
    /* Note: you can register more than one Zigbee endpoint; just call afRegisterApplication() here
    for the next endpoint */
    
    /* Start the module with the registered application configuration */
    RETURN_RESULT_IF_FAIL(zdoStartApplication(), METHOD_EXPRESS_START_MODULE);

	  /* Wait until this device has joined a network. Device State will change to DEV_ROUTER,
      DEV_END_DEVICE, or DEV_COORD to indicate that the device has correctly joined a network. */

	#ifdef ZDO_STATE_CHANGE_IND_HANDLED_BY_APPLICATION  //if you're handling this in your application instead...
	  return MODULE_SUCCESS;
	#else
	#define TEN_SECONDS 10000
	#define FIFTEEN_SECONDS 15000
	  RETURN_RESULT(waitForDeviceState(getDeviceStateForDeviceType(mc->deviceType), FIFTEEN_SECONDS), METHOD_EXPRESS_START_MODULE);
	#endif
}
int main( void )
{
    halInit();
    printf("\r\n****************************************************\r\n");
    printf("Basic Communications Example - COORDINATOR - using AFZDO\r\n");
    HAL_ENABLE_INTERRUPTS();
    setLed(0);
    /* Initialize the ZNP */
    printf("Initializing the ZNP  ");    
    znpInit(); 
    handleReturnValue();
    
    /* Set Startup Options (will restore the ZNP to default values on reset) */
    printf("Setting StartupOptions  ");
    setStartupOptions(STARTOPT_CLEAR_CONFIG + STARTOPT_CLEAR_STATE);
    handleReturnValue();
    
    /* Reset the ZNP */
    printf("Reset the ZNP  ");    
    znpReset();
    handleReturnValue();
    
    /* Set Zigbee Device Type to be COORDINATOR */
    printf("Setting Zigbee Device Type  "); 
    setZigbeeDeviceType(COORDINATOR);
    handleReturnValue();
    
    /* Enabling Callbacks (required to receive ZDO_IEEE_ADDR_RSP)  */
//#ifdef FIND_MAC_ADDRESS_OF_SENDER  //define this to print out sender's MAC address
    printf("Enabling Callbacks  "); 
    setCallbacks(CALLBACKS_ENABLED);
    handleReturnValue();    
//#endif
    
    /* Configure the ZNP for our application */
    printf("Registering Application  ");   
    afRegisterGenericApplication();
    handleReturnValue();
    
    /* Now, start the application. We will receive a START_REQUEST_SRSP, and then if it is successful, a START_CONFIRM. */
    printf("Starting the Application  "); 
    zdoStartApplication();
    handleReturnValue();
    
    /** Wait until we get on the network. 
    We will receive a ZDO_STATE_CHANGE_IND message whenever the state changes. */
    waitForDeviceState(DEV_ZB_COORD);

    printf("On Network!\r\n");
    setLed(1);
            
    /* On network, display info about this network */
#ifdef DISPLAY_NETWORK_INFORMATION     
    getNetworkConfigurationParameters();                
    getDeviceInformation();
#endif  

    /* Now the network is running - continually poll for any received messages from the ZNP */
#ifdef FIND_MAC_ADDRESS_OF_SENDER  //define this to print out sender's MAC address
    displayReceivedMessagesAndFindDevice();
#else
    displayReceivedMessages();
#endif    
    
}
int main( void )
{
    halInit(); //Sets up all hardware inc debug Tx/Rx (Used for WiFi <--> ZNP)
    printf("\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n");        
    printf("\r\nBasic Communications Example - COORDINATOR - using Simple API\r\n");
    HAL_ENABLE_INTERRUPTS();
    setLed(0);
    //Simple check to ensure that both security options weren't #defined.
#if defined(USE_SECURITY_MODE_PRECONFIGURED_KEYS) && defined(USE_SECURITY_MODE_COORD_DIST_KEYS)
    printf("ERROR\r\n");
    while (1);
#endif 
    
    /* Initialize the ZNP */
    printf("Initializing the ZNP\r\n");    
    znpInit(); 
    handleReturnValue();
    
    /* Set Startup Options (will restore the ZNP to default values on reset) */
    printf("Setting StartupOptions\r\n");
    setStartupOptions(STARTOPT_CLEAR_CONFIG + STARTOPT_CLEAR_STATE);
    handleReturnValue();
    
    /* Reset the ZNP */
    printf("Reset the ZNP\r\n");    
    znpReset();
    handleReturnValue();
    
    /* Set Zigbee Device Type to be COORDINATOR */
    printf("Setting Zigbee Device Type\r\n"); 
    setZigbeeDeviceType(COORDINATOR);
    handleReturnValue();
    
    /* Enabling Callbacks (required to receive ZDO_IEEE_ADDR_RSP)  */
    printf("Enabling Callbacks\r\n"); 
    setCallbacks(CALLBACKS_ENABLED);
    handleReturnValue();    

    /* Configure security mode, if it is being used */
#ifdef USE_SECURITY_MODE_PRECONFIGURED_KEYS
    printf("SECURITY ON WITH PRECONFIGURED KEYS\r\n");
    
    /* Turn security ON with pre-configured keys */
    setSecurityMode(SECURITY_MODE_PRECONFIGURED_KEYS);
    handleReturnValue();
    
    /* All devices on the network must be loaded with the same key */    
    setSecurityKey(key);
    handleReturnValue();    
#endif
    
#ifdef USE_SECURITY_MODE_COORD_DIST_KEYS
    printf("SECURITY ON WITH COORDINATOR DISTRIBUTING KEYS\r\n");
    
    /* Turn security ON with the coordinator distributing keys. */
    setSecurityMode(SECURITY_MODE_COORD_DIST_KEYS);
    handleReturnValue();
    
    /* This is the key that will be distributed to other devices when they attempt to join */
    setSecurityKey(key);
    handleReturnValue();
#endif   
    
#if !defined(USE_SECURITY_MODE_PRECONFIGURED_KEYS) && !defined(USE_SECURITY_MODE_COORD_DIST_KEYS)
    printf("SECURITY OFF\r\n");
#endif 
    
    /* Configure the ZNP for our application: */
    printf("Registering Application\r\n");
    sapiRegisterGenericApplication();    
    handleReturnValue();
    
    /* Now, start the application. We will receive a START_REQUEST_SRSP, and then if it is successful, a START_CONFIRM. */
    printf("Starting the Application\r\n");      
    sapiStartApplication();
    handleReturnValue();
    
    printf("On Network!\r\n");
    setLed(1);
    
    /* On network, display info about this network */
#ifdef DISPLAY_NETWORK_INFORMATION      
    getNetworkConfigurationParameters();                
    getDeviceInformation();
#endif    
    
    /* Now the network is running - continually poll for any received messages from the ZNP */
    //displayReceivedMessages();
    
    while(1)
    {
		/*
      int light = getLightSense();
      if(light > 100)
      {
        sendData(0xC72, 0xF, 0x1, 1);
      }
      else
      {
        sendData(0xC72, 0xF, 0x2, 1);
      }
		 */
		int cmd = readUART(); //Read UART
		//Depending on command, send appropriate message to relevant end point
		switch (cmd) {
			case CLOSE1:
				//sendData(dest, cluster, data, dataLength);
				sendData(0xC72, 0xF, 0x1, 1);
				break;
			case OPEN1:
				sendData(0xC72, 0xF, 0x2, 1);
				break;
			case FILM1:
				sendData(0xC72, 0xF, 0x3, 1);
				break;
			case DAY1:
				sendData(0xC72, 0xF, 0x4, 1);
				break;
			case NIGHT1:
				sendData(0xC72, 0xF, 0x5, 1);
				break;
			case CLOSE2:
				sendData(0xC72, 0xF, 0x6, 1);
				break;
			case OPEN2:
				sendData(0xC72, 0xF, 0x7, 1);
				break;
			case FILM2:
				sendData(0xC72, 0xF, 0x8, 1);
				break;
			case DAY2:
				sendData(0xC72, 0xF, 0x9, 1);
				break;
			case NIGHT2:
				sendData(0xC72, 0xF, 0xA, 1);
				break;
			default:
				break;
		}
    }
}
Ejemplo n.º 13
0
TetraTrace::TetraTrace(int argc, char *argv[])
{
    Covise::set_module_description("perform particle-trace on tetrahedra-grids");

    Covise::add_port(INPUT_PORT, "gridIn", "UnstructuredGrid", "tetrahedra-grid");
    Covise::add_port(INPUT_PORT, "velIn", "Vec3", "velocity input");
    Covise::add_port(INPUT_PORT, "volIn", "Float", "volumes of tetrahedras");
    Covise::add_port(INPUT_PORT, "neighborIn", "Float", "neighbors of tetrahedras");

    Covise::add_port(OUTPUT_PORT, "traceOut", "Points|Polygons|Lines|TriangleStrips", "computed trace");
    Covise::add_port(OUTPUT_PORT, "dataOut", "Float|Vec3", "data to be mapped on the trace");

    Covise::add_port(PARIN, "startpoint1", "FloatVector", "...");
    Covise::set_port_default("startpoint1", "1.0 1.0 1.0");

    Covise::add_port(PARIN, "startpoint2", "FloatVector", "...");
    Covise::set_port_default("startpoint2", "1.0 2.0 1.0");

    Covise::add_port(PARIN, "normal", "FloatVector", "...");
    Covise::set_port_default("normal", "0.0 0.0 1.0");

    Covise::add_port(PARIN, "direction", "FloatVector", "...");
    Covise::set_port_default("direction", "1.0 0.0 0.0");

    Covise::add_port(PARIN, "numStart", "IntScalar", "number of traces to start");
    Covise::set_port_default("numStart", "10");

    Covise::add_port(PARIN, "startStep", "IntScalar", "initial timestep (transient only)");
    Covise::set_port_default("startStep", "1");

    Covise::add_port(PARIN, "whatOut", "Choice", "what data should we compute");
    Covise::set_port_default("whatOut", "1 number velocity magnitude");

    Covise::add_port(PARIN, "startStyle", "Choice", "how to compute starting-points");
    Covise::set_port_default("startStyle", "1 line plane sphere box");

    Covise::add_port(PARIN, "traceStyle", "Choice", "how to output the trace");
    Covise::set_port_default("traceStyle", "1 points lines easymesh mesh fader");

    Covise::add_port(PARIN, "numSteps", "IntScalar", "number of steps to compute");
    Covise::set_port_default("numSteps", "100");

    Covise::add_port(PARIN, "stepDuration", "FloatScalar", "duration of each step");
    Covise::set_port_default("stepDuration", "0.01");

    Covise::add_port(PARIN, "numNodes", "IntScalar", "number of nodes/processors to use");
    Covise::set_port_default("numNodes", "1");

    Covise::add_port(PARIN, "multiProcMode", "Choice", "which multi-processing mode to use");
    Covise::set_port_default("multiProcMode", "1 none SMP MMP");

    Covise::add_port(PARIN, "searchMode", "Choice", "which searching-algorithm to use for startcells");
    Covise::set_port_default("searchMode", "1 quick save");

    Covise::init(argc, argv);

    const char *in_names[] = { "gridIn", "velIn", "volIn", "neighborIn", NULL };
    const char *out_names[] = { "traceOut", "dataOut", NULL };

    setPortNames(in_names, out_names);
    setComputeTimesteps(0);

    setCallbacks();

    return;
};
int main( void )
{
    halInit();
    printf("\r\n****************************************************\r\n");
    printf("Secure Communications Example - COORDINATOR - using AFZDO\r\n");
    HAL_ENABLE_INTERRUPTS();
    setLed(0);
    
    //Simple idiot check to ensure that we didn't accidentally define both security options.
#if defined(USE_SECURITY_MODE_PRECONFIGURED_KEYS) && defined(USE_SECURITY_MODE_COORD_DIST_KEYS)
    printf("ERROR - only select one security option!\r\n");
    while (1);
#endif     
    
    /* Initialize the ZNP */
    printf("Initializing the ZNP\r\n");    
    znpInit(); 
    handleReturnValue();
    
    /* Set Startup Options (will restore the ZNP to default values on reset) */
    printf("Setting StartupOptions\r\n");
    setStartupOptions(STARTOPT_CLEAR_CONFIG + STARTOPT_CLEAR_STATE);
    handleReturnValue();
    
    /* Set Zigbee Device Type to be COORDINATOR */
    printf("Setting Zigbee Device Type\r\n"); 
    setZigbeeDeviceType(COORDINATOR);
    handleReturnValue();
    
    /* Enabling Callbacks (required to receive ZDO_IEEE_ADDR_RSP)  */
    printf("Enabling Callbacks\r\n"); 
    setCallbacks(CALLBACKS_ENABLED);
    handleReturnValue();    
    
    /* Reset the ZNP */
    printf("Reset the ZNP\r\n");    
    znpReset();
    handleReturnValue();
    
    /* Configure security mode, if it is being used */
#ifdef USE_SECURITY_MODE_PRECONFIGURED_KEYS
    printf("SECURITY ON WITH PRECONFIGURED KEYS\r\n");
    
    /* Turn security ON with pre-configured keys */
    setSecurityMode(SECURITY_MODE_PRECONFIGURED_KEYS);
    handleReturnValue();
    
    /* All devices on the network must be loaded with the same key */    
    setSecurityKey(key);
    handleReturnValue();    
#endif
    
#ifdef USE_SECURITY_MODE_COORD_DIST_KEYS
    printf("SECURITY ON WITH COORDINATOR DISTRIBUTING KEYS\r\n");
    
    /* Turn security ON with the coordinator distributing keys. */
    setSecurityMode(SECURITY_MODE_COORD_DIST_KEYS);
    handleReturnValue();
    
    /* This is the key that will be distributed to other devices when they attempt to join */
    setSecurityKey(key);
    handleReturnValue();
#endif   
    
    /** Note: if no security option is selected then this will behave like a normal coordinator
    and will accept join requests from any device. */
#if !defined(USE_SECURITY_MODE_PRECONFIGURED_KEYS) && !defined(USE_SECURITY_MODE_COORD_DIST_KEYS)
    printf("WARNING - NO SECURITY OPTION SELECTED; SECURITY OFF\r\n");
#endif 
    
    /* Configure the ZNP for our application */
    printf("Registering Application\r\n");     
    afRegisterGenericApplication();    
    handleReturnValue();
    
    /* Now, start the application. We will receive a START_REQUEST_SRSP, and then if it is successful, a START_CONFIRM. */
    printf("Starting the Application\r\n"); 
    zdoStartApplication();
    handleReturnValue();
    
    /** Wait until we get on the network. 
    We will receive a ZDO_STATE_CHANGE_IND message whenever the state changes. */
    waitForDeviceState(DEV_ZB_COORD);

    printf("On Network!\r\n");
    setLed(1);
    
    /* On network, display info about this network */
#ifdef DISPLAY_NETWORK_INFORMATION     
    getNetworkConfigurationParameters();                
    getDeviceInformation();
#endif  

    /* Now the network is running - continually poll for any received messages from the ZNP */
    if (SRDY_IS_HIGH())
        pollAndDisplay();
    
    displayReceivedMessages();
    
}
Ejemplo n.º 15
0
void VlcQmlVideoObject::connectToMediaPlayer(VlcMediaPlayer *mediaObject)
{
    setCallbacks(mediaObject);
}