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

📄 oscope.m

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 M
字号:
function oscope(varargin)%This function is the interface to control the matlab oscilloscope application%%%%%%%%%%%%%%%%%%%% The following block is the standard matlab/TinyOS app.%% Functions specific to this application are below%%%%%%%%%%%%%%%%%if nargin>0 & ischar(varargin{1})  %% the user or timer is calling one of the functions below  feval(varargin{1},varargin{2:end});  elseif nargin==0   usage;endfunction usagefprintf('USAGE:\n\toscilloscope(''init'')\n\toscilloscope(''start'')\n\toscilloscpe(''reset'')\n\tetc.\n')%%%%%%%%%%%%%%%%%%%% StdControl:%%   init%%   reinit%%   start%%   restart%%   stop%%%%%%%%%%%%%%%%%  function init(varargin)%% create a global structure to hold persistent state for this applicationglobal OSCOPE%% import all necessary java packagesimport net.tinyos.*import net.tinyos.message.*import net.tinyos.oscope.*%% connect to the networkconnect('sf@localhost:9001');%% instantiate the application message types for future useOSCOPE.oscopeMsg = oscope.OscopeMsg;OSCOPE.resetMsg = oscope.OscopeResetMsg;%% instantiate a timerOSCOPE.timer = timer('Name', 'Oscope Timer','TimerFcn',@timerFired,'ExecutionMode','fixedRate','Period',10);function startglobal OSCOPE%% register as a listener to OscopeMsg objectsreceive(@oscopeMessageReceived,OSCOPE.oscopeMsg);%% start the timerstartTimer(OSCOPE.timer)function stopglobal OSCOPE%% unregister as a listener to OscopeMsg objectsstopReceiving(@oscopeMessageReceived,OSCOPE.oscopeMsg);%% stop the timerstopTimer(OSCOPE.timer)%%%%%%%%%%%%%%%%%%%% Timer:%%   timerFired%%%%%%%%%%%%%%%%%function timerFiredreset;%%%%%%%%%%%%%%%%%%%% Message Receive Events%%%%%%%%%%%%%%%%%function oscopeMessageReceived(address, oscopeMsg, varargin)global OSCOPExdata = get(OSCOPE.plot,'XData');ydata = get(OSCOPE.plot,'YData');set(OSCOPE.plot,'XData',[xdata oscopeMsg.lastSampleNumber-9:oscopeMsg.lastSampleNumber]);set(OSCOPE.plot,'YData',[ydata oscopeMsg.get_data']);%%%%%%%%%%%%%%%%%%%% User Defined Functions%%%%%%%%%%%%%%%%%function reset(address)global OSCOPEglobal COMM%% reset all nodes, unless user specified somebody specificif nargin<1 address = COMM.TOS_BCAST_ADDR; endsend(address,OSCOPE.resetMsg);%% reset the plotset(OSCOPE.plot,'XData',[]);set(OSCOPE.plot,'YData',[]);

⌨️ 快捷键说明

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