raphaelthurnherr / algobot_onionOmega

1 stars 0 forks source link

Continuous FRP optimization #9

Closed YannCaron closed 6 years ago

YannCaron commented 6 years ago

Prefer use an associative array (key value pair) than a list for better performances.

the actual message is the following :

{
    // ....
        "MsgValue": [
            {
                "name": "algo_98f8",
                "upTime": 0,
                "firmwareVersion": "18.06.02",
                "mcuVersion": "10",
                "boardRev": "17",
                "battery_mv": 4181
            },
            {
                "din": 0,
                "state": 0
            },
            {
                "din": 1,
                "state": 0
            }
    // ....
}

It is better to use associative array / map for msg values. This is the expected message :

{
    "MsgTo": "unknown",
    "MsgFrom": "algo_98f8",
    "MsgID": 0,
    "MsgData": {
        "MsgType": "event",
        "MsgParam": "status",
        "MsgMap": {
            "name": "algo_98f8",
            "upTime": 0,
            "firmwareVersion": "18.06.02",
            "mcuVersion": "10",
            "boardRev": "17",
            "battery_mv": 4181,
            "din": [0, 0, 1, 0, 1],
            "rgb": [[255, 255, 127, 55], [255, 255, 255, 55]]
        }
    }
}

then I can access to data as the following :

var speed = MsgData.MsgValue.motor0.speed;

for example

raphaelthurnherr commented 6 years ago

Aie... ca me fait des changements de ouf...

Le ven. 8 juin 2018 à 18:12, CyaNn notifications@github.com a écrit :

Prefer use an associative array (key value pair) than a list for better performances.

the actual message is the following :

{ // .... "MsgValue": [ { "name": "algo_98f8", "upTime": 0, "firmwareVersion": "18.06.02", "mcuVersion": "10", "boardRev": "17", "battery_mv": 4181 }, { "din": 0, "state": 0 }, { "din": 1, "state": 0 } // ....}

It is better to use associative array / map for msg values. This is the expected message :

{ // .... "MsgValue": { // be careful the previous symbol as changed from [ to { "data" : { "name": "algo_98f8", "upTime": 0, "firmwareVersion": "18.06.02", "mcuVersion": "10", "boardRev": "17", "battery_mv": 4181 }, "din0" : 0, "din1": 1, "motor0" : { "cm": 0, "speed": 0 }, // .... }

then I can access to data as the following :

var speed = MsgData.MsgValue.motor0.speed;

for example

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/raphaelthurnherr/algobot_onionOmega/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDxTVu_KTEB7SYDzkkrWyo2j7fxv6hLks5t6qJYgaJpZM4UglO7 .

YannCaron commented 6 years ago

Oui, mais point de vue algorithme, ça n'a rien à voir. Actuel : je boucle sur tous les status à chaque fois Map : javascript se charge pour moi de mettre dans un hash map, donc acces direct

Le ven. 8 juin 2018 18:41, Raph notifications@github.com a écrit :

Aie... ca me fait des changements de ouf...

Le ven. 8 juin 2018 à 18:12, CyaNn notifications@github.com a écrit :

Prefer use an associative array (key value pair) than a list for better performances.

the actual message is the following :

{ // .... "MsgValue": [ { "name": "algo_98f8", "upTime": 0, "firmwareVersion": "18.06.02", "mcuVersion": "10", "boardRev": "17", "battery_mv": 4181 }, { "din": 0, "state": 0 }, { "din": 1, "state": 0 } // ....}

It is better to use associative array / map for msg values. This is the expected message :

{ // .... "MsgValue": { // be careful the previous symbol as changed from [ to { "data" : { "name": "algo_98f8", "upTime": 0, "firmwareVersion": "18.06.02", "mcuVersion": "10", "boardRev": "17", "battery_mv": 4181 }, "din0" : 0, "din1": 1, "motor0" : { "cm": 0, "speed": 0 }, // .... }

then I can access to data as the following :

var speed = MsgData.MsgValue.motor0.speed;

for example

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/raphaelthurnherr/algobot_onionOmega/issues/9, or mute the thread < https://github.com/notifications/unsubscribe-auth/ALDxTVu_KTEB7SYDzkkrWyo2j7fxv6hLks5t6qJYgaJpZM4UglO7

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raphaelthurnherr/algobot_onionOmega/issues/9#issuecomment-395818198, or mute the thread https://github.com/notifications/unsubscribe-auth/AFr6PHy23XPwK2Jz9ajwGyLH5wy-SSWEks5t6qkmgaJpZM4UglO7 .

raphaelthurnherr commented 6 years ago

This is the result for your request ! Please update your firmware and let me know if it's ok !

"MsgTo":"MQTTFX",
"MsgFrom":"algo_2643",
"MsgID":14351139,
"MsgData":{
"MsgType":"response",
"MsgParam":"status",
"MsgMap":{
"name":"algo_2643",
"upTime":0,
"firmwareVersion":"18.06.02",
"mcuVersion":"10",
"boardRev":"17",
"battery_mv":0,
"din":[
{
"state":0
},
{
"state":0
},
{
"state":0
},
{
"state":0
}
],
"btn":[
{
"state":0
},
{
"state":0
}
],
"motor":[
{
"cm":0,
"speed":0
},
{
"cm":0,
"speed":0
}
],
"sonar":[
{
"cm":4
}
],
"pwm":[
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
},
{
"state":0,
"power":0
}
]
}
}
}