-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,471 additions
and
2,834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.bin filter=lfs diff=lfs merge=lfs -text | ||
*.csv filter=lfs diff=lfs merge=lfs -text | ||
*.obj filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 42 additions & 33 deletions
75
backend/src/main/java/com/mcmasterbaja/analyzer/AccelCurveAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 30 additions & 78 deletions
108
backend/src/main/java/com/mcmasterbaja/analyzer/AnalyzerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,40 @@ | ||
package com.mcmasterbaja.analyzer; | ||
|
||
import com.mcmasterbaja.model.AnalyzerParams; | ||
|
||
import com.mcmasterbaja.model.AnalyzerType; | ||
import jakarta.annotation.PostConstruct; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Any; | ||
import jakarta.enterprise.inject.Instance; | ||
import jakarta.inject.Inject; | ||
import java.util.EnumMap; | ||
import java.util.Map; | ||
import org.jboss.logging.Logger; | ||
|
||
@ApplicationScoped | ||
public class AnalyzerFactory { | ||
@Inject Logger logger; | ||
|
||
public static Analyzer createAnalyzer(AnalyzerParams params) { | ||
|
||
String[] inputFiles = params.getInputFiles(); | ||
String[] inputColumns = params.getInputColumns(); | ||
String[] outputFiles = params.getOutputFiles(); | ||
Object[] options = params.getOptions(); | ||
|
||
switch (params.getType()) { | ||
case ACCEL_CURVE: | ||
return new AccelCurveAnalyzer(inputFiles, inputColumns, outputFiles); | ||
|
||
case ROLL_AVG: | ||
if (options.length == 0) { | ||
return new RollingAvgAnalyzer(inputFiles, inputColumns, outputFiles); | ||
} | ||
int windowSize = Integer.parseInt((String) options[0]); | ||
return new RollingAvgAnalyzer(inputFiles, inputColumns, outputFiles, windowSize); | ||
|
||
case SGOLAY: | ||
// Check if passed a window size | ||
if (options.length == 0) { | ||
return new SGolayFilter(inputFiles, inputColumns, outputFiles); | ||
} | ||
windowSize = Integer.parseInt((String) options[0]); | ||
int polynomialDegree = Integer.parseInt((String) options[1]); | ||
return new SGolayFilter( | ||
inputFiles, inputColumns, outputFiles, windowSize, polynomialDegree); | ||
|
||
case RDP_COMPRESSION: | ||
if (options.length == 0) { | ||
return new RDPCompressionAnalyzer(inputFiles, inputColumns, outputFiles, 15); | ||
} | ||
double epsilon = Double.parseDouble((String) options[0]); | ||
return new RDPCompressionAnalyzer(inputFiles, inputColumns, outputFiles, epsilon); | ||
@Inject @Any Instance<Analyzer> analyzers; | ||
|
||
case SPLIT: | ||
System.out.println("SplitAnalyzer"); | ||
if (options[1] == "" || options[0] == "") { | ||
return null; | ||
} | ||
int start = Integer.parseInt((String) options[0]); | ||
int end = Integer.parseInt((String) options[1]); | ||
return new SplitAnalyzer(inputFiles, inputColumns, outputFiles, start, end); | ||
private Map<AnalyzerType, Analyzer> analyzerMap; | ||
|
||
case LINEAR_MULTIPLY: | ||
if (options[1] == "" || options[0] == "") { | ||
return null; | ||
} | ||
double m = Double.parseDouble((String) options[0]); | ||
double b = Double.parseDouble((String) options[1]); | ||
return new LinearMultiplyAnalyzer(inputFiles, inputColumns, outputFiles, m, b); | ||
|
||
case CONSTANT_ADDER: | ||
if (options[3] == "" || options[2] == "" || options[1] == "" || options[0] == "") { | ||
return null; | ||
} | ||
double a1 = Double.parseDouble((String) options[0]); | ||
double b2 = Double.parseDouble((String) options[1]); | ||
double c1 = Double.parseDouble((String) options[2]); | ||
double d1 = Double.parseDouble((String) options[3]); | ||
return new ConstantAdderAnalyzer(inputFiles, inputColumns, outputFiles, a1, b2, c1, d1); | ||
|
||
case AVERAGE: | ||
int[] range = new int[2]; | ||
range[0] = Integer.parseInt((String) options[0]); | ||
range[1] = Integer.parseInt((String) options[1]); | ||
return new AverageAnalyzer(inputFiles, outputFiles, range); | ||
|
||
case INTERPOLATER_PRO: | ||
return new InterpolaterProAnalyzer(inputFiles, inputColumns, outputFiles); | ||
@PostConstruct | ||
public void init() { | ||
analyzerMap = new EnumMap<>(AnalyzerType.class); | ||
for (Analyzer analyzer : analyzers) { | ||
AnalyzerQualifier qualifier = analyzer.getClass().getAnnotation(AnalyzerQualifier.class); | ||
if (qualifier != null) { | ||
analyzerMap.put(qualifier.value(), analyzer); | ||
} | ||
} | ||
} | ||
|
||
case CUBIC: | ||
double a = Double.parseDouble((String) options[0]); | ||
double b1 = Double.parseDouble((String) options[1]); | ||
double c = Double.parseDouble((String) options[2]); | ||
double d = Double.parseDouble((String) options[3]); | ||
return new CubicAnalyzer(inputFiles, inputColumns, outputFiles, a, b1, c, d); | ||
default: | ||
return null; | ||
public Analyzer getAnalyzer(AnalyzerType type) { | ||
Analyzer analyzer = analyzerMap.get(type); | ||
if (analyzer == null) { | ||
logger.errorf("No Analyzer found for type: %s", type); | ||
throw new IllegalArgumentException("No Analyzer found for type: " + type); | ||
} | ||
return analyzer; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/com/mcmasterbaja/analyzer/AnalyzerQualifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mcmasterbaja.analyzer; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import com.mcmasterbaja.model.AnalyzerType; | ||
import jakarta.inject.Qualifier; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
@Qualifier | ||
@Retention(RUNTIME) | ||
@Target({TYPE, METHOD, FIELD, PARAMETER}) | ||
public @interface AnalyzerQualifier { | ||
AnalyzerType value(); | ||
} |
Oops, something went wrong.