Пример #1
0
BaseObject::BaseObject()
    : Base()
    , f_listening(initData( &f_listening, false, "listening", "if true, handle the events, otherwise ignore the events"))
    , l_context(initLink("context","Graph Node containing this object (or BaseContext::getDefault() if no graph is used"))
    , l_slaves(initLink("slaves","Sub-objects used internally by this object"))
    , l_master(initLink("master","NULL for regular objects, or master object for which this object is one sub-objects"))
{
    l_context.setValidator(&sofa::core::objectmodel::BaseObject::changeContextLink);
    l_context.set(BaseContext::getDefault());
    l_slaves.setValidator(&sofa::core::objectmodel::BaseObject::changeSlavesLink);
    f_listening.setAutoLink(false);
}
Пример #2
0
int main(void)
{
    initSignal();
    
    // Initialise les mutex
    pthread_mutex_init(&mutex_received, NULL);
    pthread_mutex_init(&mutex_give, NULL);
    
    // Cree un thread qui ecoutera ce que la station 1 et 3 lui dira
    if(pthread_create(&receive_1, NULL, receiveFrom1, NULL) != 0 ||
       pthread_create(&receive_3, NULL, receiveFrom3, NULL) != 0) {
        printf("Erreur thread\n");
        return 1;
    }
    
    // Attend que le serveur d'~coute soit lanc~
    printf("Appuyez sur une touche lorsque station 1 et station 3 seront lance ...\n");
    while(kbhit() == 0);
    
    initSend(&station_1, ADDR_STATION_1, PORT_LISTEN_1_2);
    initSend(&station_3, ADDR_STATION_3, PORT_LISTEN_3_2);
    
    initLink();
        
    // Boucle principale
    while(1) {
        reinitialise();
        processPiece();
    }
    
    return 0;
}
Пример #3
0
int
main (void)
{
  link_t *h;
  int i;
  char *p;

  h = initLink ();

  for (i = 0; i < 1024 * 2; i++)
    {

      p = malloc (128);
      enqueueLink (h, p);
      printf ("%p enqueued\n", p);
    }

  printLink (h);

  while ((p = dequeueLink (h)))
    {
      printf ("%p dequeued\n", p);
      free (p);
    }

  finLink (h);

  return 0;
}
Пример #4
0
BaseData::BaseData(const char* h, DataFlags dataflags)
    : help(h), ownerClass(""), group(""), widget("")
    , m_counters(), m_isSets(), m_dataFlags(dataflags)
    , m_owner(NULL), m_name("")
    , parentBaseData(initLink("parent", "Linked Data, from which values are automatically copied"))
{
    addLink(&inputs);
    addLink(&outputs);
    m_counters.assign(0);
    m_isSets.assign(false);
    //setAutoLink(true);
    //if (owner) owner->addData(this);
}
Пример #5
0
BaseData::BaseData( const char* h, bool isDisplayed, bool isReadOnly)
    : help(h), ownerClass(""), group(""), widget("")
    , m_counters(), m_isSets(), m_dataFlags(FLAG_DEFAULT), m_owner(NULL), m_name("")
    , parentBaseData(initLink("parent", "Linked Data, from which values are automatically copied"))
{
    addLink(&inputs);
    addLink(&outputs);
    m_counters.assign(0);
    m_isSets.assign(false);
    setFlag(FLAG_DISPLAYED,isDisplayed);
    setFlag(FLAG_READONLY,isReadOnly);
    //setAutoLink(true);
    //if (owner) owner->addData(this);
}
Пример #6
0
Файл: main.c Проект: 3Nigma/AVI
int main(int argc, char *argv[]) {
  GtkWidget *window = NULL;

  gtk_init(&argc, &argv);

  /* initialize serial link */
  if(initLink(ttyUSB0, 19200) == FALSE) {
    fprintf(stderr, "Error on opening serial port!\n");
    return -1;
  }

  /* initialize main window */
  window = avi_new_appwindow();
  gtk_widget_show_all(window);

  gtk_main();

  closeLink(ttyUSB0);
  return 0;
}
Пример #7
0
BaseData::BaseData( const BaseInitData& init)
    : help(init.helpMsg), ownerClass(init.ownerClass), group(init.group), widget(init.widget)
    , m_counters(), m_isSets(), m_dataFlags(init.dataFlags)
    , m_owner(init.owner), m_name(init.name)
    , parentBaseData(initLink("parent", "Linked Data, from which values are automatically copied"))
{
    addLink(&inputs);
    addLink(&outputs);
    m_counters.assign(0);
    m_isSets.assign(false);
    if (init.data && init.data != this)
    {
        std::cerr << "CODE ERROR: initData POINTER MISMATCH: field name \"" << init.name << "\"";
        if (init.owner)
            std::cerr << " created by class " << init.owner->getClassName();
        std::cerr << "!...aborting" << std::endl;
        sofa::helper::BackTrace::dump();
        exit( 1 );
    }
    //setAutoLink(true);
    if (m_owner) m_owner->addData(this, m_name);
}
Пример #8
0
/// Constructor
DDGNode::DDGNode()
    : inputs(initLink("inputs", "Links to inputs Data"))
    , outputs(initLink("outputs", "Links to outputs Data"))
{
}
SofaHAPIForceFeedbackEffect::SofaHAPIForceFeedbackEffect()
    : forceFeedback(initLink("forceFeedback", "the component used to compute the applied forces"))
{
}
Пример #10
0
/*
 * This procedure will connect the given vnf to the given switch via the given/
 * requested vnf_port
 * gchar* vnf_id - the id of the vnf
 * gchar* vnf_port - one of the vnf's available ports
 * gchar* switch_id - the id of the switch
 * return gchar* - the port number of the switch
 */
