@sdeverywhere/cli 0.7.10 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdeverywhere/cli",
3
- "version": "0.7.10",
3
+ "version": "0.7.12",
4
4
  "description": "Contains the `sde` command line interface for the SDEverywhere tool suite.",
5
5
  "type": "module",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "sde": "src/main.js"
12
12
  },
13
13
  "dependencies": {
14
- "@sdeverywhere/build": "^0.3.1",
15
- "@sdeverywhere/compile": "^0.7.6",
14
+ "@sdeverywhere/build": "^0.3.2",
15
+ "@sdeverywhere/compile": "^0.7.8",
16
16
  "bufx": "^1.0.5",
17
17
  "byline": "^5.0.0",
18
18
  "ramda": "^0.27.0",
package/src/c/model.c CHANGED
@@ -8,6 +8,14 @@
8
8
  struct timespec startTime, finishTime;
9
9
  #endif
10
10
 
11
+ // For each output variable specified in the indices buffer, there
12
+ // are 4 index values:
13
+ // varIndex
14
+ // subIndex0
15
+ // subIndex1
16
+ // subIndex2
17
+ #define INDICES_PER_OUTPUT 4
18
+
11
19
  // The special _time variable is not included in .mdl files.
12
20
  double _time;
13
21
 
@@ -17,6 +25,7 @@ size_t outputIndex = 0;
17
25
 
18
26
  // Output data buffer used by `runModelWithBuffers`
19
27
  double* outputBuffer = NULL;
28
+ int32_t* outputIndexBuffer = NULL;
20
29
  size_t outputVarIndex = 0;
21
30
  size_t numSavePoints = 0;
22
31
  size_t savePointIndex = 0;
@@ -66,6 +75,13 @@ double getSaveper() {
66
75
  return _saveper;
67
76
  }
68
77
 
78
+ /**
79
+ * Return the constant `maxOutputIndices` value.
80
+ */
81
+ int getMaxOutputIndices() {
82
+ return maxOutputIndices;
83
+ }
84
+
69
85
  char* run_model(const char* inputs) {
70
86
  // run_model does everything necessary to run the model with the given inputs.
71
87
  // It may be called multiple times. Call finish() after all runs are complete.
@@ -102,13 +118,15 @@ char* run_model(const char* inputs) {
102
118
  * (where tN is the last time in the range), the second variable outputs will begin,
103
119
  * and so on.
104
120
  */
105
- void runModelWithBuffers(double* inputs, double* outputs) {
121
+ void runModelWithBuffers(double* inputs, double* outputs, int32_t* outputIndices) {
106
122
  outputBuffer = outputs;
123
+ outputIndexBuffer = outputIndices;
107
124
  initConstants();
108
125
  setInputsFromBuffer(inputs);
109
126
  initLevels();
110
127
  run();
111
128
  outputBuffer = NULL;
129
+ outputIndexBuffer = NULL;
112
130
  }
113
131
 
114
132
  void run() {
@@ -137,7 +155,25 @@ void run() {
137
155
  numSavePoints = (size_t)(round((_final_time - _initial_time) / _saveper)) + 1;
138
156
  }
139
157
  outputVarIndex = 0;
140
- storeOutputData();
158
+ if (outputIndexBuffer != NULL) {
159
+ // Store the outputs as specified in the current output index buffer
160
+ for (size_t i = 0; i < maxOutputIndices; i++) {
161
+ size_t indexBufferOffset = i * INDICES_PER_OUTPUT;
162
+ size_t varIndex = (size_t)outputIndexBuffer[indexBufferOffset];
163
+ if (varIndex > 0) {
164
+ size_t subIndex0 = (size_t)outputIndexBuffer[indexBufferOffset + 1];
165
+ size_t subIndex1 = (size_t)outputIndexBuffer[indexBufferOffset + 2];
166
+ size_t subIndex2 = (size_t)outputIndexBuffer[indexBufferOffset + 3];
167
+ storeOutput(varIndex, subIndex0, subIndex1, subIndex2);
168
+ } else {
169
+ // Stop when we reach the first zero index
170
+ break;
171
+ }
172
+ }
173
+ } else {
174
+ // Store the normal outputs
175
+ storeOutputData();
176
+ }
141
177
  savePointIndex++;
142
178
  }
143
179
  if (step == lastStep) break;
package/src/c/sde.h CHANGED
@@ -42,6 +42,7 @@ EXTERN double _epsilon;
42
42
 
43
43
  // Internal variables
44
44
  EXTERN const int numOutputs;
45
+ EXTERN const int maxOutputIndices;
45
46
 
46
47
  // Standard simulation control parameters
47
48
  EXTERN double _time;
@@ -55,7 +56,7 @@ double getInitialTime(void);
55
56
  double getFinalTime(void);
56
57
  double getSaveper(void);
57
58
  char* run_model(const char* inputs);
58
- void runModelWithBuffers(double* inputs, double* outputs);
59
+ void runModelWithBuffers(double* inputs, double* outputs, int32_t* outputIndices);
59
60
  void run(void);
60
61
  void startOutput(void);
61
62
  void outputVar(double value);
@@ -69,6 +70,7 @@ void setInputsFromBuffer(double *inputData);
69
70
  void evalAux(void);
70
71
  void evalLevels(void);
71
72
  void storeOutputData(void);
73
+ void storeOutput(size_t varIndex, size_t subIndex0, size_t subIndex1, size_t subIndex2);
72
74
  const char* getHeader(void);
73
75
 
74
76
  #ifdef __cplusplus