-
Notifications
You must be signed in to change notification settings - Fork 1
/
TempControlPeriodic_p_tcproc_tempControl_GumboX.scala
294 lines (270 loc) · 12.7 KB
/
TempControlPeriodic_p_tcproc_tempControl_GumboX.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// #Sireum
package tc.TempControlSoftwareSystem
import org.sireum._
import tc._
// Do not edit this file as it will be overwritten if HAMR codegen is rerun
object TempControlPeriodic_p_tcproc_tempControl_GumboX {
/** I-Assm: Integration constraint on tempControl's incoming data port currentTemp
*
* assume currentTempRange
*/
@strictpure def I_Assm_currentTemp(currentTemp: TempSensor.Temperature_i): B =
currentTemp.degrees >= -128.6f &
currentTemp.degrees <= 134.0f
// I-Assm-Guard: Integration constraint on tempControl's incoming data port currentTemp
@strictpure def I_Assm_Guard_currentTemp(currentTemp: TempSensor.Temperature_i): B =
I_Assm_currentTemp(currentTemp)
/** Initialize Entrypoint Contract
*
* guarantee initLatestFanCmd
* Initialize state variable
* @param latestFanCmd post-state state variable
*/
@strictpure def initialize_initLatestFanCmd (
latestFanCmd: CoolingFan.FanCmd.Type): B =
latestFanCmd == CoolingFan.FanCmd.Off
/** Initialize Entrypoint Contract
*
* guarantee initFanCmd
* Initial fan command
* @param api_fanCmd outgoing data port
*/
@strictpure def initialize_initFanCmd (
api_fanCmd: CoolingFan.FanCmd.Type): B =
api_fanCmd == CoolingFan.FanCmd.Off
/** IEP-Guar: Initialize Entrypoint Contracts for tempControl
*
* @param latestFanCmd post-state state variable
* @param api_fanCmd outgoing data port
*/
@strictpure def initialize_IEP_Guar (
latestFanCmd: CoolingFan.FanCmd.Type,
api_fanCmd: CoolingFan.FanCmd.Type): B =
initialize_initLatestFanCmd(latestFanCmd) &
initialize_initFanCmd(api_fanCmd)
/** IEP-Post: Initialize Entrypoint Post-Condition
*
* @param latestFanCmd post-state state variable
* @param api_fanCmd outgoing data port
*/
@strictpure def inititialize_IEP_Post (
latestFanCmd: CoolingFan.FanCmd.Type,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(// IEP-Guar: Initialize Entrypoint contract for tempControl
initialize_IEP_Guar(latestFanCmd, api_fanCmd))
/** IEP-Post: Initialize Entrypoint Post-Condition via container
*
* @param post Container holding the value of incoming ports and the pre-state values of state variables
*/
@strictpure def inititialize_IEP_Post_Container (post: TempControlPeriodic_p_tcproc_tempControl_PostState_Container_PS): B =
inititialize_IEP_Post (
latestFanCmd = post.latestFanCmd,
api_fanCmd = post.api_fanCmd)
/** CEP-Pre: Compute Entrypoint Pre-Condition for tempControl
*
* @param In_latestFanCmd pre-state state variable
* @param api_currentTemp incoming data port
* @param api_fanAck incoming data port
* @param api_setPoint incoming data port
*/
@strictpure def compute_CEP_Pre (
In_latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_fanAck: CoolingFan.FanAck.Type,
api_setPoint: TempControlSoftwareSystem.SetPoint_i): B =
(// D-Inv-Guard: Datatype invariants for the types associated with tempControl's state variables and incoming ports
TempSensor.Temperature_i.D_Inv_Temperature_i(api_currentTemp) &
TempControlSoftwareSystem.SetPoint_i.D_Inv_SetPoint_i(api_setPoint) &
// I-Assm-Guard: Integration constraints for tempControl's incoming ports
I_Assm_Guard_currentTemp(api_currentTemp))
/** CEP-Pre: Compute Entrypoint Pre-Condition for tempControl via container
*
* @param pre Container holding the value of incoming ports and the pre-state values of state variables
*/
@strictpure def compute_CEP_Pre_Container(pre: TempControlPeriodic_p_tcproc_tempControl_PreState_Container_PS): B =
compute_CEP_Pre(
In_latestFanCmd = pre.In_latestFanCmd,
api_currentTemp = pre.api_currentTemp,
api_fanAck = pre.api_fanAck,
api_setPoint = pre.api_setPoint)
/** Compute Entrypoint Contract
*
* guarantee altCurrentTempLTSetPoint
* If current temperature is less than
* the current low set point, then the fan state shall be Off
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_spec_altCurrentTempLTSetPoint_guarantee(
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees < api_setPoint.low.degrees) ->: (latestFanCmd == CoolingFan.FanCmd.Off &&
api_fanCmd == CoolingFan.FanCmd.Off)
/** Compute Entrypoint Contract
*
* guarantee altCurrentTempGTSetPoint
* If current temperature is greater than
* the current high set point, then the fan state shall be On
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_spec_altCurrentTempGTSetPoint_guarantee(
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees > api_setPoint.high.degrees) ->: (latestFanCmd == CoolingFan.FanCmd.On &
api_fanCmd == CoolingFan.FanCmd.On)
/** Compute Entrypoint Contract
*
* guarantee altCurrentTempInRange
* If current temperature is greater than or equal to the
* current low set point and less than or equal to the current high set point,
* then the current fan state is maintained.
* @param In_latestFanCmd pre-state state variable
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_spec_altCurrentTempInRange_guarantee(
In_latestFanCmd: CoolingFan.FanCmd.Type,
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees >= api_setPoint.low.degrees &
api_currentTemp.degrees <= api_setPoint.high.degrees) -->:
(latestFanCmd == In_latestFanCmd &
api_fanCmd == latestFanCmd)
/** CEP-T-Guar: Top-level guarantee contracts for tempControl's compute entrypoint
*
* @param In_latestFanCmd pre-state state variable
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_CEP_T_Guar (
In_latestFanCmd: CoolingFan.FanCmd.Type,
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
compute_spec_altCurrentTempLTSetPoint_guarantee(latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd) &
compute_spec_altCurrentTempGTSetPoint_guarantee(latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd) &
compute_spec_altCurrentTempInRange_guarantee(In_latestFanCmd, latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd)
/** guarantee currentTempLTSetPoint
* If current temperature is less than
* the current low set point, then the fan state shall be Off
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_case_currentTempLTSetPoint(
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees < api_setPoint.low.degrees) -->:
(latestFanCmd == CoolingFan.FanCmd.Off &
api_fanCmd == CoolingFan.FanCmd.Off)
/** guarantee currentTempGTSetPoint
* If current temperature is greater than
* the current high set point, then the fan state shall be On
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_case_currentTempGTSetPoint(
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees > api_setPoint.high.degrees) -->:
(latestFanCmd == CoolingFan.FanCmd.On &
api_fanCmd == CoolingFan.FanCmd.On)
/** guarantee currentTempInRange
* If current temperature is greater than or equal to the
* current low set point and less than or equal to the current high set point,
* then the current fan state is maintained.
* @param In_latestFanCmd pre-state state variable
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_case_currentTempInRange(
In_latestFanCmd: CoolingFan.FanCmd.Type,
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(api_currentTemp.degrees >= api_setPoint.low.degrees &
api_currentTemp.degrees <= api_setPoint.high.degrees) -->:
(latestFanCmd == In_latestFanCmd &
api_fanCmd == latestFanCmd)
/** CEP-T-Case: Top-Level case contracts for tempControl's compute entrypoint
*
* @param In_latestFanCmd pre-state state variable
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_CEP_T_Case (
In_latestFanCmd: CoolingFan.FanCmd.Type,
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
compute_case_currentTempLTSetPoint(latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd) &
compute_case_currentTempGTSetPoint(latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd) &
compute_case_currentTempInRange(In_latestFanCmd, latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd)
/** CEP-Post: Compute Entrypoint Post-Condition for tempControl
*
* @param In_latestFanCmd pre-state state variable
* @param latestFanCmd post-state state variable
* @param api_currentTemp incoming data port
* @param api_fanAck incoming data port
* @param api_setPoint incoming data port
* @param api_fanCmd outgoing data port
*/
@strictpure def compute_CEP_Post (
In_latestFanCmd: CoolingFan.FanCmd.Type,
latestFanCmd: CoolingFan.FanCmd.Type,
api_currentTemp: TempSensor.Temperature_i,
api_fanAck: CoolingFan.FanAck.Type,
api_setPoint: TempControlSoftwareSystem.SetPoint_i,
api_fanCmd: CoolingFan.FanCmd.Type): B =
(// D-Inv-Guard: Datatype invariants for the types associated with tempControl's state variables and outgoing ports
TempSensor.Temperature_i.D_Inv_Temperature_i(api_currentTemp) &
TempControlSoftwareSystem.SetPoint_i.D_Inv_SetPoint_i(api_setPoint) &
// CEP-Guar: guarantee clauses of tempControl's compute entrypoint
compute_CEP_T_Guar (In_latestFanCmd, latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd) &
// CEP-T-Case: case clauses of tempControl's compute entrypoint
compute_CEP_T_Case (In_latestFanCmd, latestFanCmd, api_currentTemp, api_setPoint, api_fanCmd))
/** CEP-Post: Compute Entrypoint Post-Condition for tempControl via containers
*
* @param pre Container holding the values of incoming ports and the pre-state values of state variables
* @param post Container holding the values of outgoing ports and the post-state values of state variables
*/
@strictpure def compute_CEP_Post_Container(
pre: TempControlPeriodic_p_tcproc_tempControl_PreState_Container_PS,
post: TempControlPeriodic_p_tcproc_tempControl_PostState_Container_PS): B =
compute_CEP_Post(
In_latestFanCmd = pre.In_latestFanCmd,
latestFanCmd = post.latestFanCmd,
api_currentTemp = pre.api_currentTemp,
api_fanAck = pre.api_fanAck,
api_setPoint = pre.api_setPoint,
api_fanCmd = post.api_fanCmd)
}