⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interference_init.cpp

📁 使用TRUETIME仿真软件编写的关于分布式实时控制系统的仿真程序
💻 CPP
字号:
// Distributed control system: interference node//// Generates disturbing network traffic.#define S_FUNCTION_NAME interference_init#include "ttkernel.cpp"// code functiondouble sender_code(int seg, void *data){  double BWshare = 0.0; // Fraction of the network bandwidth  if ((double)rand()/(double)RAND_MAX < BWshare) {    ttSendMsg(1, NULL, 80);  // send 80 bits to myself (no data)  }  return FINISHED;}double msgRcvhandler(int seg, void *data){  void *msg;  msg = ttGetMsg();  return FINISHED;}void init(){  // Initialize TrueTime kernel  ttInitKernel(0, 0, prioFP); // nbrOfInputs, nbrOfOutputs, fixed priority  // Sender task  double offset = 0;  double period = 0.001;  double prio = 1.0;  ttCreatePeriodicTask("sender", offset, period, prio, sender_code);  // Initialize network  ttCreateInterruptHandler("msgRcv", prio, msgRcvhandler);  ttInitNetwork(1, "msgRcv"); // node #1 in the network}void cleanup() {}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -