pxt-ev3
pxt-ev3 copied to clipboard
warn about conflicting modes
If we register for both IR button and distance alarm, only one of them will work (the last one likely)
Similarly, once we have events for color detection and ambient light detection, only one of them will work.
We need some way of warning the user I think, eg from the simulator.
CC @pelikhan @riknoll @microsoftsam
Maybe we can annotate the function calls so that we get the block disabling behavior.
Get Outlook for iOShttps://aka.ms/o0ukef
From: Michał Moskal [email protected] Sent: Friday, October 27, 2017 11:37:49 AM To: Microsoft/pxt-ev3 Cc: Peli de Halleux; Mention Subject: [Microsoft/pxt-ev3] warn about conflicting modes (#27)
If we register for both IR button and distance alarm, only one of them will work (the last one likely)
Similarly, once we have events for color detection and ambient light detection, only one of them will work.
We need some way of warning the user I think, eg from the simulator.
CC @pelikhanhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpelikhan&data=02%7C01%7Cjhalleux%40microsoft.com%7C9a3641f0407a4da6c67808d51d69d774%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447262772766486&sdata=itqohGMVybay91wq0oaB1kNg1845lv2AZVfF9nYKM68%3D&reserved=0 @riknollhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Friknoll&data=02%7C01%7Cjhalleux%40microsoft.com%7C9a3641f0407a4da6c67808d51d69d774%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447262772766486&sdata=8LfDKGTNTgRJzI19y5KxAv9cENVw3XL7sSTWfn%2BC1Zo%3D&reserved=0 @microsoftsamhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoftsam&data=02%7C01%7Cjhalleux%40microsoft.com%7C9a3641f0407a4da6c67808d51d69d774%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447262772766486&sdata=TbSaWkX%2B7Wt%2Biyu3hCUAVL0uTlXqK9ftbexP0M4D9nk%3D&reserved=0
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt-ev3%2Fissues%2F27&data=02%7C01%7Cjhalleux%40microsoft.com%7C9a3641f0407a4da6c67808d51d69d774%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447262772766486&sdata=ckwGFn%2B1lLyS74fsaccsJapGwvbFUoScVg3lhXpGa80%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KduzeFZV1aN6ds73kHC1S3YDGANpks5swiL9gaJpZM4QJdGE&data=02%7C01%7Cjhalleux%40microsoft.com%7C9a3641f0407a4da6c67808d51d69d774%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636447262772766486&sdata=K%2B0pQr0r3Xu2nOaNrdbnQ%2FBPYeOQLTZiBUw04G5GfIU%3D&reserved=0.
Related to https://github.com/Microsoft/pxt-ev3/issues/146
The PR doesn't seem to do anything about the mode of a sensor, just the kind of sensor connected to a port.
Note that it's perfectly valid to use a query function for ambient light, and then color.
Similarly, one can imagine registering events for both, and then changing mode manually.
The markUsed method is only called in the constructor of a sensor. You will only get one call if you use the same sensor on the same port regardless of what mode it's in, so to your second point, it won't error if you have two different color sensor handlers (one for ambient and one for color).
The PR rules out the case where the use connects sensor X to port 1, presses a button to change some program state, and connects sensor Y to 1. I think this is reasonable.
However, changing modes programmatically while the program is running seems like a much more common use case, so we should certainly not completely forbid it. I'm just not sure how exactly to handle this. Maybe ask LEGO?
It is quite easy to accidental have blocks for sensors that clash on a port. IMO, allowing this is confusing and the scenario of dynamically attaching sensors on the hardware is very unlikely.
For reference, robot configuration is completely static in ROBOTC
From: Michał Moskal [email protected] Sent: Saturday, January 6, 2018 4:54:27 AM To: Microsoft/pxt-ev3 Cc: Peli de Halleux; State change Subject: Re: [Microsoft/pxt-ev3] warn about conflicting modes (#27)
The PR rules out the case where the use connects sensor X to port 1, presses a button to change some program state, and connects sensor Y to 1. I think this is reasonable.
However, changing modes programmatically while the program is running seems like a much more common use case, so we should certainly not completely forbid it. I'm just not sure how exactly to handle this. Maybe ask LEGO?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt-ev3%2Fissues%2F27%23issuecomment-355745191&data=02%7C01%7Cjhalleux%40microsoft.com%7C24ed906529a8432487e008d555049f3d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508400696538434&sdata=Eyqg4ghYaMtn5ebGinyMOb%2FGHxuXh4LG%2Fv5fq7fxcyU%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KecPnz9P_WHA-w5Djv_IDfCHwGc3ks5tH20CgaJpZM4QJdGE&data=02%7C01%7Cjhalleux%40microsoft.com%7C24ed906529a8432487e008d555049f3d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508400696538434&sdata=j48L7Ip1UPNf%2BAbZcIFGWugJbfuejWa4blhE9ok5EgY%3D&reserved=0.
This issue is about different modes of the same sensor (eg color and ambient light) not different sensors. I think it would be OK to disable blocks with mode-conflicting events but it should be allowed in TS.
Actually, the documented way to calibrate the gyro is to switch between angle and rate (I have a block for that).
Disabling for blocks only would be nice but we don’t really have this availing right now.
From: Michał Moskal [email protected] Sent: Saturday, January 6, 2018 8:26:00 AM To: Microsoft/pxt-ev3 Cc: Peli de Halleux; State change Subject: Re: [Microsoft/pxt-ev3] warn about conflicting modes (#27)
This issue is about different modes of the same sensor (eg color and ambient light) not different sensors. I think it would be OK to disable blocks with mode-conflicting events but it should be allowed in TS.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt-ev3%2Fissues%2F27%23issuecomment-355757689&data=02%7C01%7Cjhalleux%40microsoft.com%7C6466b51334e641190e0708d555222d15%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508527630158175&sdata=C4hTzM8rzp7zI5QTtsRrifkYwcwNdQdcFtq%2Fg9RiTss%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KSZhXqbv-a4ohFlnndYxWEMMmXipks5tH56YgaJpZM4QJdGE&data=02%7C01%7Cjhalleux%40microsoft.com%7C6466b51334e641190e0708d555222d15%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508527630158175&sdata=Kc%2Famf3ew5ayWIk%2BH0CyK7brMo5ZW4koPnwSY%2BNWX5Q%3D&reserved=0.
I err on the side of allowing this one. Does the simulator reflect the mode already?
From: Peli de Halleux Sent: Saturday, January 6, 2018 8:41:42 AM To: Microsoft/pxt-ev3; Microsoft/pxt-ev3 Cc: State change Subject: Re: [Microsoft/pxt-ev3] warn about conflicting modes (#27)
Actually, the documented way to calibrate the gyro is to switch between angle and rate (I have a block for that).
Disabling for blocks only would be nice but we don’t really have this availing right now.
From: Michał Moskal [email protected] Sent: Saturday, January 6, 2018 8:26:00 AM To: Microsoft/pxt-ev3 Cc: Peli de Halleux; State change Subject: Re: [Microsoft/pxt-ev3] warn about conflicting modes (#27)
This issue is about different modes of the same sensor (eg color and ambient light) not different sensors. I think it would be OK to disable blocks with mode-conflicting events but it should be allowed in TS.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt-ev3%2Fissues%2F27%23issuecomment-355757689&data=02%7C01%7Cjhalleux%40microsoft.com%7C6466b51334e641190e0708d555222d15%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508527630158175&sdata=C4hTzM8rzp7zI5QTtsRrifkYwcwNdQdcFtq%2Fg9RiTss%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KSZhXqbv-a4ohFlnndYxWEMMmXipks5tH56YgaJpZM4QJdGE&data=02%7C01%7Cjhalleux%40microsoft.com%7C6466b51334e641190e0708d555222d15%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636508527630158175&sdata=Kc%2Famf3ew5ayWIk%2BH0CyK7brMo5ZW4koPnwSY%2BNWX5Q%3D&reserved=0.