sdfToRSI

package
v4.38.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Example (CheckMCCDetector)
// The "2A" here is detector B
det, ok, err := checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01732A13  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// A
det, ok, err = checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01732513  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// 0
det, ok, err = checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01730013  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// Invalid detector
det, ok, err = checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01733A13  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// Different line
det, ok, err = checkMCCDetector("00382 : 320A0896  14320032  0A0000C8  32640002  01732A13  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// Words missing
det, ok, err = checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01732A13  FFFF2FFF   FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)

// Word wrong
det, ok, err = checkMCCDetector("00384 : 320A0896  14320032  0A0000C8  32640002  01732A1  FFFF2FFF  00000000  FFFF0000 ")
fmt.Printf("%v|%v|%v\n", det, ok, err)
Output:

B|true|<nil>
A|true|<nil>
0|true|<nil>
|true|Invalid detector: 3A
|false|<nil>
|true|Failed to read detector config
|true|Read invalid word: 01732A1
Example (FindToken)
tok, ok := findToken("2022-302T02:28:56 : 1660 hk fcnt:11869 - FPGAVersion: 0x190425F4 - HK Time: 0x2AEEA3E9 - Power Control: 0x08000408", "HK Time: ", " ")
fmt.Printf("%v|%v\n", ok, tok)

tok, ok = findToken("2022-302T02:28:56 : 1660 hk fcnt:11869 - FPGAVersion: 0x190425F4 - HK Time: 0x2AEEA3E9", "HK Time: ", " ")
fmt.Printf("%v|%v\n", ok, tok)

tok, ok = findToken("HK Time: 0x2AEEA3E9 - Power Control: 0x08000408", "HK Time: ", " ")
fmt.Printf("%v|%v\n", ok, tok)

tok, ok = findToken("2022-302T02:28:56 : 1660 hk fcnt:11869 - FPGAVersion: 0x190425F4 - HK Ti me: 0x2AEEA3E9 - Power Control: 0x08000408", "HK Time: ", " ")
fmt.Printf("%v|%v\n", ok, tok)

tok, ok = findToken("2022-302T02:28:56 : 1660 hk fcnt:11869 - FPGAVersion: 0x190425F4 - HK Time: 0x2AEEA3E9 - Power Control: 0x08000408", " - FPGAVersion: ", "F4")
fmt.Printf("%v|%v\n", ok, tok)
Output:

true|0x2AEEA3E9
true|0x2AEEA3E9
true|0x2AEEA3E9
false|
true|0x190425
Example (MakeWriteSCLK)
fmt.Println(makeWriteSCLK( /*208601602,*/ "2022-301T14:31:18"))
Output:

2AEDFBB7
Example (ProcessCentroidLine1)
sliNum, x, y, intensity, err := processCentroidLine1(7, "", "3 -- pixel x,y,intensity: [0x7ab6fdcf] [0x37d1f047] [0x03f1] |     411.7626     187.3011")
fmt.Printf("%v,%v,%v,%v,%v\n", sliNum, x, y, intensity, err)
Output:

3,411.7626,187.3011,1009,<nil>
Example (ProcessCentroidLine2)
x, y, z, err := processCentroidLine2(7, "2022-301T17:28:38 :    2 CenSLI_struct  0 -- position x,y,z: [0xffffdbb9] [0xffffc999] [0x0000e8e3]  |    -0.009287    -0.013927     0.059619", 0)
fmt.Printf("%v,%v,%v,%v\n", x, y, z, err)
Output:

-0.009287,-0.013927,0.059619,<nil>
Example (ProcessCentroidLine3)
id, res, err := processCentroidLine3(7, "2022-301T17:28:38 :    2 CenSLI_struct  0 -- ID: 0x4a, Residual: 0x03", 0)
fmt.Printf("%v,%v,%v\n", id, res, err)
Output:

74,3,<nil>
Example (ReadFloat)
f, r, e := readFloat("-0.12470774    0.15369324    0.24655464        ")
fmt.Printf("%v|%v|%v\n", f, e, strings.TrimRight(r, " "))

f, r, e = readFloat("2.L3    0.15369324    0.24655464        ")
fmt.Printf("%v|%v|%v\n", f, e, r)
Output:

-0.12470774|<nil>|0.15369324    0.24655464
0|Error: strconv.ParseFloat: parsing "2.L3": invalid syntax|0.15369324    0.24655464
Example (ReadIntBetween)
v, f, pos, err := readNumBetween("Features Count: Reference: 266  -- Current: 283  -- Matches: 149 --  Residual:   3", "Residual:", " ", read_int)
fmt.Printf("%v|%v|%v|%v\n", v, f, pos, err)

v, f, pos, err = readNumBetween("Features Count: Reference: 266  -- Current: 283  -- Matches: 149 --  Residual:   3", "Current: ", " ", read_int)
fmt.Printf("%v|%v|%v|%v\n", v, f, pos, err)

v, f, pos, err = readNumBetween("The Reference: 0x00A3 -- Sclk: 15:42:17   ---> Flags: 0x300E", "Reference: 0x", " ", read_int)
fmt.Printf("%v|%v|%v|%v\n", v, f, pos, err)

v, f, pos, err = readNumBetween("The Reference: 0x00A3 -- Sclk: 15:42:17   ---> Flags: 0x300E", "Reference: 0x", " ", read_int_hex)
fmt.Printf("%v|%v|%v|%v\n", v, f, pos, err)

v, f, pos, err = readNumBetween("VPS -           HVMON:  27.84 Kv |   5 volt pos:   5.00 V |        SDF Retry:     0", "HVMON:", " ", read_float)
fmt.Printf("%v|%v|%v|%v\n", v, f, pos, err)
Output:

3|0|79|<nil>
283|0|47|<nil>
0|0|0|failed to read int value after 'Reference: 0x'
163|0|21|<nil>
0|27.84|27|<nil>
Example (ScanSDF)
ensureSDFRawExists()

refs, err := scanSDF("./test-data/BadPath.txt")
fmt.Printf("%v|%v\n", len(refs), err)

refs, err = scanSDF("./test-data/sdf_raw.txt")
fmt.Printf("err: %v\n", err)
for _, ref := range refs {
	fmt.Printf("%d: %v: '%v'\n", ref.Line, ref.What, ref.Value)
}
Output:

0|open ./test-data/BadPath.txt: The system cannot find the file specified.
err: <nil>
439: start: ''
464: first-time: '2022-301T13:50:28'
6213: dust-cover: 'opening'
6647: dust-cover: 'opened'
9970: dust-cover: 'closing'
10155: dust-cover: 'closed'
13182: dust-cover: 'opening'
13308: dust-cover: 'opened'
17361: new-rtt: '0C6E0204'
19140: science: 'begin'
19358: sci-place: 'Initialize"'
19362: sci-place: 'Move to Crouch"'
20073: sci-place: 'Perform OFS Eval"'
21009: new-rtt: '0C6E0205'
21223: sci-place: 'Move to Focus"'
23322: sci-place: 'Pre Scan"'
25039: sci-place: 'Perform Scan"'
56876: sci-place: 'Post Scan"'
59907: science: 'end'
68018: new-rtt: '0C6F0201'
70049: science: 'begin'
70312: sci-place: 'Initialize"'
70316: sci-place: 'Move to Crouch"'
71984: sci-place: 'Perform OFS Eval"'
72524: new-rtt: '0C6F0202'
72766: sci-place: 'Move to Focus"'
76051: sci-place: 'Pre Scan"'
77735: sci-place: 'Perform Scan"'
271793: sci-place: 'Post Scan"'
276000: science: 'end'
Example (TakeToken)
tok, l, ok := takeToken("gv - 0x00dd40 : 00000000 00000000 00000000 00000000 ::             0             0             0             0 ", " -")
fmt.Printf("%v|%v|%v\n", tok, l, ok)
tok, l, ok = takeToken("gv - 0x00dd40 : 00000000 00000000 00000000 00000000 ::             0             0             0             0 ", " ")
fmt.Printf("%v|%v|%v\n", tok, l, ok)

tok, l, ok = takeToken(" 0x00dd40 : 00000000 00000000 00000000 00000000", " ")
fmt.Printf("%v|%v|%v\n", tok, l, ok)

tok, l, ok = takeToken(strings.TrimLeft(" 0x00dd40 : 00000000 00000000 00000000 00000000", " "), " ")
fmt.Printf("%v|%v|%v\n", tok, l, ok)

tok, l, ok = takeToken("abc", "b")
fmt.Printf("%v|%v|%v\n", tok, l, ok)

tok, l, ok = takeToken("abc", "a")
fmt.Printf("%v|%v|%v\n", tok, l, ok)

tok, l, ok = takeToken("a", "a")
fmt.Printf("%v|%v|%v\n", tok, l, ok)
Output:

gv|0x00dd40 : 00000000 00000000 00000000 00000000 ::             0             0             0             0 |true
gv|- 0x00dd40 : 00000000 00000000 00000000 00000000 ::             0             0             0             0 |true
0x00dd40|: 00000000 00000000 00000000 00000000|true
0x00dd40|: 00000000 00000000 00000000 00000000|true
a|c|true
bc||true
||false

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertSDFtoRSIs

func ConvertSDFtoRSIs(sdfPath string, outPath string) ([]string, []int64, error)

Given an SDF path and an output path, this generates RSI files for each scan mentioned in the SDF. Returns the file names generated and an error if any

Types

type EventEntry

type EventEntry struct {
	Line  int
	What  string
	Value string
}

Returns a map of RTTs, with the line they are found

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL