1 | function varargout = wl_ver(varargin) |
---|
2 | |
---|
3 | MAJOR = 7; |
---|
4 | MINOR = 7; |
---|
5 | REVISION = 1; |
---|
6 | XTRA = ''; |
---|
7 | RELEASE = 1; |
---|
8 | |
---|
9 | if (RELEASE == 0) |
---|
10 | fprintf('*********************************************************************\n'); |
---|
11 | fprintf('You are running a version of WARPLab that may not be compatible\n'); |
---|
12 | fprintf('with released WARPLab bitstreams. Users should run wl_setup.m from\n'); |
---|
13 | fprintf('the zip file provided in the release download.\n'); |
---|
14 | fprintf('*********************************************************************\n\n'); |
---|
15 | end |
---|
16 | |
---|
17 | outputs = {MAJOR, MINOR, REVISION, XTRA}; |
---|
18 | |
---|
19 | % Process the inputs: |
---|
20 | % 0 => Print standard WARPLab output |
---|
21 | % 1 => Takes a argument string: 'x.y.z'; |
---|
22 | % Issues a warning if current framework is newer. |
---|
23 | % Issues an error if current framework is older. |
---|
24 | % Take wl_node objects as argument |
---|
25 | % Issues an error if MAJOR and MINOR do not match |
---|
26 | % |
---|
27 | if nargin == 0 |
---|
28 | % Print standard WARPLab output |
---|
29 | if(nargout == 0) |
---|
30 | % WARPLab version |
---|
31 | fprintf('WARPLab v%d.%d.%d %s\n', MAJOR, MINOR, REVISION, XTRA); |
---|
32 | |
---|
33 | % MEX version |
---|
34 | try |
---|
35 | mex_version = wl_mex_udp_transport('version'); |
---|
36 | fprintf('WARPLab MEX UDP Transport v%s\n', mex_version); |
---|
37 | catch ME |
---|
38 | end |
---|
39 | |
---|
40 | fprintf('\nFramework Location:\n') |
---|
41 | [wl_path, ig, ig] = fileparts(which('wl_ver')); |
---|
42 | I = strfind(wl_path,sprintf('%sutil', filesep)); |
---|
43 | wl_path = wl_path(1:I); |
---|
44 | fprintf('%s\n',wl_path); |
---|
45 | else |
---|
46 | varargout(1:nargout) = outputs(1:nargout); |
---|
47 | end |
---|
48 | |
---|
49 | elseif nargin == 1 |
---|
50 | switch( class(varargin{1}) ) |
---|
51 | case 'wl_node' |
---|
52 | nodes = varargin{1}; |
---|
53 | numNodes = length(nodes); |
---|
54 | |
---|
55 | for n = numNodes:-1:1 |
---|
56 | currNode = nodes(n); |
---|
57 | |
---|
58 | % Error if MAJOR and MINOR versions do not match |
---|
59 | if ( ~((currNode.wlVer_major == MAJOR) && (currNode.wlVer_minor == MINOR)) ) |
---|
60 | error('Node %d with Serial # %d has version "%d.%d.%d" which does not match WARPLab v%d.%d.%d', currNode.ID, currNode.serialNumber, currNode.wlVer_major, currNode.wlVer_minor, currNode.wlVer_revision, MAJOR, MINOR, REVISION); |
---|
61 | end |
---|
62 | |
---|
63 | % Print a warning if MAJOR, MINOR, and REVISION do not match |
---|
64 | if ( ~((currNode.wlVer_major == MAJOR) && (currNode.wlVer_minor == MINOR) && (currNode.wlVer_revision == REVISION) ) ) |
---|
65 | warning('Node %d with Serial # %d has version "%d.%d.%d" which does not match WARPLab v%d.%d.%d', currNode.ID, currNode.serialNumber, currNode.wlVer_major, currNode.wlVer_minor, currNode.wlVer_revision, MAJOR, MINOR, REVISION); |
---|
66 | end |
---|
67 | end |
---|
68 | |
---|
69 | case 'char' |
---|
70 | version = varargin{1}; |
---|
71 | |
---|
72 | if (~(strcmp(version,sprintf('%d.%d.%d', MAJOR, MINOR, REVISION)))) |
---|
73 | |
---|
74 | [VER, count] = sscanf(version, '%d.%d.%d'); |
---|
75 | |
---|
76 | if (~(count == 3)) |
---|
77 | error('Unknown argument. Argument provided is: "%s", need "x.y.z" where x, y, and z are integers specifying the WARPLab version.', version); |
---|
78 | end |
---|
79 | |
---|
80 | if (VER(1) == MAJOR) |
---|
81 | if (VER(2) == MINOR) |
---|
82 | if (VER(3) == REVISION) |
---|
83 | % Versions are equal do nothing |
---|
84 | else |
---|
85 | % Versions are not equal; Since MAJOR and MINOR versions match, only print a warning |
---|
86 | if (lt(VER(3),REVISION)) |
---|
87 | warning('Specified version "%s" is older than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
88 | else |
---|
89 | warning('Specified version "%s" is newer than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
90 | end |
---|
91 | end |
---|
92 | else |
---|
93 | % Versions are not equal |
---|
94 | if (lt(VER(2),MINOR)) |
---|
95 | warning('Specified version "%s" is older than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
96 | else |
---|
97 | error('Specified version "%s" is newer than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
98 | end |
---|
99 | end |
---|
100 | else |
---|
101 | % Versions are not equal |
---|
102 | if (lt(VER(1),MAJOR)) |
---|
103 | warning('Specified version "%s" is older than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
104 | else |
---|
105 | error('Specified version "%s" is newer than WARPLab v%d.%d.%d', version, MAJOR, MINOR, REVISION); |
---|
106 | end |
---|
107 | end |
---|
108 | end |
---|
109 | |
---|
110 | otherwise |
---|
111 | error('Unknown argument. Argument is of type "%s", need "wl_node" or "char"', class(varargin{1})); |
---|
112 | end |
---|
113 | else |
---|
114 | error('Too many arguments provided'); |
---|
115 | end |
---|
116 | end |
---|