source: ResearchApps/PHY/WARPLAB/WARPLab7/M_Code_Reference/classes/wl_resp.m

Last change on this file was 4332, checked in by welsh, 9 years ago

Code cleanup.

File size: 2.0 KB
Line 
1%-------------------------------------------------------------------------
2% WARPLab Framework
3%
4% Copyright 2013, Mango Communications. All rights reserved.
5%           Distributed under the WARP license  (http://warpproject.org/license)
6%
7% Chris Hunter (chunter [at] mangocomm.com)
8% Patrick Murphy (murphpo [at] mangocomm.com)
9% Erik Welsh (welsh [at] mangocomm.com)
10%-------------------------------------------------------------------------
11
12classdef wl_resp < wl_msg_helper
13   properties(SetAccess = public)
14      cmd;
15   end
16   
17   properties(SetAccess = protected)
18      cmd_len;
19      numArgs;
20   end
21   
22   properties(SetAccess = protected, Hidden=true)
23      args; 
24   end
25   
26   methods
27       function obj = wl_resp(varargin)
28            obj.cmd     = uint32(0); 
29            obj.cmd_len = uint16(0); 
30            obj.numArgs = uint16(0); 
31            obj.args    = uint32([]);
32           
33            if(length(varargin) == 1)
34                obj.deserialize(varargin{1});
35            end
36       end
37       
38       function deserialize(obj,vec)
39            vec         = uint32(vec);
40            obj.cmd     = vec(1);
41            obj.numArgs = bitand(65535, vec(2));
42            obj.cmd_len = bitshift(vec(2), -16);
43           
44            if(length(vec) > 2)
45                obj.args = {vec(3:(2 + (obj.cmd_len/4)))};
46            end
47       end
48       
49       function output = getArgs(obj)
50            if(isempty(obj.args)==0)
51                output = cat(2,obj.args{:});
52            else
53                output = [];
54            end
55       end
56       
57       function output = len(obj)
58           output = (obj.cmd_len / 4) + 2;
59       end
60       
61       function output = sizeof(obj)
62           output = length(obj.serialize) * 4;
63       end
64           
65       function output = serialize(obj)
66           output(1) = obj.cmd;
67           output(2) = bitor(bitshift(uint32(obj.cmd_len),16), uint32(obj.numArgs));
68           output = [output, obj.getArgs];
69       end
70   end
71end
Note: See TracBrowser for help on using the repository browser.