Skip to content

Commit

Permalink
fix path bugs; don’t send multiple mode commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cadin committed Sep 6, 2023
1 parent 69abc2f commit 1dc4ad1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions AxiControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.cadinbatrack.AxiControl;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -332,7 +332,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.cadinbatrack.AxiControl;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
30 changes: 21 additions & 9 deletions AxiControl/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,22 @@ struct ContentView: View {
showError = true
}

func sendAxiCommand(_ cmd: String, withFile path: String) {
let args = cmd.components(separatedBy: " ")
func getArgsForCommand(_ cmd: String) -> [String]? {
let args = cmd.count > 0 ? cmd.components(separatedBy: " ") : []

var newArgs = args + ["--model", String(modelNumber), "--reordering", String(reorderNumber), "--speed_pendown", String(Int(speed)) ]

if(plotSingleLayer){
if(plotSingleLayer && !newArgs.contains("--mode")){
if let layerNum = Int(singleLayerNum){
if(layerNum > 0 && layerNum <= 1000){
newArgs = newArgs + ["--mode", "layers", "--layer", "\(layerNum)"]
} else {
showLayerError()
return
return nil
}
} else {
showLayerError()
return
return nil
}
}

Expand All @@ -152,7 +152,19 @@ struct ContentView: View {
newArgs = newArgs + ["--hiding"]
}

runAxiCLI(args: [path] + newArgs)
return newArgs
}

func sendAxiCommand(_ cmd: String, withFile path: String, outputPath: String) {
if let args = getArgsForCommand(cmd) {
runAxiCLI(args: [path, "-o", outputPath] + args)
}
}

func sendAxiCommand(_ cmd:String, withFile path: String) {
if let args = getArgsForCommand(cmd) {
runAxiCLI(args: [path] + args)
}
}

func sendAxiCommand(_ cmd: String) {
Expand Down Expand Up @@ -215,7 +227,7 @@ struct ContentView: View {
if let original = originalFileURL {
let outputPath = getNewOutputPath(path: original)
isPlotting = true
sendAxiCommand("-o \(outputPath)", withFile: url.path)
sendAxiCommand("", withFile: url.path, outputPath: outputPath)
}
}
}
Expand All @@ -231,7 +243,7 @@ struct ContentView: View {
let outputPath = getNewOutputPath(path: original)
currentFileURL = URL(string: url)
isPlotting = true
runAxiCLI(args: [url, "--mode", "res_plot", "-o", outputPath])
sendAxiCommand("--mode res_plot", withFile: url, outputPath: outputPath)
}
}

Expand All @@ -240,7 +252,7 @@ struct ContentView: View {
let url = getCurrentOutputPath(path: original)
let outputPath = getNewOutputPath(path: original)
currentFileURL = URL(string: url)
runAxiCLI(args: [url, "--mode", "res_home", "-o", outputPath])
sendAxiCommand("--mode res_home", withFile: url, outputPath: outputPath)
}
}

Expand Down

0 comments on commit 1dc4ad1

Please sign in to comment.