예제 #1
0
/**
** @brief Function to be called from post_SlaveBootup
**
** @param d
** @param nodeId
*/
UNS8 check_and_start_node(CO_Data* d, UNS8 nodeId)
{   
    if(d->dcf_status != DCF_STATUS_INIT)
        return 0;
    if((init_consise_dcf(d, nodeId) == 0) || (read_consise_dcf_next_entry(d, nodeId) == 0)){
        start_node(d, nodeId);
        return 1;
    }
    d->dcf_status = DCF_STATUS_READ_CHECK;
    return 2;
}
예제 #2
0
파일: main.cpp 프로젝트: pdziepak/Shoggoth
/*
 * shog_node filesystem_name filesystem_path
 */
int main(int argc, char *argv[]) {
	if (argc < 3)
		return 1;

	memset(filesystem_name, 0, 256);
	strncpy(filesystem_name, argv[1], 256);
	filesystem_path = argv[2];
	
	srand(time(NULL));
	return start_node();
}
예제 #3
0
int allin1(XMLEvent event, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
{
	switch(event) {
		case XML_EVENT_START_DOC: printf("Document start\n\n"); return true;
		case XML_EVENT_START_NODE: return start_node(node, sd);
		case XML_EVENT_END_NODE: return end_node(node, sd);
		case XML_EVENT_TEXT: return new_text(text, sd);
		case XML_EVENT_ERROR: printf("%s:%d: ERROR %d\n", sd->name, sd->line_num, n); return true;
		case XML_EVENT_END_DOC: printf("\nDocument end\n"); return true;
		default: return true;
	}
}
예제 #4
0
int zmain(int argc, char **argv){
    /* argv[0] is node name
     * expecting in format : "name-%d",
     * format for single node without decimal id: "name" */
    WRITE_FMT_LOG(LOG_DEBUG, "Source node started argv[0]=%s\n", argv[0] );
    if ( argc < 2 ){
	WRITE_LOG(LOG_ERR, "argv[1] is expected, items count need to be passed.\n" );
	return -1;
    }
    set_items_count_to_sortjob( atoi(argv[1]) );

    int ownnodeid= -1;
    int extracted_name_len=0;
    int res =0;

    /*get node type names via environnment*/
    char *source_node_type_text = getenv(ENV_SOURCE_NODE_NAME);
    char *dest_node_type_text = getenv(ENV_DEST_NODE_NAME);
    char *man_node_type_text = getenv(ENV_MAN_NODE_NAME);
    assert(source_node_type_text);
    assert(dest_node_type_text);
    assert(man_node_type_text);

    ownnodeid = ExtractNodeNameId( argv[0], &extracted_name_len );
    /*nodename should be the same we got via environment and extracted from argv[0]*/
    assert( !strncmp(source_node_type_text, argv[0], extracted_name_len ) );
    if ( ownnodeid == -1 ) ownnodeid=1; /*node id not specified for single node by default assign nodeid=1*/

    /*setup channels conf, now used static data but should be replaced by data from zrt*/
    struct ChannelsConfigInterface chan_if;
    SetupChannelsConfigInterface( &chan_if, ownnodeid, ESourceNode );

    /***********************************************************************
     Add channels configuration into config object */
    res = AddAllChannelsRelatedToNodeTypeFromDir( &chan_if, IN_DIR, EChannelModeRead, EManagerNode, man_node_type_text );
    assert( res == 0 );
    res = AddAllChannelsRelatedToNodeTypeFromDir( &chan_if, IN_DIR, EChannelModeRead, EDestinationNode, dest_node_type_text );
    assert( res == 0 );
    res = AddAllChannelsRelatedToNodeTypeFromDir( &chan_if, OUT_DIR, EChannelModeWrite, EManagerNode, man_node_type_text );
    assert( res == 0 );
    res = AddAllChannelsRelatedToNodeTypeFromDir( &chan_if, OUT_DIR, EChannelModeWrite, EDestinationNode, dest_node_type_text );
    assert( res == 0 );
    /*add input channel into config*/
    res = chan_if.AddChannel( &chan_if, EInputOutputNode, 1, STDIN, EChannelModeRead ) != NULL? 0: -1;
    assert( res == 0 );
    /*--------------*/

    res = start_node(&chan_if, ownnodeid);

    CloseChannels(&chan_if);
    return res;
}
예제 #5
0
__inline void start_and_seek_node(CO_Data* d, UNS8 nodeId){
   UNS8 node;
   start_node(d,nodeId);
   /* Look for other nodes waiting to be started */
   for(node = 0 ; node<NMT_MAX_NODE_ID ; node++){
       if(d->NMTable[node] != Initialisation)
           continue;
       if(check_and_start_node(d, node) == 2)
           return;
   }
   /* No more node to start. Let's start our own node */
   setState(d, Operational);
}