File tree Expand file tree Collapse file tree 5 files changed +156
-2
lines changed
lib/src/main/scala/codegen/DictionaryJsonWriter Expand file tree Collapse file tree 5 files changed +156
-2
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,25 @@ case class DictionaryJsonEncoder(
461461 }
462462 }
463463
464+ /** JSON Encoding for Event.Throttle */
465+ private implicit def eventThrottleEncoder : Encoder [Event .Throttle ] = new Encoder [Event .Throttle ] {
466+ override def apply (throttle : Event .Throttle ): Json = {
467+ throttle match {
468+ case Event .Throttle (count, Some (every)) => Json .obj(
469+ " count" -> count.asJson,
470+ " every" -> Json .obj(
471+ " seconds" -> every.seconds.asJson,
472+ " useconds" -> every.useconds.asJson
473+ )
474+ )
475+ case Event .Throttle (count, None ) => Json .obj(
476+ " count" -> count.asJson,
477+ " every" -> Json .Null
478+ )
479+ }
480+ }
481+ }
482+
464483 /** JSON Encoding for TlmChannel.Limits */
465484 private implicit def channelLimitEncoder : Encoder [TlmChannel .Limits ] = new Encoder [TlmChannel .Limits ] {
466485 override def apply (limits : TlmChannel .Limits ): Json = {
@@ -604,6 +623,7 @@ case class DictionaryJsonEncoder(
604623 }
605624 case x : Value => Json .obj(key -> valueAsJson(x)).deepMerge(json)
606625 case x : Ast .QueueFull => Json .obj(key -> x.toString.asJson).deepMerge(json)
626+ case x : Event .Throttle => Json .obj(key -> x.asJson).deepMerge(json)
607627 }
608628 case None => json
609629 }
Original file line number Diff line number Diff line change 407407 "type" : " string"
408408 },
409409 "throttle" : {
410- "type" : " number"
410+ "type" : " object" ,
411+ "properties" : {
412+ "count" : {
413+ "type" : " integer" ,
414+ "minimum" : 1
415+ },
416+ "interval" : {
417+ "type" : " object" ,
418+ "properties" : {
419+ "seconds" : {
420+ "type" : " integer" ,
421+ "minimum" : 0
422+ },
423+ "useconds" : {
424+ "type" : " integer" ,
425+ "minimum" : 0
426+ }
427+ }
428+ }
429+ }
411430 }
412431 },
413432 "required" : [
568587 }
569588 }
570589 }
571- }
590+ }
Original file line number Diff line number Diff line change 978978 "format" : " Arg1 is {f}" ,
979979 "annotation" : " Event with format specifier\n Multiple lines of annotation\n And not used on purpose"
980980 },
981+ {
982+ "name" : " Module1.myFirstC1.Event4" ,
983+ "severity" : " ACTIVITY_HI" ,
984+ "formalParams" : [
985+ {
986+ "name" : " arg1" ,
987+ "type" : {
988+ "name" : " F64" ,
989+ "kind" : " float" ,
990+ "size" : 64
991+ },
992+ "ref" : false ,
993+ "annotation" : " description of arg1 formal param"
994+ }
995+ ],
996+ "id" : 771 ,
997+ "format" : " Arg1 is {}" ,
998+ "annotation" : " Event with throttle" ,
999+ "throttle" : {
1000+ "count" : 10 ,
1001+ "every" : null
1002+ }
1003+ },
1004+ {
1005+ "name" : " Module1.myFirstC1.Event5" ,
1006+ "severity" : " ACTIVITY_HI" ,
1007+ "formalParams" : [
1008+ {
1009+ "name" : " arg1" ,
1010+ "type" : {
1011+ "name" : " F64" ,
1012+ "kind" : " float" ,
1013+ "size" : 64
1014+ },
1015+ "ref" : false ,
1016+ "annotation" : " description of arg1 formal param"
1017+ }
1018+ ],
1019+ "id" : 772 ,
1020+ "format" : " Arg1 is {}" ,
1021+ "annotation" : " Event with throttle and timeout" ,
1022+ "throttle" : {
1023+ "count" : 10 ,
1024+ "every" : {
1025+ "seconds" : 10 ,
1026+ "useconds" : 0
1027+ }
1028+ }
1029+ },
9811030 {
9821031 "name" : " Module1.myFirstC2.Event1" ,
9831032 "severity" : " WARNING_LO" ,
Original file line number Diff line number Diff line change 978978 "format" : " Arg1 is {f}" ,
979979 "annotation" : " Event with format specifier\n Multiple lines of annotation\n And not used on purpose"
980980 },
981+ {
982+ "name" : " Module1.mySecondC1.Event4" ,
983+ "severity" : " ACTIVITY_HI" ,
984+ "formalParams" : [
985+ {
986+ "name" : " arg1" ,
987+ "type" : {
988+ "name" : " F64" ,
989+ "kind" : " float" ,
990+ "size" : 64
991+ },
992+ "ref" : false ,
993+ "annotation" : " description of arg1 formal param"
994+ }
995+ ],
996+ "id" : 1283 ,
997+ "format" : " Arg1 is {}" ,
998+ "annotation" : " Event with throttle" ,
999+ "throttle" : {
1000+ "count" : 10 ,
1001+ "every" : null
1002+ }
1003+ },
1004+ {
1005+ "name" : " Module1.mySecondC1.Event5" ,
1006+ "severity" : " ACTIVITY_HI" ,
1007+ "formalParams" : [
1008+ {
1009+ "name" : " arg1" ,
1010+ "type" : {
1011+ "name" : " F64" ,
1012+ "kind" : " float" ,
1013+ "size" : 64
1014+ },
1015+ "ref" : false ,
1016+ "annotation" : " description of arg1 formal param"
1017+ }
1018+ ],
1019+ "id" : 1284 ,
1020+ "format" : " Arg1 is {}" ,
1021+ "annotation" : " Event with throttle and timeout" ,
1022+ "throttle" : {
1023+ "count" : 10 ,
1024+ "every" : {
1025+ "seconds" : 10 ,
1026+ "useconds" : 0
1027+ }
1028+ }
1029+ },
9811030 {
9821031 "name" : " Module1.mySecondC2.Event1" ,
9831032 "severity" : " WARNING_LO" ,
Original file line number Diff line number Diff line change @@ -132,6 +132,23 @@ module Module1 {
132132 severity activity high \
133133 format " Arg1 is {f}"
134134
135+ @ Event with throttle
136+ event Event4(
137+ arg1: F64 @< description of arg1 formal param
138+ ) \
139+ severity activity high \
140+ format " Arg1 is {}" \
141+ throttle 10
142+
143+ @ Event with throttle and timeout
144+ event Event5(
145+ arg1: F64 @< description of arg1 formal param
146+ ) \
147+ severity activity high \
148+ format " Arg1 is {}" \
149+ throttle 10 \
150+ every {seconds= 10 }
151+
135152
136153 # Telemtry Channels
137154 @ Telemetry channel of type F64 with high and low limits
You can’t perform that action at this time.
0 commit comments