mirror of
https://github.com/nasa/fpp.git
synced 2025-12-15 21:08:16 -06:00
Merge remote-tracking branch 'origin/feature/event-throttle-time' into event-throttle-time-codegen
This commit is contained in:
commit
db0d0e9f81
@ -59,24 +59,21 @@ object Event {
|
||||
Type.U32
|
||||
)
|
||||
|
||||
if (v < 0) {
|
||||
Left(SemanticError.InvalidIntValue(
|
||||
loc, v, s"$member may not be negative"
|
||||
))
|
||||
} else {
|
||||
if v >= maxValue then
|
||||
Left(SemanticError.InvalidIntValue(
|
||||
loc, v, s"$member must be smaller than $maxValue"
|
||||
)) else Right(v.longValue)
|
||||
}
|
||||
if v < 0 || v > maxValue
|
||||
then Left(
|
||||
SemanticError.InvalidIntValue(
|
||||
loc, v, s"$member must be in the range [0, $maxValue]"
|
||||
)
|
||||
)
|
||||
else Right(v.longValue)
|
||||
}
|
||||
for {
|
||||
seconds <- getMember("seconds", 4294967295L)
|
||||
useconds <- getMember("useconds", 1_000_000)
|
||||
seconds <- getMember("seconds", UInt.MaxValue)
|
||||
useconds <- getMember("useconds", 999_999)
|
||||
_ <- {
|
||||
if (seconds + useconds) > 0 then Right(())
|
||||
else Left(SemanticError.InvalidIntValue(
|
||||
loc, 0, s"time interval must be greater than 0"
|
||||
else Left(SemanticError.InvalidEvent(
|
||||
loc, "time interval may not be zero"
|
||||
))
|
||||
}
|
||||
} yield TimeInterval(seconds, useconds.toInt)
|
||||
|
||||
10
compiler/lib/src/main/scala/util/UInt.scala
Normal file
10
compiler/lib/src/main/scala/util/UInt.scala
Normal file
@ -0,0 +1,10 @@
|
||||
package fpp.compiler.util
|
||||
|
||||
object UInt {
|
||||
/** The smallest value representable as a UInt. */
|
||||
final val MinValue = 0
|
||||
|
||||
/** The largest value representable as a UInt. */
|
||||
final val MaxValue = 4294967295L
|
||||
|
||||
}
|
||||
@ -3,4 +3,4 @@ fpp-check
|
||||
every {seconds=-1}
|
||||
^
|
||||
error: invalid integer value -1
|
||||
seconds may not be negative
|
||||
seconds must be in the range [0, 4294967295]
|
||||
|
||||
@ -2,6 +2,6 @@ active component C {
|
||||
|
||||
event E severity activity low \
|
||||
format "" throttle 10 \
|
||||
every {useconds=2000000}
|
||||
every {useconds=1000000}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
fpp-check
|
||||
[ local path prefix ]/compiler/tools/fpp-check/test/event/bad_throttle_interval_useconds.fpp:5.11
|
||||
every {useconds=2000000}
|
||||
every {useconds=1000000}
|
||||
^
|
||||
error: invalid integer value 2000000
|
||||
useconds must be smaller than 1000000
|
||||
error: invalid integer value 1000000
|
||||
useconds must be in the range [0, 999999]
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
active component C {
|
||||
|
||||
event E severity activity low \
|
||||
format "" throttle 10 \
|
||||
every {seconds=4294967295 + 1}
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
fpp-check
|
||||
[ local path prefix ]/compiler/tools/fpp-check/test/event/bad_throttle_seconds.fpp:5.11
|
||||
every {seconds=4294967295 + 1}
|
||||
^
|
||||
error: invalid integer value 4294967296
|
||||
seconds must be in the range [0, 4294967295]
|
||||
@ -4,6 +4,7 @@ bad_throttle_interval_extra_member
|
||||
bad_throttle_interval_seconds
|
||||
bad_throttle_interval_useconds
|
||||
bad_throttle_interval
|
||||
bad_throttle_seconds
|
||||
bad_throttle
|
||||
duplicate_id_explicit
|
||||
duplicate_id_implicit
|
||||
|
||||
@ -2,5 +2,4 @@ fpp-check
|
||||
[ local path prefix ]/compiler/tools/fpp-check/test/event/zero_throttle_interval.fpp:5.11
|
||||
every {seconds=0}
|
||||
^
|
||||
error: invalid integer value 0
|
||||
time interval must be greater than 0
|
||||
error: time interval may not be zero
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user