-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpartNames.js
64 lines (63 loc) · 2.94 KB
/
partNames.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const _ = require('lodash')
// const inData = require('./data/out.json')
module.exports.partNames = (allParts) => {
return allParts.map((part) => {
let partName = part.path.substr(part.path.lastIndexOf('/') + 1)
let breadboardPartConnectesTo = 'none'
let pcbPartConnectesTo = 'none'
let schematicPartConnectesTo = 'none'
let breadboardConnectTo = ['none']
let pcbConnectTo = ['none']
let schematicConnectTo = ['none']
if ( _.isEmpty(part.viewSettings[0], true)) {
return ({name: partName, modelIndex: part.modelIndex, connectedTo:{breadboard: breadboardConnectTo, pcb:pcbConnectTo, schematic:schematicConnectTo}})
}
else {
for (let i = 0; i < part.viewSettings.length; i++) {
let thisView = part.viewSettings[i]
if (!_.isEmpty(thisView.connectors, true)) {
let temp = {}
switch (thisView.name) {
case 'breadboard':
// console.log("got breadboard",thisView.connectors);
breadboardPartConnectesTo = thisView.connectors
breadboardConnectTo = breadboardPartConnectesTo.map(connectTo => {
if (!_.isEmpty(connectTo.connectsTo, true)) {
temp = {originId: connectTo.id, originIndex: part.modelIndex, targetIndex:connectTo.connectsTo[0].modelIndex, targetId:connectTo.connectsTo[0].id, layer:connectTo.connectsTo[0].layer}
// console.log('temp from switchcase',temp);
return temp
}
})
break;
//
// case 'pcb':
// // console.log("got pcb",thisView.name);
// pcbPartConnectesTo = thisView.connectors
// pcbConnectTo = pcbPartConnectesTo.map(connectTo => {
// if (!_.isEmpty(connectTo.connectsTo, true)) {
// temp = {modelIndex:connectTo.connectsTo[0].modelIndex, id:connectTo.connectsTo[0].id, layer:connectTo.connectsTo[0].layer}
// return temp
// }
// })
// break;
//
// case 'schematic':
// // console.log("got schematic",thisView.name);
// schematicPartConnectesTo = thisView.connectors
// schematicConnectTo = schematicPartConnectesTo.map(connectTo => {
// if (!_.isEmpty(connectTo.connectsTo, true)) {
// temp = {modelIndex:connectTo.connectsTo[0].modelIndex, id:connectTo.connectsTo[0].id, layer:connectTo.connectsTo[0].layer}
// return temp
// }
// })
break;
default:
// console.log("DEFAULT::::::",thisView.name);
}
}
}
// return ({name: partName, modelIndex: part.modelIndex, connectedTo:{breadboard: breadboardConnectTo, pcb:pcbConnectTo, schematic:schematicConnectTo}})
return ({name: partName, modelIndex: part.modelIndex, connectedTo:{breadboard: breadboardConnectTo}})
}
})
}