?? actuator_init.cpp
字號:
// Distributed control system: actuator node//// Receives messages from the controller and actuates // the plant.#define S_FUNCTION_NAME actuator_init#include "ttkernel.cpp"// code functiondouble act_code(int seg, void *data) { static double *y, *u, t; switch (seg) { case 1: ttWait("packet"); return 0.0; case 2: return 0.0005; case 3: u = (double *)ttGetMsg(); // Receive message if (u != NULL) { ttAnalogOut(1, *u); delete u; // delete message } ttSetNextSegment(1); // loop and wait for new packet return 0.0; }}double msgRcvhandler(int seg, void *data){ ttNotifyAll("packet"); return FINISHED;}void init(){ // Initialize TrueTime kernel ttInitKernel(0, 1, FP); // nbrOfInputs, nbrOfOutputs, fixed priority // Actuator task double deadline = 100.0; double prio = 1.0; ttCreateTask("act_task", deadline, prio, act_code); ttCreateJob("act_task"); // Initialize network ttCreateInterruptHandler("msgRcv", prio, msgRcvhandler); ttInitNetwork(2, "msgRcv"); // node #2 in the network ttCreateEvent("packet");}void cleanup() {}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -