Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feeder-event-to-server solution #43

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions client/client-1.0/Javascript/appclient_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Metadata request:
{"action":"get","path":"Vehicle/ADAS","filter":[{"type":"paths","parameter":["ABS/*","CruiseControl/Error"]},{"type":"dynamic-metadata","parameter":"availability"}],"requestId":"237"}

Set request:
{"action":"set", "path":"Vehicle/Cabin/Door/Row1/Right/IsOpen", "value":"999", "requestId":"245"}
{"action":"set", "path":"Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen", "value":"999", "requestId":"245"}

Subscribe request:
{"action":"subscribe","path":"Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen","filter":{"type":"timebased","parameter":{"period":"3000"}},"requestId":"246"}
{"action":"subscribe","path":"Vehicle.Cabin.Door.Row1.Right.IsOpen","filter":{"type":"change","parameter":{"logic-op":"ne", "diff":"0"}},"requestId":"247"}
{"action":"subscribe","path":"Vehicle/Cabin/Door/Row1/Right/IsOpen","filter":{"type":"range","parameter":{"logic-op":"gt","boundary":"500"}},"requestId":"255"}
{"action":"subscribe","path":"Vehicle/Cabin/Door/Row1/Right/IsOpen","filter":{"type":"range","parameter":[{"logic-op":"gt","boundary":"500"},{"logic-op":"lt","boundary":"510"}]},"requestId":"265"}
{"action":"subscribe","path":"Vehicle.Cabin.Door.Row1.PassengerSide.IsOpen","filter":{"type":"change","parameter":{"logic-op":"ne", "diff":"0"}},"requestId":"247"}
{"action":"subscribe","path":"Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen","filter":{"type":"range","parameter":{"logic-op":"gt","boundary":"500"}},"requestId":"255"}
{"action":"subscribe","path":"Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen","filter":{"type":"range","parameter":[{"logic-op":"gt","boundary":"500"},{"logic-op":"lt","boundary":"510"}]},"requestId":"265"}
{"action":"subscribe","path":"Vehicle.Powertrain.Transmission.Speed","filter":{"type":"curvelog","parameter":{"maxerr":"2","bufsize":"100"}},"requestId":"275"}
{"action":"subscribe","path":"Vehicle","filter":[{"type":"paths","parameter":["CurrentLocation.Latitude", "CurrentLocation.Longitude"]}, {"type":"curvelog","parameter":{"maxerr":"0.00001","bufsize":"100"}}],"requestId":"285"}

Expand All @@ -48,7 +48,7 @@ Unsubscribe request:

Get request:
HTTP GET
URL: Vehicle/Cabin/Door/Row1/Right/IsOpen
URL: Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen
URL: Vehicle.Acceleration.Longitudinal

Get request with search:
Expand Down Expand Up @@ -90,6 +90,6 @@ wsclient_uncompressed.html:
// where "at" is the Access Token from ATS request

http_client.html:
URL: Vehicle/Cabin/Door/Row1/Right/IsOpen
URL: Vehicle/Cabin/Door/Row1/PassengerSide/IsOpen
Access token: from at-request response

