{"modulePath":"github.com/Open-MBEE/OpenSysML","version":"v0.13.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package fmi\n\nPackage fmi reads Functional Mock-up Units: the modelDescription.xml of an .fmu archive as a Description, and the \\`tool:fmi\\` analysis engine that computes a ToolExecution-annotated calc or action by handing the FMU to the runner OPENSYSML\\_FMI\\_RUNNER names. The package never runs the FMU's native code itself; the runner is the operator's grant of that execution.\n\n## Constants\n\n```go\nconst Exchange = \"fmi/1\"\n```\nExchange names the request/reply protocol the engine and the runner speak, as an engine listing reports it.\n\n```go\nconst RunnerEnv = \"OPENSYSML_FMI_RUNNER\"\n```\nRunnerEnv names the environment variable holding the FMI runner: an executable name looked up on PATH or a path, exactly as OPENSYSML\\_SMT names the solver. Setting it is the operator's grant of execution: the runner instantiates an FMU's native code, which nothing in the build checks. Unset, the engine registers and refuses every question through Covers.\n\n## Variables\n\n```go\nvar ErrModelDescription = errors.New(\"malformed modelDescription.xml\")\n```\nErrModelDescription is the typed error for a malformed modelDescription.xml.\n\n```go\nvar ErrNotFMU = errors.New(\"not a Functional Mock-up Unit\")\n```\nErrNotFMU is the typed error for data that is not an FMU: not a zip archive, or a zip with no modelDescription.xml at its root.\n\n```go\nvar ErrUnsupportedVersion = errors.New(\"unsupported FMI version\")\n```\nErrUnsupportedVersion is the typed error for an fmiVersion this package does not read.\n\n```go\nvar ErrVariable = errors.New(\"fmi variable refused\")\n```\nErrVariable is the typed error for a ToolVariable an FMU cannot answer for.\n\n## Functions\n\n```go\nfunc FileURI(path string) string\n```\nFileURI spells the file: URI naming the file at path: the absolute path, escaped, a Windows drive gaining the leading slash the URL form carries.\n\n```go\nfunc New(look func() (string, error)) analysis.Manifested\n```\nNew returns the \\`tool:fmi\\` engine. look finds the runner's executable; nil reads RunnerEnv, whose absence is the absence the engine reports.\n\n## Types\n\n```go\ntype BaseUnit struct {\n\tKg, M, S, A, K, Mol, Cd, Rad int\n\tFactor, Offset               float64 // Factor defaults 1\n}\n```\nBaseUnit is the SI base-unit exponents of a Unit and the factor and offset converting its values to the SI unit.\n\n```go\nfunc ParseBaseUnit(unit string) (BaseUnit, bool)\n```\nParseBaseUnit reads a unit spelled as a product of the SI base symbols alone: \\`kg\\`, \\`m\\`, \\`s\\`, \\`A\\`, \\`K\\`, \\`mol\\`, \\`cd\\` and \\`rad\\` joined by \\`\\*\\`, \\`.\\` or \\`/\\`, each optionally raised by \\`^n\\`, \\`^-n\\`, a trailing digit or a ²/³ superscript — \\`m/s2\\`, \\`m/s^2\\`, \\`m/s²\\` and \\`kg.m/s2\\` all read. Named units such as \\`N\\` are not parsed.\n\n```go\nfunc (b BaseUnit) SIExpression() string\n```\nSIExpression spells the coherent KerML unit expression the exponents read as: the positive powers first, then \\`/\\` the negatives, in the order kg m s A K mol cd rad — \\`m/s^2\\` for acceleration, \\`kg\\*m/s^2\\` for force and \\`1/s\\` for frequency. A dimensionless unit spells as \"\" and reads as no unit at all.\n\n```go\ntype Causality string\n```\nCausality is a variable's causality attribute.\n\n```go\nconst (\n\tCausalityParameter           Causality = \"parameter\"\n\tCausalityCalculatedParameter Causality = \"calculatedParameter\"\n\tCausalityInput               Causality = \"input\"\n\tCausalityOutput              Causality = \"output\"\n\tCausalityLocal               Causality = \"local\"\n\tCausalityIndependent         Causality = \"independent\"\n\tCausalityStructuralParameter Causality = \"structuralParameter\"\n)\n```\nThe causalities a variable may declare.\n\n```go\ntype Description struct {\n\tFMIVersion                                                                     Version\n\tModelName, Description, Author, Version, GenerationTool, GenerationDateAndTime string\n\tInstantiationToken                                                             string     // FMI3 instantiationToken, FMI2 guid\n\tCoSimulation, ModelExchange, ScheduledExecution                                *Interface // nil when absent\n\tUnits                                                                          []Unit\n\tVariables                                                                      []Variable // document order\n\tDefaultExperiment                                                              *Experiment\n\t// Platforms are the sorted names of binaries/\u003cplatform\u003e/ directories that\n\t// hold at least one file; empty for a source-only or description-only archive.\n\tPlatforms []string\n}\n```\nDescription is the model description of one FMU.\n\n```go\nfunc ParseModelDescription(data []byte) (*Description, error)\n```\nParseModelDescription reads the XML of one modelDescription.xml.\n\n```go\nfunc Read(path string) (*Description, error)\n```\nRead opens the .fmu archive at path and reads its model description and the platforms its binaries are built for.\n\n```go\nfunc ReadArchive(r io.ReaderAt, size int64) (*Description, error)\n```\nReadArchive reads the .fmu archive held in memory at r.\n\n```go\nfunc (d *Description) Inputs() []Variable\n```\nInputs are the variables settable before or at initialization: causality input, parameter or structuralParameter, in document order.\n\n```go\nfunc (d *Description) Outputs() []Variable\n```\nOutputs are the readable variables: causality output, calculatedParameter or local, in document order.\n\n```go\nfunc (d *Description) Unit(name string) (Unit, bool)\n```\nUnit returns the unit named, and whether the description declares one.\n\n```go\nfunc (d *Description) Variable(name string) (Variable, bool)\n```\nVariable returns the variable named, and whether the description holds one.\n\n```go\ntype Dimension struct {\n\tStart          uint64 // meaningful only when HasStart\n\tHasStart       bool\n\tValueReference uint32 // meaningful only when HasVR\n\tHasVR          bool\n}\n```\nDimension is one array dimension of an FMI 3.0 variable: fixed at start, or structural when it names the valueReference of a structural parameter.\n\n```go\ntype Experiment struct {\n\tStartTime, StopTime, Tolerance, StepSize     float64\n\tHasStart, HasStop, HasTolerance, HasStepSize bool\n}\n```\nExperiment is a DefaultExperiment element: the experiment the FMU's documentation suggests. Each field is meaningful only when its Has flag is set.\n\n```go\ntype Interface struct {\n\tModelIdentifier string\n\tNeedsExecutionTool, CanHandleVariableCommunicationStepSize,\n\tCanGetAndSetFMUState, CanSerializeFMUState, ProvidesDirectionalDerivatives bool\n}\n```\nInterface is one FMI interface the FMU provides.\n\n```go\ntype Kind string\n```\nKind is a variable's type normalized across the FMI versions: the type element's name as FMI 2.0 writes it, with the FMI 3.0 scalar types folded onto it.\n\n```go\nconst (\n\tKindReal        Kind = \"Real\"\n\tKindInteger     Kind = \"Integer\"\n\tKindBoolean     Kind = \"Boolean\"\n\tKindString      Kind = \"String\"\n\tKindEnumeration Kind = \"Enumeration\"\n\tKindBinary      Kind = \"Binary\"\n\tKindClock       Kind = \"Clock\"\n)\n```\nThe kinds a variable's type reads as.\n\n```go\ntype ModelDescriptionError struct {\n\tDetail string\n\tErr    error\n}\n```\nModelDescriptionError reports a model description that does not read.\n\n```go\nfunc (e *ModelDescriptionError) Error() string\n```\nError gives the detail, then the cause.\n\n```go\nfunc (e *ModelDescriptionError) Is(target error) bool\n```\nIs matches ErrModelDescription.\n\n```go\nfunc (e *ModelDescriptionError) Unwrap() error\n```\nUnwrap returns the cause.\n\n```go\ntype RunnerError struct {\n\tMessage string\n\tStderr  string\n}\n```\nRunnerError is a reply carrying the runner's own error member.\n\n```go\nfunc (e *RunnerError) Error() string\n```\nError names the runner's message, then what it wrote to standard error.\n\n```go\ntype Unit struct {\n\tName string\n\tBase *BaseUnit\n}\n```\nUnit is one declared unit.\n\n```go\ntype UnsupportedVersionError struct {\n\tVersion string\n}\n```\nUnsupportedVersionError reports a model description of a version other than 1.0, 2.0 or 3.0 — including pre-release spellings such as \"3.0-beta.1\".\n\n```go\nfunc (e *UnsupportedVersionError) Error() string\n```\nError names the version read.\n\n```go\nfunc (e *UnsupportedVersionError) Is(target error) bool\n```\nIs matches ErrUnsupportedVersion.\n\n```go\ntype Variability string\n```\nVariability is a variable's variability attribute.\n\n```go\nconst (\n\tVariabilityConstant   Variability = \"constant\"\n\tVariabilityFixed      Variability = \"fixed\"\n\tVariabilityTunable    Variability = \"tunable\"\n\tVariabilityDiscrete   Variability = \"discrete\"\n\tVariabilityContinuous Variability = \"continuous\"\n)\n```\nThe variabilities a variable may declare.\n\n```go\ntype Variable struct {\n\tName, Description string\n\tValueReference    uint32\n\tCausality         Causality   // FMI 2/3 default \"local\"\n\tVariability       Variability // default \"continuous\" for Real, else \"discrete\"\n\tKind              Kind\n\tFMIType           string // the element name as written (Float64, Real, Int32…)\n\tStart             string // raw start text, \"\" when none\n\tHasStart          bool\n\tUnit              string // unit attribute, or the declaredType's unit when the variable has none\n\tDeclaredType      string\n\tMin, Max          string\n\t// Dimensions are the variable's array dimensions in document order; empty\n\t// for a scalar. A Dimension with HasStart is fixed; HasVR names the\n\t// valueReference of a structural parameter.\n\tDimensions []Dimension\n}\n```\nVariable is one scalar variable of the model.\n\n```go\nfunc (v Variable) UnitExponents(d *Description) (BaseUnit, bool)\n```\nUnitExponents resolves the variable's unit to coherent SI base-unit exponents: the declared unit's BaseUnit, else the unit spelling itself as a product of the base symbols. False for a variable with no unit, one that resolves to nothing, or a non-coherent unit (factor other than 1 or an offset, as km or degC carry).\n\n```go\ntype VariableError struct {\n\tFMU      string\n\tVariable string\n\tDetail   string\n}\n```\nVariableError reports a ToolVariable naming no variable of the FMU, or naming one of the wrong direction. Detail lists the candidates it could have been.\n\n```go\nfunc (e *VariableError) Error() string\n```\nError names the FMU, the variable and the detail.\n\n```go\nfunc (e *VariableError) Is(target error) bool\n```\nIs matches ErrVariable.\n\n```go\ntype Version string\n```\nVersion is an FMI version as fmiVersion spells it: major.minor only.\n\n```go\nconst (\n\tVersion1 Version = \"1.0\"\n\tVersion2 Version = \"2.0\"\n\tVersion3 Version = \"3.0\"\n)\n```\nFMI versions this package reads.\n\n","path":"github.com/Open-MBEE/OpenSysML/internal/exec/fmi","name":"fmi","synopsis":"Package fmi reads Functional Mock-up Units: the modelDescription.xml of an .fmu archive as a Description, and the `tool:fmi` analysis engine that computes a ToolExecution-annotated calc or action by handing the FMU to the runner OPENSYSML_FMI_RUNNER names.","isRedistributable":true}
