mirror of
https://github.com/nasa/fpp.git
synced 2025-12-10 17:29:15 -06:00
User guide updates for dictionary specifier
This commit is contained in:
parent
c78f26eeaa
commit
0ea6dbb0c4
@ -11930,7 +11930,7 @@ equivalent.</p>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2025-09-30 11:19:46 -0700
|
||||
Last updated 2025-10-22 10:46:34 -0700
|
||||
</div>
|
||||
</div>
|
||||
<script src="code-prettify/run_prettify.js"></script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -737,3 +737,19 @@ is not legal:
|
||||
constant
|
||||
a = 1
|
||||
--------
|
||||
|
||||
=== Constant Dictionary Definitions
|
||||
|
||||
Prefixing a constant definition with the `dicitionary` keyword
|
||||
designates the constant as a dictionary defintion. Dictionary
|
||||
definitions are covered in more detail in the
|
||||
<<Defining-Framework-and-Dictionary-Definitions,dictionary definitions>>
|
||||
section.
|
||||
|
||||
For example, to define a constant dictionary definition, you write
|
||||
the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary constant a = 1
|
||||
----
|
||||
|
||||
@ -198,3 +198,19 @@ enum Decision { YES, NO, MAYBE } default MAYBE
|
||||
Notice that when using the constant `MAYBE` as a default value, we
|
||||
don't need to qualify it with the enum name, because the
|
||||
use appears inside the enum where it is defined.
|
||||
|
||||
=== Enum Dictionary Definitions
|
||||
|
||||
Prefixing an enum definition with the `dicitionary` keyword
|
||||
designates the enum as a dictionary defintion. Dictionary
|
||||
definitions are covered in more detail in the
|
||||
<<Defining-Framework-and-Dictionary-Definitions,dictionary definitions>>
|
||||
section.
|
||||
|
||||
For example, to define an enum dictionary definition, you write
|
||||
the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary enum E { A, B, C }
|
||||
----
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
== Defining Framework and Dictionary Definitions
|
||||
|
||||
=== Defining Framework Definitions
|
||||
*Framework definitions* are type and constant definitions that
|
||||
are specicially used by the F Prime Framework. If a model defines
|
||||
framework definitions, they must conform to the rules described
|
||||
in the the _FPP Specification_.
|
||||
|
||||
=== Writing a Framework Definition
|
||||
|
||||
To write a framework definition, we write the type or constant
|
||||
and ensure that the defintion follows the rules for that
|
||||
framework definition.
|
||||
|
||||
For example, to write the `FwDpIdType` framework definition,
|
||||
we would write an alias `FwDpIdType` that represents an
|
||||
integer type:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
type FwDpIdType = U32
|
||||
----
|
||||
|
||||
To write the `Fw.DpCfg.CONTAINER_USER_DATA_SIZE` framework definition,
|
||||
we would define modules `Fw` and `DpCfg` and write a constant
|
||||
`CONTAINER_USER_DATA_SIZE` with an integer type:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
module Fw {
|
||||
module DpCfg {
|
||||
constant CONTAINER_USER_DATA_SIZE = 1
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
=== Defining Dictionary Definitions
|
||||
|
||||
An FPP model may include type and constant definitions
|
||||
that are *dictionary definitions*. These definitions describe
|
||||
type and constant definitions that will be output to the
|
||||
dictionary.
|
||||
|
||||
=== Writing a Dictionary Definition
|
||||
|
||||
To write a dictionary definition, prefix an array, struct,
|
||||
alias, or constant definition with the `dictionary` keyword.
|
||||
For example, to define a constant dictionary definition
|
||||
we write the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary constant a = 1
|
||||
----
|
||||
|
||||
To define an array dictionary definition, we write the following:
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary array a = [3] U32
|
||||
----
|
||||
@ -281,6 +281,22 @@ array B3 = [2] A default [ 1, 2 ] # default value is [ [ 1, 1 ], [ 2, 2 ] ]
|
||||
array B4 = [2] A default [ [ 1, 2 ], [ 3, 4 ] ]
|
||||
----
|
||||
|
||||
==== Array Dictionary Definitions
|
||||
|
||||
Prefixing an array definition with the `dicitionary` keyword
|
||||
designates the array as a dictionary defintion. Dictionary
|
||||
definitions are covered in more detail in the
|
||||
<<Defining-Framework-and-Dictionary-Definitions,dictionary definitions>>
|
||||
section.
|
||||
|
||||
For example, to define an array dictionary definition, you write
|
||||
the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary array A = [2] U32
|
||||
----
|
||||
|
||||
=== Struct Type Definitions
|
||||
|
||||
A *struct type definition* associates a name with a *struct type*.
|
||||
@ -576,6 +592,22 @@ FPP struct _values_ have no inherent order associated with their members.
|
||||
However, once those values are assigned to a named struct _type_,
|
||||
the order becomes fixed.
|
||||
|
||||
==== Struct Dictionary Definitions
|
||||
|
||||
Prefixing a struct definition with the `dicitionary` keyword
|
||||
designates the struct as a dictionary defintion. Dictionary
|
||||
definitions are covered in more detail in the
|
||||
<<Defining-Framework-and-Dictionary-Definitions,dictionary definitions>>
|
||||
section.
|
||||
|
||||
For example, to define a struct dictionary definition, you write
|
||||
the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary struct S { x: U32, y: string }
|
||||
----
|
||||
|
||||
=== Abstract Type Definitions
|
||||
|
||||
An array or struct type definition specifies a complete type:
|
||||
@ -691,3 +723,19 @@ defining `T`; elsewhere, configuration code can define
|
||||
F Prime uses this method to provide basic type whose definitions
|
||||
configure the framework.
|
||||
These types are defined in the file `config/FpConfig.fpp`.
|
||||
|
||||
==== Alias Type Dictionary Definitions
|
||||
|
||||
Prefixing an alias type definition with the `dicitionary` keyword
|
||||
designates the alias type as a dictionary defintion. Dictionary
|
||||
definitions are covered in more detail in the
|
||||
<<Defining-Framework-and-Dictionary-Definitions,dictionary definitions>>
|
||||
section.
|
||||
|
||||
For example, to define an alias type dictionary definition, you write
|
||||
the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
dictionary type T = U32
|
||||
----
|
||||
|
||||
@ -397,6 +397,29 @@ and suppose that file `b.fpp` contains the include specifier `include "a.fppi"`.
|
||||
When analyzing `b.fpp`, the location of the definition of the constant `a`
|
||||
is `b.fpp`, not `a.fppi`.
|
||||
|
||||
==== Dictionary Specifiers
|
||||
|
||||
Dictionary specifiers define the location of constant or type
|
||||
dictionary definitions. To write a dictionary specifier,
|
||||
write a location specifier and include the `dictionary` keyword
|
||||
before the `constant` or `type` keyword.
|
||||
|
||||
For example, to write a dictionary specifier for type `T` located
|
||||
at `T.fpp`, write the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
locate dictionary type T at "T.fpp"
|
||||
----
|
||||
|
||||
To write a dictionary specifier for constant `C` located
|
||||
at `C.fpp`, write the following:
|
||||
|
||||
[source,fpp]
|
||||
----
|
||||
locate dictionary constant C at "C.fpp"
|
||||
----
|
||||
|
||||
=== Locating Definitions
|
||||
|
||||
Given a collection of FPP source files _F_, you can generate location specifiers
|
||||
|
||||
@ -17,6 +17,7 @@ Writing-Comments-and-Annotations.adoc
|
||||
Defining-Modules.adoc
|
||||
Defining-Types.adoc
|
||||
Defining-Enums.adoc
|
||||
Defining-Framework-and-Dictionary-Definitions.adoc
|
||||
Defining-Ports.adoc
|
||||
Defining-State-Machines.adoc
|
||||
Defining-Components.adoc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user