34 changes: 20 additions & 14 deletions feeder/feeder-template/feederv2/feederv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ func initVSSInterfaceMgr(inputChan chan DomainData, outputChan chan DomainData)
for {
select {
case outData := <-outputChan:
utils.Info.Printf("Data written to statestorage: Name=%s, Value=%s", outData.Name, outData.Value)
// utils.Info.Printf("Data written to statestorage: Name=%s, Value=%s", outData.Name, outData.Value)
if len(outData.Name) == 0 {
continue
}
status := statestorageSet(outData.Name, outData.Value, utils.GetRfcTime())
if status != 0 {
utils.Error.Printf("initVSSInterfaceMgr():Redis write failed")
Expand Down Expand Up @@ -209,8 +212,8 @@ func statestorageSet(path string, val string, ts string) int {
}

func initUdsEndpoint(udsChan chan DomainData) {
os.Remove("/var/tmp/vissv2/server-feeder-channel.sock")
listener, err := net.Listen("unix", "/var/tmp/vissv2/server-feeder-channel.sock") //the file must be the same as declared in the feeder-registration.json that the service mgr reads
os.Remove("/var/tmp/vissv2/serverFeeder.sock")
listener, err := net.Listen("unix", "/var/tmp/vissv2/serverFeeder.sock") //the file must be the same as declared in the feeder-registration.json that the service mgr reads
if err != nil {
utils.Error.Printf("initUdsEndpoint:UDS listen failed, err = %s", err)
os.Exit(-1)
Expand All @@ -229,19 +232,21 @@ func initUdsEndpoint(udsChan chan DomainData) {
continue
}
utils.Info.Printf("Feeder:Server message: %s", string(buf[:n]))
domainData, _ := splitToDomainDataAndTs(string(buf[:n]))
udsChan <- domainData
var serverMessageMap map[string]interface{}
err = json.Unmarshal(buf[:n], &serverMessageMap)
if err != nil {
utils.Error.Printf("splitToDomainDataAndTs:Unmarshal error=%s", err)
continue
}
if serverMessageMap["action"] != nil && serverMessageMap["action"].(string) == "set" {
domainData, _ := splitToDomainDataAndTs(serverMessageMap["data"].(map[string]interface{}))
udsChan <- domainData
}
}
}

func splitToDomainDataAndTs(serverMessage string) (DomainData, string) { // server={"dp": {"ts": "Z","value": "Y"},"path": "X"}, redis={"value":"xxx", "ts":"zzz"}
func splitToDomainDataAndTs(serverMessageMap map[string]interface{}) (DomainData, string) { // server={"dp": {"ts": "Z","value": "Y"},"path": "X"}, redis={"value":"xxx", "ts":"zzz"}
var domainData DomainData
var serverMessageMap map[string]interface{}
err := json.Unmarshal([]byte(serverMessage), &serverMessageMap)
if err != nil {
utils.Error.Printf("splitToDomainDataAndTs:Unmarshal error=%s", err)
return domainData, ""
}
domainData.Name = serverMessageMap["path"].(string)
dpMap := serverMessageMap["dp"].(map[string]interface{})
domainData.Value = dpMap["value"].(string)
Expand Down Expand Up @@ -319,7 +324,7 @@ func selectRandomInput(fMap []FeederMap) DomainData {
} else {
domainData.Value = strconv.Itoa(rand.Intn(1000))
}
utils.Info.Printf("Simulated data from Vehicle interface: Name=%s, Value=%s", domainData.Name, domainData.Value)
// utils.Info.Printf("Simulated data from Vehicle interface: Name=%s, Value=%s", domainData.Name, domainData.Value)
return domainData
}

Expand Down Expand Up @@ -370,7 +375,8 @@ func convertDomainData(north2SouthConv bool, inData DomainData, feederMap []Feed
var outData DomainData
matchIndex := sort.Search(len(feederMap), func(i int) bool { return feederMap[i].Name >= inData.Name })
if matchIndex == len(feederMap) || feederMap[matchIndex].Name != inData.Name {
matchIndex = -1
utils.Error.Printf("convertDomainData:Failed to map= %s", inData.Name)
return outData
}
outData.Name = feederMap[feederMap[matchIndex].MapIndex].Name
outData.Value = convertValue(inData.Value, feederMap[matchIndex].ConvertIndex,
Expand Down
Binary file added feeder/feeder-template/feederv3/VssVehicle.cvt
Binary file not shown.
2 changes: 2 additions & 0 deletions feeder/feeder-template/feederv3/VssVehicleScaling.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
"{\"false\":\"0\", \"true\":\"1\"}","{\"UNDEFINED\":\"0\", \"LOCK\":\"1\", \"OFF\":\"2\", \"ACC\":\"3\", \"ON\":\"4\", \"START\":\"5\"}","{\"NONE\":\"0\", \"TWO_D\":\"1\", \"TWO_D_SATELLITE_BASED_AUGMENTATION\":\"2\", \"TWO_D_GROUND_BASED_AUGMENTATION\":\"3\", \"TWO_D_SATELLITE_AND_GROUND_BASED_AUGMENTATION\":\"4\", \"THREE_D\":\"5\", \"THREE_D_SATELLITE_BASED_AUGMENTATION\":\"6\", \"THREE_D_GROUND_BASED_AUGMENTATION\":\"7\", \"THREE_D_SATELLITE_AND_GROUND_BASED_AUGMENTATION\":\"8\"}","[0.6213712, 0]"]
Loading