ogma-core 1.16.0 → 1.17.0
raw patch · 8 files changed
+118/−49 lines, 8 filesdep ~QuickCheckdep ~aesondep ~ogma-extraPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, aeson, ogma-extra, ogma-language-c, ogma-language-copilot, ogma-language-csv, ogma-language-jsonspec, ogma-language-lustre, ogma-language-smv, ogma-language-xlsx, ogma-language-xmlspec, ogma-spec
API changes (from Hackage documentation)
- Command.CFSApp: instance GHC.Classes.Eq Command.CFSApp.MsgData
+ Command.CFSApp: instance Data.Aeson.Types.ToJSON.ToJSON Command.CFSApp.MsgDataContents
+ Command.CFSApp: instance GHC.Classes.Eq Command.CFSApp.MsgDataEntry
+ Command.CFSApp: instance GHC.Generics.Generic Command.CFSApp.MsgDataContents
Files
- CHANGELOG.md +9/−0
- ogma-core.cabal +13/−13
- src/Command/CFSApp.hs +82/−18
- src/Command/FPrimeApp.hs +7/−7
- src/Command/VariableDB.hs +1/−0
- src/Language/Trans/Lustre2Copilot.hs +2/−2
- src/Language/Trans/Spec2Copilot.hs +0/−1
- templates/cfs/copilot/fsw/src/copilot_cfs.c +4/−8
CHANGELOG.md view
@@ -1,5 +1,14 @@ # Revision history for ogma-core +## [1.17.0] - 2026-11-21++* Version bump (1.17.0) (#632).+* Bump upper version constraint on `aeson`, `QuickCheck` (#609).+* Remove duplicate line from copyright header (#611).+* Remove extraneous horizontal space from imports (#620).+* Adapt cFS backend, template to support messages with multiple fields (#625).+* Fix translation of Lustre comparison operators (#634).+ ## [1.16.0] - 2026-09-21 * Version bump (1.16.0) (#606).
ogma-core.cabal view
@@ -19,7 +19,7 @@ build-type: Simple name: ogma-core-version: 1.16.0+version: 1.17.0 homepage: https://github.com/nasa/ogma bug-reports: https://github.com/nasa/ogma/issues license: Apache-2.0@@ -152,7 +152,7 @@ build-depends: base >= 4.11.0.0 && < 5- , aeson >= 2.0.0.0 && < 2.3+ , aeson >= 2.0.0.0 && < 2.4 , bytestring >= 0.10.8.2 && < 0.13 , containers >= 0.5 && < 0.8 , copilot-core >= 4.7.1 && < 4.9@@ -170,16 +170,16 @@ , vector >= 0.12.0.1 && < 0.14 , yaml >= 0.11.7.0 && < 0.12 - , ogma-extra >= 1.16.0 && < 1.17- , ogma-language-c >= 1.16.0 && < 1.17- , ogma-language-copilot >= 1.16.0 && < 1.17- , ogma-language-csv >= 1.16.0 && < 1.17- , ogma-language-jsonspec >= 1.16.0 && < 1.17- , ogma-language-lustre >= 1.16.0 && < 1.17- , ogma-language-smv >= 1.16.0 && < 1.17- , ogma-language-xlsx >= 1.16.0 && < 1.17- , ogma-language-xmlspec >= 1.16.0 && < 1.17- , ogma-spec >= 1.16.0 && < 1.17+ , ogma-extra >= 1.17.0 && < 1.18+ , ogma-language-c >= 1.17.0 && < 1.18+ , ogma-language-copilot >= 1.17.0 && < 1.18+ , ogma-language-csv >= 1.17.0 && < 1.18+ , ogma-language-jsonspec >= 1.17.0 && < 1.18+ , ogma-language-lustre >= 1.17.0 && < 1.18+ , ogma-language-smv >= 1.17.0 && < 1.18+ , ogma-language-xlsx >= 1.17.0 && < 1.18+ , ogma-language-xmlspec >= 1.17.0 && < 1.18+ , ogma-spec >= 1.17.0 && < 1.18 hs-source-dirs: src@@ -201,7 +201,7 @@ base >= 4.11.0.0 && < 5 , directory >= 1.3.1.5 && < 1.4 , HUnit >= 1.2.0.0 && < 1.7- , QuickCheck >= 2.8.2 && < 2.19+ , QuickCheck >= 2.8.2 && < 2.20 , test-framework >= 0.8.2 && < 0.9 , test-framework-hunit >= 0.2.0 && < 0.4 , test-framework-quickcheck2 >= 0.3.0.4 && < 0.4
src/Command/CFSApp.hs view
@@ -36,14 +36,15 @@ where -- External imports-import Control.Applicative ( (<|>) )-import qualified Control.Exception as E-import Control.Monad.Except ( ExceptT (..), liftEither,- throwError )-import Data.Aeson ( ToJSON (..), Value )-import Data.List ( nub )-import Data.Maybe ( fromMaybe, mapMaybe, maybeToList )-import GHC.Generics ( Generic )+import Control.Applicative ( (<|>) )+import qualified Control.Exception as E+import Control.Monad.Except ( ExceptT (..), liftEither, throwError )+import Data.Aeson ( ToJSON (..), Value )+import Data.Function ( on )+import Data.List ( groupBy, nub, sortOn )+import Data.Maybe ( fromMaybe, listToMaybe, mapMaybe,+ maybeToList )+import GHC.Generics ( Generic ) -- External imports: auxiliary import qualified Command.Standalone@@ -191,7 +192,7 @@ vars' = nub vars ids' = nub ids infos' = nub infos- datas' = nub datas+ datas' = groupMsgDataEntries $ nub datas triggers' = nub triggers -- This is a Data.List.unzip4@@ -203,6 +204,46 @@ Just (vars, ids, infos, datas) -> (vars : oVars, ids : oIds, infos : oInfos, datas : oDatas) +-- | Group @MsgDataEntry@s coming from the same message into @MsgData@s.+groupMsgDataEntries :: [MsgDataEntry] -> [MsgData]+groupMsgDataEntries plains = map processGroup grouped+ where+ sorted = sortOn msgDataEntryDesc plains+ grouped = groupBy ((==) `on` msgDataEntryDesc) sorted++-- | Process a group of @MsgDataEntry@ sharing the same message description+-- into a @MsgData@.+--+-- PRE: The input list is not empty and all values share the same message+-- description.+processGroup :: [MsgDataEntry] -> MsgData+processGroup [] = error "processGroup: Empty group"+processGroup group@(firstElem:_) =+ MsgData+ { msgDataDesc = msgDataEntryDesc firstElem+ , msgDataActive = any msgDataEntryActive group+ , msgDataType = groupType group+ , msgDataContents = map toContents group+ }+ where++ -- | Type of the message based on the types mentioned by the subfields.+ groupType :: [MsgDataEntry] -> String+ groupType group' =+ fromMaybe (msgDataEntryVarType $ head group') firstFromType+ where+ firstFromType = listToMaybe allFromTypes+ allFromTypes = mapMaybe msgDataEntryFromType group'++ -- | Convert a plain message data into a structured field message data.+ toContents :: MsgDataEntry -> MsgDataContents+ toContents p = MsgDataContents+ { msgDataFromType = msgDataEntryFromType p+ , msgDataFromField = msgDataEntryFromField p+ , msgDataVarName = msgDataEntryVarName p+ , msgDataVarType = msgDataEntryVarType p+ }+ -- ** Argument processing -- | Options used to customize the conversion of specifications to ROS@@ -240,7 +281,7 @@ -- and subscriptions for a given variable name and variable database. variableMap :: VariableDB -> String- -> Maybe (VarDecl, MsgInfoId, MsgInfo, MsgData)+ -> Maybe (VarDecl, MsgInfoId, MsgInfo, MsgDataEntry) variableMap varDB varName = do inputDef <- findInput varDB varName mid <- connectionTopic <$> findConnection inputDef "cfs"@@ -263,7 +304,7 @@ return ( VarDecl varName typeVar' , mid , MsgInfo mid mn extra- , MsgData mn typeMsgFromType typeMsgFromField varName typeVar' active+ , MsgDataEntry mn typeMsgFromType typeMsgFromField varName typeVar' active ) -- | Return the monitor information needed to generate declarations and@@ -300,19 +341,42 @@ instance ToJSON MsgInfo --- | Information on the data provided by a message with a given description,--- and the type of the data it carries.+-- | Structured information on the data provided by a message with a given+-- description, and the type of the data it carries. data MsgData = MsgData- { msgDataDesc :: String- , msgDataFromType :: Maybe String+ { msgDataDesc :: String+ , msgDataActive :: Bool+ , msgDataType :: String+ , msgDataContents :: [MsgDataContents]+ }+ deriving (Generic)++instance ToJSON MsgData++-- | Information on data inside a message, its type, and how it maps to an+-- existing variable, and the field of the message it is populated from, if+-- applicable.+data MsgDataContents = MsgDataContents+ { msgDataFromType :: Maybe String , msgDataFromField :: Maybe String , msgDataVarName :: String , msgDataVarType :: String- , msgDataActive :: Bool }- deriving (Eq, Generic)+ deriving (Generic) -instance ToJSON MsgData+instance ToJSON MsgDataContents++-- | Information on the data provided by a message with a given description,+-- and the type of the data it carries.+data MsgDataEntry = MsgDataEntry+ { msgDataEntryDesc :: String+ , msgDataEntryFromType :: Maybe String+ , msgDataEntryFromField :: Maybe String+ , msgDataEntryVarName :: String+ , msgDataEntryVarType :: String+ , msgDataEntryActive :: Bool+ }+ deriving (Eq) -- | The message ID to subscribe to. data Trigger = Trigger
src/Command/FPrimeApp.hs view
@@ -30,13 +30,13 @@ where -- External imports-import Control.Applicative ( (<|>) )-import qualified Control.Exception as E-import Control.Monad.Except ( ExceptT(..), liftEither )-import Data.Aeson ( ToJSON, toJSON )-import Data.Char ( toUpper )-import Data.Maybe ( fromMaybe, mapMaybe, maybeToList )-import GHC.Generics ( Generic )+import Control.Applicative ( (<|>) )+import qualified Control.Exception as E+import Control.Monad.Except ( ExceptT(..), liftEither )+import Data.Aeson ( ToJSON, toJSON )+import Data.Char ( toUpper )+import Data.Maybe ( fromMaybe, mapMaybe, maybeToList )+import GHC.Generics ( Generic ) -- External imports: auxiliary import Data.Either.Extra ( mapLeft )
src/Command/VariableDB.hs view
@@ -275,6 +275,7 @@ | typeFromScope t1 == typeFromScope t2 && typeFromType t1 == typeFromType t2+ && typeFromField t1 == typeFromField t2 && typeToScope t1 == typeToScope t2 = throwError $ cannotMergeVariableDBs
src/Language/Trans/Lustre2Copilot.hs view
@@ -103,8 +103,8 @@ opTwoNum2Copilot BoolNumOp2Ne = "/=" opTwoNum2Copilot BoolNumOp2Le = "<=" opTwoNum2Copilot BoolNumOp2Lt = "<"-opTwoNum2Copilot BoolNumOp2Gt = ">="-opTwoNum2Copilot BoolNumOp2Ge = ">"+opTwoNum2Copilot BoolNumOp2Gt = ">"+opTwoNum2Copilot BoolNumOp2Ge = ">=" -- | Return the Copilot representation of a Lustre boolean -- constant.
src/Language/Trans/Spec2Copilot.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-} -- Copyright 2024 United States Government as represented by the Administrator--- Copyright 2024 United States Government as represented by the Administrator -- of the National Aeronautics and Space Administration. All Rights Reserved. -- -- Disclaimers
templates/cfs/copilot/fsw/src/copilot_cfs.c view
@@ -217,20 +217,16 @@ */ void COPILOT_Process{{msgDataDesc}}(void) {- {{#msgDataFromType}}- {{msgDataFromType}}* msg;- msg = ({{.}}*) COPILOTMsgPtr;- {{/msgDataFromType}}- {{^msgDataFromType}}- {{msgDataVarType}}* msg;- msg = ({{msgDataVarType}}*) COPILOTMsgPtr;- {{/msgDataFromType}}+ {{msgDataType}}* msg;+ msg = ({{msgDataType}}*) COPILOTMsgPtr;+ {{#msgDataContents}} {{#msgDataFromField}} {{msgDataVarName}} = msg->{{.}}; {{/msgDataFromField}} {{^msgDataFromField}} {{msgDataVarName}} = *msg; {{/msgDataFromField}}+ {{/msgDataContents}} {{#msgDataActive}} // Run all copilot monitors.