Commit 4c88328a authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Model: added adaptable Parameters + flattened generics

parent c4f4aa88
...@@ -234,6 +234,24 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -234,6 +234,24 @@ public class GenerationTest extends AbstractSymtabTest {
content = content.replace("Col<int> counter=Col<int>(1);" , "Col<int> counter=Col<int>(n);"); content = content.replace("Col<int> counter=Col<int>(1);" , "Col<int> counter=Col<int>(n);");
content = content.replace("colvec tmpLine;","colvec tmpLine = colvec(4);"); content = content.replace("colvec tmpLine;","colvec tmpLine = colvec(4);");
// content = content.replace("sqrt","std::sqrt"); // content = content.replace("sqrt","std::sqrt");
if(f.getName().equals("ba_system_collisionDetection_multiOr.h")){
content = content.replace("10","1");
}
// if(f.getName().equals("ba_system_collisionDetection_rectIntersection_1__dualSetCompare.h")){
// String fixedGenerics = "const int n = 4;\nconst int n2 = 10;\n";
// content = content.replace("const int cols = 1;","const int cols = 1;\n" + fixedGenerics);
// }
if(f.getName().equals("ba_system_collisionDetection_rectIntersection_1__dualSetCompare.h")){
content = content.replace("rows = 4","rows = 2");
content = content.replace("cols = 1","cols = 4");
content = content.replace("n = 4","n = 2");
content = content.replace("n2 = 10","n2 = 1");
}
Files.write(path, content.getBytes(charset)); Files.write(path, content.getBytes(charset));
} }
} }
......
...@@ -3,7 +3,7 @@ import ba.intersection.IntersectionController; ...@@ -3,7 +3,7 @@ import ba.intersection.IntersectionController;
import ba.util.RelToAbsTrajectory; import ba.util.RelToAbsTrajectory;
import ba.util.CommQuality; import ba.util.CommQuality;
import ba.vehicle.VelocityController; import ba.vehicle.VelocityController;
import ba.collisionDetection.CollisionDetection; import ba.collisionDetection.CollisionDetectionGeneric;
//component System<N1 n = 2,N1 x = 1,N1 m = 5,N1 m1 = 4,N1 m2 = 10>{ //component System<N1 n = 2,N1 x = 1,N1 m = 5,N1 m1 = 4,N1 m2 = 10>{
component System{ component System{
//Intersection ports //Intersection ports
...@@ -25,7 +25,7 @@ component System{ ...@@ -25,7 +25,7 @@ component System{
out Q(0m/s : 60m/s) curVel[2]; out Q(0m/s : 60m/s) curVel[2];
instance IntersectionController intersectionController; instance IntersectionController intersectionController;
instance CollisionDetection collisionDetection; instance CollisionDetectionGeneric collisionDetection;
instance CommQuality<B> stopCommQuality[2]; instance CommQuality<B> stopCommQuality[2];
instance VelocityController(3.0) velocityController[2]; instance VelocityController(3.0) velocityController[2];
......
...@@ -3,14 +3,14 @@ import ba.util.RectIntersection; ...@@ -3,14 +3,14 @@ import ba.util.RectIntersection;
import ba.util.SingleSetCompareMatrix; import ba.util.SingleSetCompareMatrix;
import ba.util.MultiOr; import ba.util.MultiOr;
component CollisionDetection<N1 n = 2,N1 x = 1>{ component CollisionDetectionGeneric<N1 n = 2,N1 x = 1>{
//component CollisionDetection{ //component CollisionDetection{
ports in Q^{2,4} hulls[n], ports in Q^{2,4} hulls[n],
out B collision; out B collision;
instance SingleSetCompareMatrix<2,4,n,x> singleSetCompare; instance SingleSetCompareMatrix<2,4,2,1> singleSetCompare;
instance RectIntersection rectIntersection[x]; instance RectIntersection rectIntersection[x];
instance MultiOr<x> multiOr; instance MultiOr<1> multiOr;
connect hulls[:] -> singleSetCompare.setIn[:]; connect hulls[:] -> singleSetCompare.setIn[:];
......
...@@ -2,16 +2,16 @@ package ba.intersection; ...@@ -2,16 +2,16 @@ package ba.intersection;
import ba.util.SingleSetCompareMatrix; import ba.util.SingleSetCompareMatrix;
//TODO: x = (n-1)n/2 //TODO: x = (n-1)n/2
//TODO: m1 = m - 1, m2 = m1(m1+1)/2 //TODO: m1 = m - 1, m2 = m1(m1+1)/2
component IntersectionController<N1 n = 2,N1 x = 1,N1 m = 5,N1 m1 = 4,N1 m2 = 10>{ //component IntersectionController<N1 n = 2,N1 x = 1,N1 m = 5,N1 m1 = 4,N1 m2 = 10>{
//component IntersectionController{ component IntersectionController{
ports in Q^{3,m} trajectoryIn[n], ports in Q^{3,5} trajectoryIn[2],
in Q(0m : 10m) cutoffTime, in Q(0m : 10m) cutoffTime,
in B isActive, in B isActive,
out B stop[n]; out B stop[2];
instance SingleSetCompareMatrix<3,m,n,x> singleSetCompare; instance SingleSetCompareMatrix<3,5,2,1> singleSetCompare;
instance TrajectoryCollision<m,m1,m2> trajectoryCollision[x]; instance TrajectoryCollision<5,4,10> trajectoryCollision[1];
instance CollisionToStop<n,x,m> collisionToStop; instance CollisionToStop<2,1,5> collisionToStop;
connect trajectoryIn[:] -> singleSetCompare.setIn[:]; connect trajectoryIn[:] -> singleSetCompare.setIn[:];
connect singleSetCompare.outA[:] -> trajectoryCollision[:].trajectoryA; connect singleSetCompare.outA[:] -> trajectoryCollision[:].trajectoryA;
......
...@@ -12,7 +12,7 @@ component TrajectoryCollision<N1 m = 5, N1 m1 = 4, N1 m2 = 10>{ ...@@ -12,7 +12,7 @@ component TrajectoryCollision<N1 m = 5, N1 m1 = 4, N1 m2 = 10>{
instance TrajectoryToLines trajectoryToLinesA; instance TrajectoryToLines trajectoryToLinesA;
instance TrajectoryToLines trajectoryToLinesB; instance TrajectoryToLines trajectoryToLinesB;
instance DualSetCompareMatrix<4,1,m1,m2> dualSetCompare; instance DualSetCompareMatrix<4,1,4,10> dualSetCompare;
instance LineIntersection lineIntersection[m2]; instance LineIntersection lineIntersection[m2];
instance FirstLineIntersection firstLineIntersection; instance FirstLineIntersection firstLineIntersection;
instance TimeCutoffFilter(2.0) timeCutoffFilter; instance TimeCutoffFilter(2.0) timeCutoffFilter;
......
...@@ -12,41 +12,19 @@ component RectIntersection{ ...@@ -12,41 +12,19 @@ component RectIntersection{
instance RectToLines rectToLines1; instance RectToLines rectToLines1;
instance RectToLines rectToLines2; instance RectToLines rectToLines2;
instance DualSetCompareMatrix<2,4,4,10> dualSetCompare;
instance LineIntersection lineIntersection[10]; instance LineIntersection lineIntersection[10];
instance MultiOr<10> multiOr; instance MultiOr<10> multiOr;
connect rect1 -> rectToLines1.rect; connect rect1 -> rectToLines1.rect;
connect rect2 -> rectToLines2.rect; connect rect2 -> rectToLines2.rect;
connect rectToLines1.lineA -> lineIntersection[1].lineA; connect rectToLines1.lines[:] -> dualSetCompare.setInA[:];
connect rectToLines2.lineA -> lineIntersection[1].lineB; connect rectToLines2.lines[:] -> dualSetCompare.setInB[:];
connect rectToLines1.lineA -> lineIntersection[2].lineA;
connect rectToLines2.lineB -> lineIntersection[2].lineB;
connect rectToLines1.lineA -> lineIntersection[3].lineA;
connect rectToLines2.lineC -> lineIntersection[3].lineB;
connect rectToLines1.lineA -> lineIntersection[4].lineA;
connect rectToLines2.lineD -> lineIntersection[4].lineB;
connect rectToLines1.lineB -> lineIntersection[5].lineA;
connect rectToLines2.lineB -> lineIntersection[5].lineB;
connect rectToLines1.lineB -> lineIntersection[6].lineA;
connect rectToLines2.lineC -> lineIntersection[6].lineB;
connect rectToLines1.lineB -> lineIntersection[7].lineA;
connect rectToLines2.lineD -> lineIntersection[7].lineB;
connect rectToLines1.lineC -> lineIntersection[8].lineA;
connect rectToLines2.lineC -> lineIntersection[8].lineB;
connect rectToLines1.lineC -> lineIntersection[9].lineA;
connect rectToLines2.lineD -> lineIntersection[9].lineB;
connect rectToLines1.lineD -> lineIntersection[10].lineA; connect dualSetCompare.outA[:] -> lineIntersection[:].lineA;
connect rectToLines2.lineD -> lineIntersection[10].lineB; connect dualSetCompare.outB[:] -> lineIntersection[:].lineB;
connect lineIntersection[:].intersects -> multiOr.boolIn[:]; connect lineIntersection[:].intersects -> multiOr.boolIn[:];
connect multiOr.boolOut -> collision; connect multiOr.boolOut -> collision;
......
...@@ -2,11 +2,7 @@ package ba.util; ...@@ -2,11 +2,7 @@ package ba.util;
component RectToLines{ component RectToLines{
ports in Q^{2,4} rect, ports in Q^{2,4} rect,
//TODO: as array once issue is resolved out Q^{4,1} lines[4];
out Q^{4,1} lineA,
out Q^{4,1} lineB,
out Q^{4,1} lineC,
out Q^{4,1} lineD;
implementation Math{ implementation Math{
Q^{4,1} tmpLine; Q^{4,1} tmpLine;
...@@ -23,16 +19,19 @@ component RectToLines{ ...@@ -23,16 +19,19 @@ component RectToLines{
tmpLine(3,1) = rect(1,j); tmpLine(3,1) = rect(1,j);
tmpLine(4,1) = rect(2,j); tmpLine(4,1) = rect(2,j);
lines(i) = tmpLine;
//TODO: as array once issue is resolved //TODO: as array once issue is resolved
if i == 1 //if i == 1
lineA = tmpLine; // lineA = tmpLine;
elseif i == 2 // elseif i == 2
lineB = tmpLine; // lineB = tmpLine;
elseif i == 3 // elseif i == 3
lineC = tmpLine; // lineC = tmpLine;
elseif i == 4 // elseif i == 4
lineD = tmpLine; // lineD = tmpLine;
end // end
end end
} }
} }
\ No newline at end of file
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