gchar* connectVNF(gchar* vnf_id, gchar* vnf_port, gchar* switch_id)
{

	//getting the vnf
	vnf_data *found_vnf = getVNF(vnf_id);

	//for the link structure
	vnf_link *l = NULL;

	//this is the return value. The switch port will be determined by an
	//ovs-vsctl command
	gchar* sw_port = NULL;

	//checking whether a link is existed
	if(g_hash_table_lookup_extended(found_vnf->links, vnf_port, NULL, NULL) ==
		FALSE)
	{
		//create new link and connecting
		l = initLink();
		gchar* uny_pair = createVirtualEthernetPairs();
		gchar* vnf_dev = subStringDeviceIdFromVirtualEthernetPair(uny_pair,0);
		gchar* sw_dev = subStringDeviceIdFromVirtualEthernetPair(uny_pair,1);

		sw_port = connectVirtualEthernetDeviceToSwitch(sw_dev,switch_id);

		//setting link params
		l->vnf_dev = vnf_dev;
		l->sw_dev = sw_dev;
		l->sw_id = switch_id;
		l->sw_port = sw_port;

		//bringing up virtual ethernet pairs
		if(bringVirtualEthernetPairs(vnf_dev, sw_dev, LINK_UP))
		{
			//bringing up was successful
			l->connected = TRUE;
			custom_log(INFO, g_strdup_printf("%s (%s) is connected to switch %s"
											 " (%s)",
											 vnf_id,
											 vnf_dev,
											 switch_id,
											 sw_dev));
		}
		else
		{
			//something went wrong during bringing up interfaces
			l->connected = FALSE;
		}

		//adding link to vnf's datastructure
		addLinkToVNF(vnf_id, vnf_port, l);

	}
	else
	{
		//the given link already existed

		//getting the link structure
		l = g_hash_table_lookup(found_vnf->links, vnf_port);

		//checking whether the switch_id assigned to the link is equal to
		//the given switch_id
		if(g_strcmp0(l->sw_id, switch_id) == 0)
		{
			//RECONNECT
			if(bringVirtualEthernetPairs(l->vnf_dev, l->sw_dev, LINK_UP))
			{
				//bringing up was successful
				l->connected = TRUE;
				custom_log(INFO, g_strdup_printf("%s (%s) is reconnected to "
												 "switch %s (%s)",
												 vnf_id,
												 l->vnf_dev,
												 switch_id,
												 l->sw_dev));
			}
			else
			{
				//something went wrong during bringing up interfaces
				l->connected = FALSE;
			}

			sw_port = l->sw_port;

		}
		else
		{
			//TODO: if a connection entry is already existed for the given
			//		vnf_port, but the assigned switch_id is different than
			//		the given switch_id
			sw_port = NULL;
			custom_log(ERROR, "WRONG arguments have been set for connect func");
		}
	}

	return sw_port;

}