/* 
 * Thomas Pantzer: new_demo.C, v0.4.7  8.6.99 16:32 
 * 
 * 
 * Copyright 1999 by Thomas Pantzer
 * 
 * Permission to use, copy, modify, and distribute this software for noncommercial 
 * use and without fee is hereby granted, provided that the above copyright notice 
 * appear in all copies and that both that copyright notice and this permission 
 * notice appear in supporting documentation, and that the name of the Author not be 
 * used in advertising or publicity pertaining to distribution of the software 
 * without specific, written prior permission. The Author makes no representations about
 * the suitability of this software for any purpose.  It is provided "as is" 
 * without expressed or implied warranty. 
 * 
 * 
 * pantec@isys2.informatik.uni-leipzig.de   (Thomas Pantzer) 
 * 
 */



#include "t_runtime_obj.h"

#include "graphix.h"
#include "stuff.h"
#include "user.h"

#define _newdemo_DEMO_G
#include "newdemo_demo.h"


#define newdemo_nBoxes		3
#define newdemo_nSliders	2

char newdemo_boxes[newdemo_nBoxes][32] = {"erster\0","zweite\0","drittes\0"};
char newdemo_sliders[newdemo_nSliders][16] = {"uno\0","dos\0"};


void t_newdemo_demo::Init(RobotContext *robot)
{
	char *cb_pointers[newdemo_nBoxes];
	char *sl_pointers[newdemo_nSliders];

	for (int i=0; i<newdemo_nBoxes; i++)
          cb_pointers[i]  = &newdemo_boxes[i][0];

	for (int i=0; i<newdemo_nSliders; i++)
          sl_pointers[i]  = &newdemo_sliders[i][0];

	int pro = 0; 
	pro |= _p_control;	//  does something to control the robot
	pro |= _p_calc;		//  needs calculations
	pro |= _p_show;		//  has a method to show something in graphic window
	pro |= _p_extras;	//  uses user settable parameters

	t_runtime_object::Init("newdemo",robot,pro,
		newdemo_nSliders,newdemo_nBoxes,0,
		sl_pointers,cb_pointers,NULL);
}


void t_newdemo_demo::button_cb(FL_OBJECT *ob,long data)
{
	switch(data)
	  {
	   // add your cases here

	   // rest ist handled by parent object
	   case 0:
	   case 1:
	   case 2:
	   default:
	     t_runtime_object::button_cb(ob,data);
	     break; 	
	  }
}

void t_newdemo_demo::slider_cb(FL_OBJECT *ob,long data)
{
	switch(data)
	  {
	   default:
	     break; 	
	  }
}

void t_newdemo_demo::Load(char *to_parse)
{
	// put your loading stuff here and 
	if (something_matched)
	   return;

	// if we come here that wasn't private stuff 
	// try the generic parser from parent object      
	t_runtime_object::Load(to_parse);
}

void t_newdemo_demo::Save(int fd)
{
	t_runtime_object::Save(fd);	// call parent for generic savings

	fprintf(stderr,"t_newdemo_demo::Save()\n");
	// then save our private stuff
}

void t_newdemo_demo::Reset(void)
{
	// do some Resetting
	t_runtime_object::Reset();
}


void t_newdemo_demo::Show(void)
{
}


char t_newdemo_demo::calculate_module(char allow_learn, char any_new)
{
	if (t_runtime_object::calculate_module(allow_learn,any_new) == false)
	   return false;
	
//	do some calculation in our spare time after this comment line

	return true;
}


char t_newdemo_demo::control_module(void)
{
	if (t_runtime_object::control_module() == false)
	   return false;

//	place your control instructions after this comment line

	return true;
}



char t_newdemo_demo::start_module(void) 
{
	if (t_runtime_object::start_module() == false)
	   return false;

//	what to do when starting this module

	return true;
}


char t_newdemo_demo::stop_module(void)
{
	if (t_runtime_object::stop_module() == false)
	   return false;
	
//	what to do when stopping

	return true;
}

