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){
return this.properties.conductive;
};
DMAMaterial.prototype.isSilicon = function(){
return this.properties.silicon;
}
DMAMaterial.prototype.getDensity = function(){
return this.properties.density;
};
......
......@@ -30,6 +30,7 @@ define([], function(){
altColor: "#8a2be2",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -45,6 +46,7 @@ define([], function(){
mesh: "bending1dof",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -60,6 +62,7 @@ define([], function(){
mesh: "bending2dof",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -75,6 +78,7 @@ define([], function(){
mesh: "torsion1dof",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -89,6 +93,7 @@ define([], function(){
texture: "cubeTextureShearFlex",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:2,zy:80},
......@@ -103,6 +108,7 @@ define([], function(){
texture: "stripes",
properties:{
conductive: false,
silicon: false,
density: 3500,//kg/m^3
longitudalK:{x:10,y:10,z:10},
shearK:{xy:10,xz:10,yx:10,yz:10,zx:10,zy:10},
......@@ -117,6 +123,7 @@ define([], function(){
mesh: "wireStraight",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:0, y:0, z:1},
{x:0, y:0, z:-1}
......@@ -135,6 +142,7 @@ define([], function(){
mesh: "wireBent",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:0, y:0, z:-1}
......@@ -153,6 +161,7 @@ define([], function(){
mesh: "wireJunction1",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:-1, y:0, z:0},
......@@ -172,6 +181,7 @@ define([], function(){
mesh: "wireJunction2",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:0, y:1, z:0},
......@@ -192,6 +202,7 @@ define([], function(){
mesh: "wireStraight",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:0, y:0, z:1},
{x:0, y:0, z:-1}
......@@ -211,6 +222,7 @@ define([], function(){
mesh: "wireBent",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:0, y:0, z:-1}
......@@ -230,6 +242,7 @@ define([], function(){
mesh: "wireJunction1",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:-1, y:0, z:0},
......@@ -250,6 +263,7 @@ define([], function(){
mesh: "wireJunction2",
properties:{
conductive: true,
silicon: false,
conductiveAxes: [
{x:1, y:0, z:0},
{x:0, y:1, z:0},
......@@ -269,6 +283,7 @@ define([], function(){
texture: "cubeTexture",
properties:{
conductive: false,
silicon: false,
density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -283,6 +298,7 @@ define([], function(){
mesh: "bending1dof",
properties:{
conductive: false,
silicon: false,
density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -297,6 +313,7 @@ define([], function(){
mesh: "torsion1dof",
properties:{
conductive: false,
silicon: false,
density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -311,6 +328,7 @@ define([], function(){
texture: "cubeTextureShear",
properties:{
conductive: false,
silicon: false,
density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......@@ -325,6 +343,11 @@ define([], function(){
mesh: "siliconModule",
properties:{
conductive: false,
silicon: true,
conductiveAxes: [
{x:1, y:0, z:0},
{x:-1, y:0, z:0}
],
density: 6500,//kg/m^3
longitudalK:{x:80,y:80,z:80},
shearK:{xy:80,xz:80,yx:80,yz:80,zx:80,zy:80},
......
......@@ -167,6 +167,7 @@ define(["underscore", "cell", "lattice", "plist", "three"],
};
DMACell.prototype.setAsSignalGenerator = function(json){
this.terminals = [-1,-1];//storage for connecting wires
if (json){
this.pwm = json.pwm;
this.frequency = json.frequency;
......@@ -202,6 +203,10 @@ define(["underscore", "cell", "lattice", "plist", "three"],
return this.getMaterial().isConductive();
};
DMACell.prototype.isSilicon = function(){
return this.getMaterial().isSilicon();
};
EMSimCell.prototype.isActuator = function(){
return this.cell.getMaterialID() == "actuator";
};
......@@ -219,24 +224,50 @@ define(["underscore", "cell", "lattice", "plist", "three"],
this._wireGroup = num;
return;
}
if (this._wireGroup>num){
if ((this.isConductive() && this._wireGroup>num) || this.isSilicon()){
//check if we can connect on this side
var axes = this.getMaterial().properties.conductiveAxes;
var canConnect = false;
var self = this;
_.each(axes, function(axis){
_.each(axes, function(axis, index){
var vector = new THREE.Vector3(axis.x, axis.y, axis.z);
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 (!this.isConductive()) return;
this._wireGroup = 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){
var cells = lattice.getCells();
var sizeX = cells.length;
......
......@@ -429,7 +429,17 @@ define(['underscore', 'backbone', 'threeModel', 'lattice', 'plist', 'emWire', 'G
var wires = this.get("wires");
var signalConflict = false;
_.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);
},
......
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