MibView::MibView (QWidget * parent) : BasicMibView(parent) { // Create context menu actions walkAct = new QAction(tr("Walk"), this); connect(walkAct, SIGNAL(triggered()), this, SLOT(WalkFromNode())); getAct = new QAction(tr("Get"), this); connect(getAct, SIGNAL(triggered()), this, SLOT(GetFromNode())); getPromptAct = new QAction(tr("Prompt for instance..."), this); connect(getPromptAct, SIGNAL(triggered()), this, SLOT(GetFromNodePromptInstance())); getSelectAct = new QAction(tr("Select Instance"), this); connect(getSelectAct, SIGNAL(triggered()), this, SLOT(GetFromNodeSelectInstance())); getnextAct = new QAction(tr("Get Next"), this); connect(getnextAct, SIGNAL(triggered()), this, SLOT(GetNextFromNode())); getnextPromptAct = new QAction(tr("Prompt for instance..."), this); connect(getnextPromptAct, SIGNAL(triggered()), this, SLOT(GetNextFromNodePromptInstance())); getnextSelectAct = new QAction(tr("Select Instance"), this); connect(getnextSelectAct, SIGNAL(triggered()), this, SLOT(GetNextFromNodeSelectInstance())); getbulkAct = new QAction(tr("Get Bulk"), this); connect(getbulkAct, SIGNAL(triggered()), this, SLOT(GetBulkFromNode())); getbulkPromptAct = new QAction(tr("Prompt for instance..."), this); connect(getbulkPromptAct, SIGNAL(triggered()), this, SLOT(GetBulkFromNodePromptInstance())); getbulkSelectAct = new QAction(tr("Select Instance"), this); connect(getbulkSelectAct, SIGNAL(triggered()), this, SLOT(GetBulkFromNodeSelectInstance())); setAct = new QAction(tr("Set..."), this); connect(setAct, SIGNAL(triggered()), this, SLOT(SetFromNode())); stopAct = new QAction(tr("Stop"), this); connect(stopAct, SIGNAL(triggered()), this, SLOT(StopNode())); tableviewAct = new QAction(tr("Table View"), this); connect(tableviewAct, SIGNAL(triggered()), this, SLOT(TableViewFromNode())); varbindsAct = new QAction(tr("Multiple Varbinds..."), this); connect(varbindsAct, SIGNAL(triggered()), this, SLOT(VarbindsFromNode())); walkinprogress = false; agentisv1 = true; }
int ProcessCommand(char* command) { int ret = 0; int sec = 0; int NodeID; int NodeType; EnterMutex(); switch(cst_str4(command[0], command[1], command[2], command[3])) { case cst_str4('h', 'e', 'l', 'p') : /* Display Help*/ help_menu(); break; case cst_str4('s', 's', 't', 'a') : /* Slave Start*/ StartNode(ExtractNodeId(command + 5)); break; case cst_str4('s', 's', 't', 'o') : /* Slave Stop */ StopNode(ExtractNodeId(command + 5)); break; case cst_str4('s', 'r', 's', 't') : /* Slave Reset */ ResetNode(ExtractNodeId(command + 5)); break; case cst_str4('i', 'n', 'f', 'o') : /* Retrieve node informations */ GetSlaveNodeInfo(ExtractNodeId(command + 5)); break; case cst_str4('r', 's', 'd', 'o') : /* Read device entry */ ReadDeviceEntry(command); break; case cst_str4('w', 's', 'd', 'o') : /* Write device entry */ WriteDeviceEntry(command); break; case cst_str4('s', 'c', 'a', 'n') : /* Display master node state */ DiscoverNodes(); break; case cst_str4('w', 'a', 'i', 't') : /* Display master node state */ ret = sscanf(command, "wait#%d", &sec); if(ret == 1) { LeaveMutex(); SleepFunction(sec); return 0; } break; case cst_str4('q', 'u', 'i', 't') : /* Quit application */ LeaveMutex(); return QUIT; case cst_str4('l', 'o', 'a', 'd') : /* Library Interface*/ ret = sscanf(command, "load#%100[^,],%30[^,],%4[^,],%d,%d", LibraryPath, BoardBusName, BoardBaudRate, &NodeID, &NodeType); if(ret == 5) { LeaveMutex(); ret = NodeInit(NodeID, NodeType); return ret; } else { printf("Invalid load parameters\n"); } break; default : help_menu(); } LeaveMutex(); return 0; }
int ProcessCommand(char* command) { int ret = 0; int sec = 0; int NodeID; int NodeType; UNS32 data = 0; char buf[50]; EnterMutex(); switch(cst_str4(command[0], command[1], command[2], command[3])) { case cst_str4('h', 'e', 'l', 'p') : /* Display Help*/ help_menu(); break; case cst_str4('c', 'l', 'e', 'a') : /* Display Help*/ system(CLEARSCREEN); break; case cst_str4('s', 's', 't', 'a') : /* Slave Start*/ StartNode(ExtractNodeId(command + 5)); break; case cst_str4('s', 's', 't', 'o') : /* Slave Stop */ StopNode(ExtractNodeId(command + 5)); break; case cst_str4('s', 'r', 's', 't') : /* Slave Reset */ ResetNode(ExtractNodeId(command + 5)); break; case cst_str4('i', 'n', 'f', 'o') : /* Retrieve node informations */ GetSlaveNodeInfo(ExtractNodeId(command + 5)); break; case cst_str4('r', 's', 'd', 'o') : /* Read device entry */ ReadDeviceEntry(command); break; case cst_str4('w', 's', 'd', 'o') : /* Write device entry */ WriteDeviceEntry(command); break; case cst_str4('n', 'o', 'd', 'e') : /* Write device entry */ ret = sscanf(command, "node %2x", &NodeID); data = 0; SDO_write(CANOpenShellOD_Data,NodeID,0x1024,0x00,1, 0, &data, 0); CurrentNode = NodeID; break; case cst_str4('c', 'm', 'd', ' ') : /* Write device entry */ ret = sscanf(command, "cmd %2x,%s", &NodeID, buf ); SDO_write(CANOpenShellOD_Data,NodeID,0x1023,0x01,strlen(buf),visible_string, buf, 0); SDO_read(CANOpenShellOD_Data,NodeID,0x1023,0x03,visible_string,0); return 0; break; case cst_str4('s', 'y', 'n', '0') : /* Display master node state */ stopSYNC(CANOpenShellOD_Data); break; case cst_str4('s', 'y', 'n', '1') : /* Display master node state */ startSYNC(CANOpenShellOD_Data); break; case cst_str4('s', 't', 'a', 't') : /* Display master node state */ printf("Status3: %x\n",Status3); Status3 = 0; break; case cst_str4('s', 'c', 'a', 'n') : /* Display master node state */ DiscoverNodes(); break; case cst_str4('w', 'a', 'i', 't') : /* Display master node state */ ret = sscanf(command, "wait#%d", &sec); if(ret == 1) { LeaveMutex(); SleepFunction(sec); return 0; } break; case cst_str4('g', 'o', 'o', 'o') : /* Quit application */ setState(CANOpenShellOD_Data, Operational); break; case cst_str4('q', 'u', 'i', 't') : /* Quit application */ LeaveMutex(); return QUIT; case cst_str4('l', 'o', 'a', 'd') : /* Library Interface*/ ret = sscanf(command, "load#%100[^,],%30[^,],%4[^,],%d,%d", LibraryPath, BoardBusName, BoardBaudRate, &NodeID, &NodeType); if(ret == 5) { LeaveMutex(); ret = NodeInit(NodeID, NodeType); return ret; } else { printf("Invalid load parameters\n"); } break; default : help_menu(); } LeaveMutex(); return 0; }