Compare commits

..

No commits in common. 'e538d497f629cfa623d56472685c626588ba1cce' and '8e78307efccb255f9a83b1b215ea813f63373e2f' have entirely different histories.

  1. 9
      model/device.go
  2. 36
      parser/devicePrsInternal.go

9
model/device.go

@ -60,13 +60,6 @@ const (
CMD_RUP_GARMD_RESP = 131
CMD_RUP_CONN_PARM = 105
CMD_RUP_ODO = 106
// add
CMD_RUP_FUEL_LEVEL = 205
CMD_RUP_ENGINE_SPEED = 197
CMD_RUP_HIGH_RESOL_ENGINE_TOTAL_FUEL_USED = 92
CMD_RUP_HIGH_RESOL_TOTAL_VEHICLE_DISTANCE = 114
CMD_FUEL_LEVEL1 = 207
)
// Device and standard Tag type
@ -178,7 +171,7 @@ type Parser interface {
Payload() []byte
GetError() error
GetCommand() byte
// GetRecords() *DeviceRecords
// GetRecords() *DeviceRecords
GetIMEI() uint64
GetClientResponse() []byte
ExecuteAsync()

36
parser/devicePrsInternal.go

@ -9,7 +9,6 @@ import (
"encoding/binary"
"fmt"
"time"
"math"
//"encoding/hex"
"strconv"
"sort"
@ -18,10 +17,6 @@ import (
"../model"
)
const (
ALLOWED_TIME_MINUTES = -5
)
type ruptelaTchHeader struct {
Length uint16
IMEI uint64
@ -224,12 +219,9 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
ioVal := convBinaryToUint16(addOneByteInTwoByte(data[currByte:plusByte]),2,"io1Val")
//fmt.Printf("io1Val %d\n",ioVal)
strVal := fmt.Sprintf("%v",int16(ioVal))
//fmt.Printf("strVal %v\n",strVal)
tagDevice_ := tags_[strconv.Itoa(int(ioID))]
tagDevice_.TagId = strconv.Itoa(int(ioID))
tagDevice_.TagVal = strVal
tagDevice_.TagVal = strconv.Itoa(int(ioVal))
if tagDevice_.TagName != ""{
//tags_[strconv.Itoa(int(ioID))] = tagDevice_
tags_[tagDevice_.TagName] = tagDevice_
@ -256,14 +248,10 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
currByte = plusByte
plusByte = currByte + 2
ioVal := convBinaryToUint16(data[currByte:plusByte],2,"io2Val")
// fmt.Printf("io2Val %d\n",ioVal)
// fmt.Printf("io2Val INT %d\n",int16(ioVal))
strVal := fmt.Sprintf("%v",int16(ioVal))
//fmt.Printf("strVal %v\n",strVal)
//fmt.Printf("io2Val %d\n",ioVal)
tagDevice_ := tags_[strconv.Itoa(int(ioID))]
tagDevice_.TagVal = strVal
tagDevice_.TagVal = strconv.Itoa(int(ioVal))
if tagDevice_.TagName != ""{
tags_[tagDevice_.TagName] = tagDevice_
}
@ -289,11 +277,8 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
ioVal := convBinaryToInt32(data[currByte:plusByte],4,"io4Val")
//fmt.Printf("io4Val %d\n",ioVal)
strVal := fmt.Sprintf("%v",int32(ioVal))
//fmt.Printf("strVal %v\n",strVal)
tagDevice_ := tags_[strconv.Itoa(int(ioID))]
tagDevice_.TagVal = strVal
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10)
if tagDevice_.TagName != ""{
tags_[tagDevice_.TagName] = tagDevice_
}
@ -319,11 +304,8 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
ioVal := convBinaryToInt64(data[currByte:plusByte],8,"io8Val")
//fmt.Printf("io8Val %d\n",ioVal)
strVal := fmt.Sprintf("%v",int64(ioVal))
//fmt.Printf("strVal %v\n",strVal)
tagDevice_ := tags_[strconv.Itoa(int(ioID))]
tagDevice_.TagVal = strVal
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10)
if tagDevice_.TagName != ""{
tags_[tagDevice_.TagName] = tagDevice_
}
@ -338,18 +320,10 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
}
deviceRecord.TagDevices = tags_
tstampToNow := time.Since(deviceRecord.Tstamp)
hCurr := math.Round(tstampToNow.Minutes()*100)/100
if hCurr >= ALLOWED_TIME_MINUTES {
deviceRecords = append(deviceRecords, deviceRecord)
}
}
rec.NumRec = uint16(len(deviceRecords))
//sort ascending by date
sort.Sort(ByTstamp(deviceRecords))

Loading…
Cancel
Save