Simon Hunt

efunc: generate map data

Change-Id: I613166d3ebc016fc1c37bff61a909ab60aae8836
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + ONOS GUI -- Util -- EE functions
19 + */
20 +(function () {
21 + 'use strict';
22 +
23 + // injected services
24 + var fs;
25 +
26 + // function references
27 + var fcc = String.fromCharCode;
28 +
29 + function computeTransform(x) {
30 + var m = x.split(':'),
31 + h = Number(m[0]),
32 + d = m[1],
33 + n = d.length,
34 + w = [],
35 + i;
36 +
37 + for (i = 0; i<n; i+=2)
38 + w.push(fcc(Number(d.slice(i, i+2))));
39 +
40 + return fs.eecode(h, w.join(''));
41 + }
42 +
43 + function genMap(data) {
44 + var map = {};
45 +
46 + data.forEach(function (x) {
47 + var r = computeTransform(x);
48 + map['shift' + r.e] = r.o.toLowerCase() + '.bin';
49 + });
50 + return map;
51 + }
52 +
53 + angular.module('onosUtil')
54 + .factory('EeService',
55 + ['FnService', function (_fs_) {
56 + fs = _fs_;
57 +
58 + return {
59 + genMap: genMap
60 + }
61 + }]);
62 +}());
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
41 <script src="app/directives.js"></script> 41 <script src="app/directives.js"></script>
42 42
43 <script src="app/fw/util/util.js"></script> 43 <script src="app/fw/util/util.js"></script>
44 + <script src="app/fw/util/ee.js"></script>
44 <script src="app/fw/util/fn.js"></script> 45 <script src="app/fw/util/fn.js"></script>
45 <script src="app/fw/util/random.js"></script> 46 <script src="app/fw/util/random.js"></script>
46 <script src="app/fw/util/theme.js"></script> 47 <script src="app/fw/util/theme.js"></script>
......