Skip to content
Snippets Groups Projects
Commit e87d2d8d authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

Clean up existing functions.

parent 4ec8a495
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,6 @@ func main() {
fmt.Printf("CPS: %d\n", cps)
fmt.Printf("Version: %s\n", gc.Version())
fmt.Printf("Short Version: %s\n", gc.Ver())
fmt.Printf("Model: %s\n", gc.Model())
ser, err = gc.SerialNum()
......
......@@ -23,7 +23,6 @@ type Counter interface {
Clear() error
Model() string
Version() string
Ver() string
SerialNum() (string, error)
GetCPM() (uint16, error)
GetCPS() (uint16, error)
......@@ -35,7 +34,6 @@ type Counter interface {
TurnOffPower()
GetConfiguration()
SetConfiguration()
ResetConfiguration()
SetTime(time.Time)
GetTime() (time.Time, error)
FactoryReset()
......
......@@ -22,84 +22,6 @@ const (
VoltageTooLow = 75
)
const (
powerOnOff = 0
alarmOnOff = 1
speakerOnOff = 2
graphicModeOnOff = 3
backlightTimeoutSeconds = 4
idleTitleDisplayMode = 5
alarmCPMValue = 6
calibrationCPM0 = 8
calibrationSvUc0 = 10
calibrationCPM1 = 14
calibrationSvUc1 = 16
calibrationCPM2 = 20
calibrationSvUc2 = 22
idleDisplayMode = 26
alarmValueuSvUc = 27
alarmType = 31
saveDataType = 32
swivelDisplay = 33
zoom = 34
dataSaveAddress = 38
dataReadAddress = 41
nPowerSavingMode = 44
nSensitivityMode = 45
nCounterDelay = 46
nVoltageOffset = 48
maxCPM = 49
nSensitivityAutoModeThreshold = 51
saveDate = 52
saveTime = 55
maxBytes = 58
)
var configBytes = map[int]int{
powerOnOff: 1,
alarmOnOff: 1,
speakerOnOff: 1,
graphicModeOnOff: 1,
backlightTimeoutSeconds: 1,
idleTitleDisplayMode: 1,
alarmCPMValue: 2,
calibrationCPM0: 2,
calibrationSvUc0: 4,
calibrationCPM1: 2,
calibrationSvUc1: 4,
calibrationCPM2: 2,
calibrationSvUc2: 4,
idleDisplayMode: 1,
alarmValueuSvUc: 4,
alarmType: 1,
saveDataType: 1,
swivelDisplay: 1,
zoom: 4,
dataSaveAddress: 3,
dataReadAddress: 3,
nPowerSavingMode: 1,
nSensitivityMode: 1,
nCounterDelay: 2,
nVoltageOffset: 1,
maxCPM: 2,
nSensitivityAutoModeThreshold: 1,
saveDate: 3,
saveTime: 3,
maxBytes: 1,
}
const (
saveOff = iota
saveCPS
saveCPM
saveCPH
saveMax
)
const (
nvmSize = 256
)
const (
cmdGetSerial = "<GETSERIAL>>" // GMC-280, GMC-300 Re.2.11
cmdGetVersion = "<GETVER>>" // GMC-280, GMC-300 Re.2.0x, Re.2.10
......@@ -125,7 +47,6 @@ type GQGMCCounter struct {
port *serial.Port
config *serial.Config
version,
shortVer,
model string
}
......@@ -147,7 +68,6 @@ func NewGQGMC(c Config) (*GQGMCCounter, error) {
v, err = gc.communicate(cmdGetVersion, 14)
gc.model = string(v[:7])
gc.version = string(v[7:])
gc.shortVer = string(v[10:])
//getConfigurationData()
return &gc, nil
}
......@@ -169,11 +89,6 @@ func (gc *GQGMCCounter) Version() string {
return gc.version
}
// Ver gets the short version of the device
func (gc *GQGMCCounter) Ver() string {
return gc.shortVer
}
// Model gets the model of the device
func (gc *GQGMCCounter) Model() string {
return gc.model
......@@ -238,19 +153,6 @@ func (gc *GQGMCCounter) GetHistoryData() {
// TurnOnCPS turns on CPS collection
func (gc *GQGMCCounter) TurnOnCPS() error {
// turnOnCPS is public method to enable automatic reporting of the
// count per second (CPS) value. First, I would say don't use this
// command. Since the returned data has no protocol, that is, there
// is no start/stop marker, no identification, no nothing but a
// sequence of bytes, any other command issued while CPS is turned on
// will take extraordinary effort not to confuse its returned data
// with the CPS data. To handle it correctly, you would have to
// wait for the CPS data to be returned, and then issue the command.
// This would be most safely done by creating a new thread to
// read the CPS and using a mutex to signal opportunity to issue a
// separate command. The command is turn_on_cps_cmd
// (see GQ GMC COMMANDS above). The returned data is always two
// bytes so that samples > 255 can be reported (even though unlikely).
gc.sendCmd(cmdTurnOnCPS)
return nil
}
......@@ -287,8 +189,11 @@ func (gc *GQGMCCounter) TurnOffPower() {
// GetConfiguration reads configuration data
func (gc *GQGMCCounter) GetConfiguration() {
// Issue command to get configuration and read returned data.
// communicate(get_cfg_cmd, reinterpret_cast<char *>(&mCFG_Data),
cfg, err := gc.communicate(cmdGetCfg, 256)
if err != nil {
return
}
fmt.Printf("%+v\n", cfg)
}
// SetConfiguration writes configuration data
......@@ -296,13 +201,6 @@ func (gc *GQGMCCounter) SetConfiguration() {
// See the ConfigurationData functions in gqgmc.cc
}
// ResetConfiguration resets to factory default
func (gc *GQGMCCounter) ResetConfiguration() {
//uint32_t retsize = 1;
//char ret_char[retsize+1];
//communicate(erase_cfg_cmd, ret_char, retsize);
}
// SetTime sets the time
func (gc *GQGMCCounter) SetTime(t time.Time) {
//command: <SETDATETIME[YYMMDDHHMMSS]>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment