-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
91 lines (81 loc) · 1.8 KB
/
Program.cs
File metadata and controls
91 lines (81 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GCodeAdjust
{
class Program
{
static void Main(string[] args)
{
bool showInfo;
decimal diffX, diffY, diffZ;
// parse args
ParseArgs(
args,
out showInfo,
out diffX,
out diffY,
out diffZ);
string input = string.Empty;
if(!showInfo)
{
#if !DEBUG
input = Console.In.ReadToEnd();
#else
input = @"
;G1 X0a
; G1 X0b
G1 E0
G1 X0
G1 Y0
G1 Z0
G1 X0 Y0
G1 X0 Z0
G1 Y0 Z0
G1 X0 Y0 Z0
G1 E0
G1 X0 E0
G1 Y0 E0
G1 Z0 E0
G1 X0 Y0 E0
G1 X0 Z0 E0
G1 Y0 Z0 E0
G1 X0 Y0 Z0 E0";
#endif
showInfo = input.Length < 1;
}
// display info, or start worker
if (showInfo)
{
Console.Error.WriteLine(
"GCodeAdjust [diffx] [diffy] [diffz]");
}
else
{
Console.Out.WriteLine(
new Worker(input)
.Adjust(
diffX,
diffY,
diffZ));
}
}
private static void ParseArgs(
string[] args,
out bool showInfo,
out decimal diffX,
out decimal diffY,
out decimal diffZ)
{
diffX = diffY = diffZ = 0M;
showInfo = args.Length < 1
|| args[0] == "/?";
if (showInfo)
return;
diffX = decimal.Parse(args[0]);
diffY = decimal.Parse(args[1]);
diffZ = decimal.Parse(args[2]);
}
}
}