Commit cd66d0ea authored by amandaghassaei's avatar amandaghassaei

assign signals to wires

parent 78f9a9ed
...@@ -556,6 +556,10 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){ ...@@ -556,6 +556,10 @@ define(['underscore', 'appState', 'three'], function(_, appState, THREE){
return this.properties.conductive; return this.properties.conductive;
}; };
DMAMaterial.prototype.isSilicon = function(){
return this.properties.silicon;
}
DMAMaterial.prototype.getDensity = function(){ DMAMaterial.prototype.getDensity = function(){
return this.properties.density; return this.properties.density;
}; };
......
...@@ -30,6 +30,7 @@ define([], function(){ ...@@ -30,6 +30,7 @@ define([], function(){
altColor: "#8a2be2", altColor: "#8a2be2",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -45,6 +46,7 @@ define([], function(){ ...@@ -45,6 +46,7 @@ define([], function(){
mesh: "bending1dof", mesh: "bending1dof",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -60,6 +62,7 @@ define([], function(){ ...@@ -60,6 +62,7 @@ define([], function(){
mesh: "bending2dof", mesh: "bending2dof",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -75,6 +78,7 @@ define([], function(){ ...@@ -75,6 +78,7 @@ define([], function(){
mesh: "torsion1dof", mesh: "torsion1dof",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -89,6 +93,7 @@ define([], function(){ ...@@ -89,6 +93,7 @@ define([], function(){
texture: "cubeTextureShearFlex", texture: "cubeTextureShearFlex",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:2,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:2,zy:80},
...@@ -103,6 +108,7 @@ define([], function(){ ...@@ -103,6 +108,7 @@ define([], function(){
texture: "stripes", texture: "stripes",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 3500,//kg/m^3 density: 3500,//kg/m^3
longitudalK:{x:10,y:10,z:10}, longitudalK:{x:10,y:10,z:10},
shearK:{xy:10,xz:10,yx:10,yz:10,zx:10,zy:10}, shearK:{xy:10,xz:10,yx:10,yz:10,zx:10,zy:10},
...@@ -117,6 +123,7 @@ define([], function(){ ...@@ -117,6 +123,7 @@ define([], function(){
mesh: "wireStraight", mesh: "wireStraight",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:0, y:0, z:1}, {x:0, y:0, z:1},
{x:0, y:0, z:-1} {x:0, y:0, z:-1}
...@@ -135,6 +142,7 @@ define([], function(){ ...@@ -135,6 +142,7 @@ define([], function(){
mesh: "wireBent", mesh: "wireBent",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:0, y:0, z:-1} {x:0, y:0, z:-1}
...@@ -153,6 +161,7 @@ define([], function(){ ...@@ -153,6 +161,7 @@ define([], function(){
mesh: "wireJunction1", mesh: "wireJunction1",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:-1, y:0, z:0}, {x:-1, y:0, z:0},
...@@ -172,6 +181,7 @@ define([], function(){ ...@@ -172,6 +181,7 @@ define([], function(){
mesh: "wireJunction2", mesh: "wireJunction2",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:0, y:1, z:0}, {x:0, y:1, z:0},
...@@ -192,6 +202,7 @@ define([], function(){ ...@@ -192,6 +202,7 @@ define([], function(){
mesh: "wireStraight", mesh: "wireStraight",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:0, y:0, z:1}, {x:0, y:0, z:1},
{x:0, y:0, z:-1} {x:0, y:0, z:-1}
...@@ -211,6 +222,7 @@ define([], function(){ ...@@ -211,6 +222,7 @@ define([], function(){
mesh: "wireBent", mesh: "wireBent",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:0, y:0, z:-1} {x:0, y:0, z:-1}
...@@ -230,6 +242,7 @@ define([], function(){ ...@@ -230,6 +242,7 @@ define([], function(){
mesh: "wireJunction1", mesh: "wireJunction1",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:-1, y:0, z:0}, {x:-1, y:0, z:0},
...@@ -250,6 +263,7 @@ define([], function(){ ...@@ -250,6 +263,7 @@ define([], function(){
mesh: "wireJunction2", mesh: "wireJunction2",
properties:{ properties:{
conductive: true, conductive: true,
silicon: false,
conductiveAxes: [ conductiveAxes: [
{x:1, y:0, z:0}, {x:1, y:0, z:0},
{x:0, y:1, z:0}, {x:0, y:1, z:0},
...@@ -269,6 +283,7 @@ define([], function(){ ...@@ -269,6 +283,7 @@ define([], function(){
texture: "cubeTexture", texture: "cubeTexture",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 6500,//kg/m^3 density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -283,6 +298,7 @@ define([], function(){ ...@@ -283,6 +298,7 @@ define([], function(){
mesh: "bending1dof", mesh: "bending1dof",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 6500,//kg/m^3 density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -297,6 +313,7 @@ define([], function(){ ...@@ -297,6 +313,7 @@ define([], function(){
mesh: "torsion1dof", mesh: "torsion1dof",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 6500,//kg/m^3 density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -311,6 +328,7 @@ define([], function(){ ...@@ -311,6 +328,7 @@ define([], function(){
texture: "cubeTextureShear", texture: "cubeTextureShear",
properties:{ properties:{
conductive: false, conductive: false,
silicon: false,
density: 6500,//kg/m^3 density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
...@@ -325,6 +343,11 @@ define([], function(){ ...@@ -325,6 +343,11 @@ define([], function(){
mesh: "siliconModule", mesh: "siliconModule",
properties:{ properties:{
conductive: false, conductive: false,
silicon: true,
conductiveAxes: [
{x:1, y:0, z:0},
{x:-1, y:0, z:0}
],
density: 6500,//kg/m^3 density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80}, longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80}, shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......
...@@ -167,6 +167,7 @@ define(["underscore", "cell", "lattice", "plist", "three"], ...@@ -167,6 +167,7 @@ define(["underscore", "cell", "lattice", "plist", "three"],
}; };
DMACell.prototype.setAsSignalGenerator = function(json){ DMACell.prototype.setAsSignalGenerator = function(json){
this.terminals = [-1,-1];//storage for connecting wires
if (json){ if (json){
this.pwm = json.pwm; this.pwm = json.pwm;
this.frequency = json.frequency; this.frequency = json.frequency;
...@@ -202,6 +203,10 @@ define(["underscore", "cell", "lattice", "plist", "three"], ...@@ -202,6 +203,10 @@ define(["underscore", "cell", "lattice", "plist", "three"],
return this.getMaterial().isConductive(); return this.getMaterial().isConductive();
}; };
DMACell.prototype.isSilicon = function(){
return this.getMaterial().isSilicon();
};
EMSimCell.prototype.isActuator = function(){ EMSimCell.prototype.isActuator = function(){
return this.cell.getMaterialID() == "actuator"; return this.cell.getMaterialID() == "actuator";
}; };
...@@ -219,24 +224,50 @@ define(["underscore", "cell", "lattice", "plist", "three"], ...@@ -219,24 +224,50 @@ define(["underscore", "cell", "lattice", "plist", "three"],
this._wireGroup = num; this._wireGroup = num;
return; return;
} }
if (this._wireGroup>num){ if ((this.isConductive() && this._wireGroup>num) || this.isSilicon()){
//check if we can connect on this side //check if we can connect on this side
var axes = this.getMaterial().properties.conductiveAxes; var axes = this.getMaterial().properties.conductiveAxes;
var canConnect = false; var canConnect = false;
var self = this; var self = this;
_.each(axes, function(axis){ _.each(axes, function(axis, index){
var vector = new THREE.Vector3(axis.x, axis.y, axis.z); var vector = new THREE.Vector3(axis.x, axis.y, axis.z);
vector.applyQuaternion(self.getOrientation()); vector.applyQuaternion(self.getOrientation());
if (vector.dot(fromVector) < -0.9) canConnect = true; if (vector.dot(fromVector) < -0.9) {
if (self.isSilicon()) self.terminals[index] = num;
canConnect = true;
}
}); });
if (!canConnect) return; if (!canConnect) return;
if (!this.isConductive()) return;
this._wireGroup = num; this._wireGroup = num;
this.propagateWireGroup(this.calcNeighbors(this.getIndex()), num); this.propagateWireGroup(this.calcNeighbors(this.getIndex()), num);
} }
}; };
DMACell.prototype.isConnectedTo = function(neighbor){
var neighborAxes = neighbor.getMaterial().properties.conductiveAxes;
var axes = this.getMaterial().properties.conductiveAxes;
if (!neighborAxes || !axes) return false;
var canConnect = false;
var self = this;
_.each(neighborAxes, function(neighborAxis){
var neighborVector = new THREE.Vector3(neighborAxis.x, neighborAxis.y, neighborAxis.z);
neighborVector.applyQuaternion(neighbor.getOrientation());
_.each(axes, function(axis, index){
var vector = new THREE.Vector3(axis.x, axis.y, axis.z);
vector.applyQuaternion(self.getOrientation());
if (vector.dot(neighborVector) < -0.9) {
canConnect = true;
}
});
});
return canConnect;
};
DMACell.prototype.calcNeighbors = function(index){ DMACell.prototype.calcNeighbors = function(index){
var cells = lattice.getCells(); var cells = lattice.getCells();
var sizeX = cells.length; var sizeX = cells.length;
......
...@@ -429,7 +429,17 @@ define(['underscore', 'backbone', 'threeModel', 'lattice', 'plist', 'emWire', 'G ...@@ -429,7 +429,17 @@ define(['underscore', 'backbone', 'threeModel', 'lattice', 'plist', 'emWire', 'G
var wires = this.get("wires"); var wires = this.get("wires");
var signalConflict = false; var signalConflict = false;
_.each(this.get("signals"), function(signal){ _.each(this.get("signals"), function(signal){
signalConflict |= wires[signal.getWireGroup()].addSignal(signal); _.each(signal.terminals, function(wireNum){
if (wireNum < 0 ) return;
signalConflict |= wires[wireNum].addSignal(signal);
});
});
_.each(this.get("signals"), function(signal){
_.each(signal.calcNeighbors(signal.getIndex()), function(neighbor){
if (neighbor && neighbor.isSignalGenerator()){
if (signal.isConnectedTo(neighbor)) signalConflict = true;
}
})
}); });
this.set("signalConflict", signalConflict); this.set("signalConflict", signalConflict);
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment