-
Notifications
You must be signed in to change notification settings - Fork 0
/
memscene.go
66 lines (55 loc) · 1.64 KB
/
memscene.go
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
package main
import (
"flag"
"fmt"
"log"
"path/filepath"
"github.com/andrewdjackson/memscene/scenarios"
"github.com/andrewdjackson/memscene/utils"
)
func main() {
var file string
var output string
flag.StringVar(&file, "file", "", "file to convert")
flag.StringVar(&output, "output", "", "destination file")
flag.Parse()
if file == "" {
fmt.Println("Usage of ./memscene:\n -file string\n file to convert\n -output string\n destination file\n")
log.Fatalf("")
}
if output == "" {
_, filename := filepath.Split(file)
output = fmt.Sprintf("%s.output.csv", filename)
}
filetype := utils.GetFileType(file)
utils.LogI.Printf("file identified as '%s' type", filetype)
if filetype == utils.Unknown {
utils.LogE.Fatalf("Unknown file type")
}
scenario := scenarios.NewScenario()
// convert the file and exit
switch filetype {
case utils.ReadMemsFile:
utils.LogI.Printf("converting from readmems file to MemsFCR")
r := scenarios.NewReadMems()
scenario = r.Convert(file)
case utils.MemsRoscoFile:
utils.LogI.Printf("converting from memsrosco file to MemsFCR")
r := scenarios.NewMemsRosco()
scenario = r.Convert(file)
case utils.MemsRoscoFilev2:
utils.LogI.Printf("converting from memsrosco version 2 file to MemsFCR")
r := scenarios.NewMemsRoscoV2()
scenario = r.Convert(file)
case utils.MemsDiagFile:
utils.LogW.Printf("unable to process memsdiag files, not enough data")
case utils.MemsFCRFile:
utils.LogI.Printf("reprocessing MemsFCR file")
r := scenarios.NewMemsFCR()
scenario = r.Convert(file)
}
if scenario.Count > 0 {
save := fmt.Sprintf("%s", output)
scenario.SaveCSVFile(save)
}
}