Esempio n. 1
0
int main()
{
    Server              *s;
	ModuleList			*ml;
	Serial              *se;
    MyModule            *mm;
	int                 mColor;
    
	s	= new Server();
	ml	= new ModuleList(s, "/ModuleList");
    se  = new Serial(s, "/Serial", "/dev/cu.usbserial-A600afyl");
	mm  = new MyModule(s, "/MM");
        
    se->connectTo(mm, "/Stream");
    ml->requestML();
	
    while (1) {
        printf("Enter Module Color\n");
        scanf("%d", &mColor);
        if (!mColor) break;
		if (mColor == 99) ml->requestML();
        if (mm->tID) 
            ml->createModule(mm->tID, mColor);
    }	
	
	delete se;
	delete mm;
	delete ml;
	delete s;
	
	return 0;
}
Esempio n. 2
0
int main()
{
    Server              *s;
    Coordinator			*co;
	ModuleManager       *mm;
    XBeeController      *xbc;
	Serial              *se;
    MyModule            *mym;
	int                 mIndex;
    char                dn[128];
    dn[0] = '/';
    
    printf("Please Enter Your Device Name!\n");
    scanf("%s", &dn[1]);

	s = new Server();
    xbc = new XBeeController(s, "/XBC", "/dev/cu.usbserial-A50178PJ");
	mm	= new ModuleManager(s, dn);
	co	= new Coordinator(s, "/Coordinator");
    se  = new Serial(s, "/Serial", "/dev/cu.usbmodemfd131");
	mym = new MyModule(s, "/MM");

	mm->sendModuleList();
    xbc->co = co;
    co->xbc = xbc;
    
    se->connectTo(mym, "/Stream");
    
    while (1) {
        printf("Enter Module Index\n");
        scanf("%d", &mIndex);
        if (!mIndex) break;
        
        if (mIndex == -1) {
            co->ml->requestML();
            co->ml->displayModules();
        }
        
        if (mym->tID) 
            co->ml->createModule(mym->tID, mIndex);

    }	

	return 0;
}