IsConnected logic
This commit is contained in:
+16
-1
@@ -20,7 +20,6 @@ const (
|
|||||||
IRSDK_BROADCASTMSGNAME string = "IRSDK_BROADCASTMSG"
|
IRSDK_BROADCASTMSGNAME string = "IRSDK_BROADCASTMSG"
|
||||||
fileMapSize uint32 = 1164 * 1024
|
fileMapSize uint32 = 1164 * 1024
|
||||||
connTimeout int64 = 30
|
connTimeout int64 = 30
|
||||||
stConnected int = 1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -117,6 +116,22 @@ const (
|
|||||||
csFocusAtDriver int = 0 // ctFocusAtDriver + car number...
|
csFocusAtDriver int = 0 // ctFocusAtDriver + car number...
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// StatusField - START
|
||||||
|
const (
|
||||||
|
irsdk_stConnected = 0x01
|
||||||
|
)
|
||||||
|
|
||||||
|
func (i *IBT) SessionStatusConnected() bool {
|
||||||
|
return i.Headers.Status == irsdk_stConnected
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: move this away from here
|
||||||
|
// func (i *IBT) SessionTimedOut() bool {
|
||||||
|
// return sdk.lastValidData+connTimeout > time.Now().Unix()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// StatusField - END
|
||||||
|
|
||||||
// Camera positions
|
// Camera positions
|
||||||
type bitfieldValue struct {
|
type bitfieldValue struct {
|
||||||
Value int
|
Value int
|
||||||
|
|||||||
@@ -59,16 +59,19 @@ type IBT struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *IBT) IsConnected() bool {
|
func (i *IBT) IsConnected() bool {
|
||||||
if i.Headers != nil {
|
if i.Headers == nil {
|
||||||
if sessionStatusOK(int(i.Headers.Status)) {
|
return false
|
||||||
return true
|
|
||||||
}
|
|
||||||
// if sessionStatusOK(int(i.Headers.Status)) && (sdk.lastValidData+connTimeout > time.Now().Unix()) {
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
if !i.SessionStatusConnected() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if i.SessionStateInvalid() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IBT) exportYAML() error {
|
func (i *IBT) exportYAML() error {
|
||||||
|
|||||||
@@ -370,11 +370,6 @@ func parseSessionInfo(buf []byte, len int32) (*SessionInfoYAML, error) {
|
|||||||
return &sessionInfo, nil
|
return &sessionInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionStatusOK will tell us if we are connected to the live data
|
|
||||||
func sessionStatusOK(status int) bool {
|
|
||||||
return (status & stConnected) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// ToString will return a readable string of the struct
|
// ToString will return a readable string of the struct
|
||||||
func (s *SessionInfoYAML) ToString() string {
|
func (s *SessionInfoYAML) ToString() string {
|
||||||
stringified, _ := json.MarshalIndent(s, "", " ")
|
stringified, _ := json.MarshalIndent(s, "", " ")
|
||||||
|
|||||||
Reference in New Issue
Block a user