Skip to content

Commit

Permalink
Merge pull request #356 from pixlise/feature/em-import
Browse files Browse the repository at this point in the history
Generate HK file with sclk as int
  • Loading branch information
pnemere authored Nov 11, 2024
2 parents 78abcbe + 1e2c76c commit 8d485d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/dataimport/sdfToRSI/readHousekeeping.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func processHousekeeping(lineNo int, lineData string, lines []string, sclk strin
// SCLK,PMC,hk_fcnt,f_pixl_sdd_1_conv,f_pixl_sdd_2_conv,f_pixl_arm_resist_conv,f_head_sdd_1_conv,f_head_sdd_2_conv,f_hvps_fvmon_conv,f_hvps_fimon_conv,f_hvps_hvmon_conv,f_hvps_himon_conv,i_motor_1_conv,i_motor_2_conv,i_motor_3_conv,i_motor_4_conv,i_motor_5_conv,i_motor_6_conv

hk2 := fmt.Sprintf("%v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v\n",
makeWriteSCLK(sclk), pmc, fcnt, fVal[1], fVal[0], fVal[2], fVal[3], fVal[4], fVal[5], fVal[6], fVal[7], fVal[8],
makeWriteSCLInt(sclk), pmc, fcnt, fVal[1], fVal[0], fVal[2], fVal[3], fVal[4], fVal[5], fVal[6], fVal[7], fVal[8],
motorPos[0], motorPos[1], motorPos[2], motorPos[3], motorPos[4], motorPos[5])

return hktime, hk, hk2, nil
Expand Down
8 changes: 7 additions & 1 deletion api/dataimport/sdfToRSI/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,20 @@ func readNumBetween(line string, prefix string, suffix string, readType int) (in
return val, 0, lastPos, nil
}

func makeWriteSCLK(readSCLK string) string {
func makeWriteSCLInt(readSCLK string) int64 {
unixSec := readTimestamp(readSCLK)

// Work out where we are relative to the epoch above, and add to it to work out SCLK to use
secSinceEpoch := unixSec - 1666967479

sclk := 720239544 + secSinceEpoch

return sclk
}

func makeWriteSCLK(readSCLK string) string {
sclk := makeWriteSCLInt(readSCLK)

// Return as hex
return fmt.Sprintf("%X", sclk)
}
Expand Down

0 comments on commit 8d485d0

Please sign in to comment.