int main3( int /*argc*/, char** /*argv*/) { int exitStatus = EXIT_SUCCESS; LOW_link::linkPtrVec_t oneWireLinks; try { // // Automatically log any exception when it is created // //LOW_exception::setLogOnCreation( true); // if debugging is enabled then enable according log level #ifdef DEBUG_LOCKING //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::objSync_getLock_dl); //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::objSync_lockFailed_dl); #endif // // Uncomment to activate various debugging levels // //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::portSerial_dl); //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::devDS1820_dl); //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::linkLock_dl); //LOW_helper_msglog::setDebugLevelEnabled( LOW_helper_msglog::linkDS2490_dl); // // This is our whole network // LOW_helper_msglog::printMessage( "Creating network class.\n"); LOW_network oneWireNet; std::string hostName = LOW_platformMisc::getHostname(); // predefined setup for Harald's machine if ( hostName == "raspberrypi" ) { // stuff for the active adapter // LOW_linkDS2480B *activeLink = 0; // try { // hlp_printDashline(); // LOW_helper_msglog::printMessage( "Harald's predefined setup: Adding active adapter to network.\n"); // LOW_portSerialFactory::portSpecifier_t ttyS0 = LOW_portSerialFactory::portSpecifier_t( "/dev/ttyAMA0"); // activeLink = new LOW_linkDS2480B( ttyS0, LOW_linkDS2480B::RXPOL_INV, true, true); // oneWireNet.addLink( activeLink); // oneWireLinks.push_back( activeLink); // } // catch( LOW_exception ex) { // ex.logException(); // if ( activeLink ) delete activeLink; // } // // stuff for the passive adapter LOW_linkPassiveSerial *passiveLink = 0; try { hlp_printDashline(); LOW_helper_msglog::printMessage( "Harald's predefined setup: Adding passive adapter to network.\n"); LOW_portSerialFactory::portSpecifier_t ttyS1 = LOW_portSerialFactory::portSpecifier_t( "/dev/ttyAMA0"); passiveLink = new LOW_linkPassiveSerial( ttyS1); oneWireNet.addLink( passiveLink); //LOW_devDS1820::devDS1820PtrVec_t allTDevs = oneWireNet.getDevices<LOW_devDS1820>(); //getInfoDS1820( hlp_selectDevices( allTDevs)); //tempMenu( oneWireNet); oneWireLinks.push_back( passiveLink); } catch( LOW_exception ex) { ex.logException(); if ( passiveLink ) delete passiveLink; } // stuff for the USB adapter // try { // hlp_printDashline(); // LOW_helper_msglog::printMessage( "Harald's predefined setup: Adding all USB adapters to network.\n"); // // LOW_portUsb_Factory::usbDevSpecVec_t specifierList = LOW_portUsb_Factory::getPortSpecifiers( LOW_linkDS2490::usbVendorID, LOW_linkDS2490::usbProductID); // for( unsigned int a=0; a<specifierList.size(); a++) { // LOW_linkDS2490 *usbLink = 0; // try { // usbLink = new LOW_linkDS2490( specifierList[a], true, true); // oneWireNet.addLink( usbLink); // oneWireLinks.push_back( usbLink); // } // catch( LOW_exception ex) { // ex.logException(); // if ( usbLink ) delete usbLink; // } // } // } // catch( LOW_exception ex) { // ex.logException(); // } } bool keepLooping = true; while ( keepLooping) { hlp_printDashline(); printf( "OneWire++ Library Testing Main Menu\n"); printf( "\n"); printf( " <l> Links\n"); printf( "\n"); printf( " <n> Network\n"); printf( "\n"); printf( " <t> Temperature devices\n"); printf( " <1> PIO DS2413 devices\n"); printf( " <5> PIO DS2505 devices\n"); printf( " <6> PIO DS2506 devices\n"); printf( " <9> Digital potentiometer DS2890 devices\n"); printf( "\n"); printf( " <s> Switch components\n"); printf( " <j> Jalousie components\n"); printf( "\n"); printf( " <m> Message logging and debugging\n"); printf( " <o> Locks test\n"); printf( " <h> Thread test\n"); printf( "\n"); printf( " <q> Quit\n"); int key = hlp_getMenuKey( "lnt1569sjmohq"); switch( key ) { case 'l': linkMenu( oneWireLinks, oneWireNet); break; case 'n': netMenu( oneWireNet); break; case 't': tempMenu( oneWireNet); break; case '1': ds2413Menu( oneWireNet); break; case '5': ds2405Menu( oneWireNet); break; case '6': ds2406Menu( oneWireNet); break; case '9': ds2890Menu( oneWireNet); break; case 's': switchMenu( oneWireNet); break; case 'j': jalousieMenu( oneWireNet); break; case 'm': msgLoggingMenu(); break; case 'o': lockMenu( oneWireNet); break; case 'h': threadMenu( oneWireNet); break; case 'q': keepLooping=false; break; } } } catch( LOW_exception ex) { ex.logException(); exitStatus = EXIT_FAILURE; } for( unsigned int a=0; a<oneWireLinks.size(); a++ ) delete oneWireLinks[a]; return exitStatus; }
SetupWindow::SetupWindow(void) : BWindow(BRect(108.0, 88.0, 500.0, 320.0), S_SETUP_TITLE, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { AddShortcut('/', B_SHIFT_KEY, new BMessage(M_PREFS_SHOW)); bgView = new BView(Bounds(), "background", B_FOLLOW_ALL, B_WILL_DRAW); AddChild(bgView); bgView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BRect rect = Bounds(); LogoView* logo = new LogoView(rect); rect.top = logo->PreferredHeight(); rect.bottom = Bounds().bottom; rect.left = kItemSpacing; BMenu* netMenu(new NetworkMenu(S_SETUP_CHOOSENET, M_SETUP_CHOOSE_NETWORK, BMessenger(this))); netMenu->SetLabelFromMarked(true); netList = new BMenuField(rect, "Network List", S_SETUP_CHOOSELABEL, netMenu); netList->ResizeToPreferred(); netList->SetDivider(be_plain_font->StringWidth(S_SETUP_CHOOSELABEL) + 5); rect = netList->Frame(); rect.OffsetBy(0, rect.Height() + kItemSpacing); connectButton = new BButton(rect, "connect", S_SETUP_CONNECT_BUTTON, new BMessage(M_CONNECT_NETWORK)); connectButton->ResizeToPreferred(); rect = connectButton->Frame(); rect.OffsetBy(rect.Width() + kItemSpacing, 0); netPrefsButton = new BButton(rect, "netprefs", S_SETUP_NETPREFS B_UTF8_ELLIPSIS, new BMessage(M_NETWORK_SHOW)); netPrefsButton->ResizeToPreferred(); netPrefsButton->SetTarget(vision_app); rect = netPrefsButton->Frame(); rect.OffsetBy(rect.Width() + kItemSpacing, 0); prefsButton = new BButton(rect, "prefs", S_SETUP_GENPREFS B_UTF8_ELLIPSIS, new BMessage(M_PREFS_SHOW)); prefsButton->ResizeToPreferred(); prefsButton->SetTarget(vision_app); rect = prefsButton->Frame(); float newWidth = rect.right + kItemSpacing; float newHeight = rect.bottom + kItemSpacing; ResizeTo(newWidth, newHeight); bgView->AddChild(logo); bgView->AddChild(netList); bgView->AddChild(prefsButton); bgView->AddChild(netPrefsButton); bgView->AddChild(connectButton); rect = Bounds(); rect.bottom = netList->Frame().bottom - (kItemSpacing * 2); logo->ResizeTo(newWidth, rect.Height()); connectButton->SetEnabled(false); rect = vision_app->GetRect("SetupWinRect"); if (rect.Width() > 0) MoveTo(rect.LeftTop()); }