-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
265 changed files
with
20,639 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Do not edit this file as it will be overwritten if HAMR codegen is rerun | ||
# | ||
set -e | ||
export SCRIPT_HOME=$( cd "$( dirname "$0" )" &> /dev/null && pwd ) | ||
cd $SCRIPT_HOME | ||
|
||
# Uncomment the following to prevent terminal from closing when the app shuts down or crashes | ||
#PREVENT_CLOSE="; bash -i" | ||
|
||
# check if getopt supports long options | ||
getopt -T > /dev/null || ret=$? | ||
[[ $ret -eq 4 ]] && GNU_GETOPT=0 || GNU_GETOPT=1 | ||
|
||
OPTIONS=s:h | ||
LONGOPTS=scheduler:,help | ||
|
||
function usage { | ||
echo "" | ||
echo "Usage: <option>*" | ||
echo "" | ||
echo "Available Options:" | ||
if [[ $GNU_GETOPT -eq 0 ]]; then | ||
echo "-s, --scheduler The scheduler to use (expects one of" | ||
echo " { default, roundRobin, static, legacy};" | ||
echo " default: default)" | ||
echo "-h, --help Display this information" | ||
else | ||
echo "-s The scheduler to use (expects one of" | ||
echo " { default, roundRobin, static, legacy};" | ||
echo " default: default)" | ||
echo "-h Display this information" | ||
fi | ||
} | ||
|
||
if [[ $GNU_GETOPT -eq 0 ]]; then | ||
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") | ||
else | ||
! PARSED=$(getopt $OPTIONS "$@") | ||
fi | ||
|
||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
eval set -- "$PARSED" | ||
|
||
SCHEDULER="default" | ||
while true; do | ||
case "$1" in | ||
-h|--help) usage; exit 0 ;; | ||
-s|--scheduler) | ||
case "$2" in | ||
default|roundRobin|static|legacy) | ||
SCHEDULER="$2" ;; | ||
*) | ||
echo "Invalid scheduler: ${2}" | ||
exit 2 ;; | ||
esac | ||
shift 2 ;; | ||
--) shift; break ;; | ||
esac | ||
done | ||
|
||
# handle non-option arguments | ||
if [[ $# -ne 0 ]]; then | ||
echo "$0: Unexpected non-option arguments" | ||
usage | ||
exit 3 | ||
fi | ||
|
||
function launch() { | ||
if [ "$2" ]; then SCHEDULER_ARG=" -s ${2}"; fi | ||
if [ -n "$COMSPEC" -a -x "$COMSPEC" ]; then | ||
for APP in $1; do | ||
cygstart mintty /bin/bash -c "slang-build/${APP}${SCHEDULER_ARG}${PREVENT_CLOSE}" & | ||
done | ||
elif [[ "$(uname)" == "Darwin" ]]; then | ||
for APP in $1; do | ||
# workaround to launch the applications via separate Terminals. Create a shell script in the | ||
# /tmp directory that launches the application. Then delete the shell script when the | ||
# application exits | ||
echo "${SCRIPT_HOME}/slang-build/${APP}${SCHEDULER_ARG}${PREVENT_CLOSE} ; rm /tmp/${APP}.sh" > /tmp/${APP}.sh ; chmod +x /tmp/${APP}.sh ; open -a Terminal /tmp/${APP}.sh & | ||
done | ||
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then | ||
for APP in $1; do | ||
x-terminal-emulator -T ${APP} -e sh -i -c "slang-build/${APP}${SCHEDULER_ARG}${PREVENT_CLOSE}" & | ||
done | ||
else | ||
>&2 echo "Platform not supported: $(uname)." | ||
exit 1 | ||
fi | ||
} | ||
|
||
EXT="" | ||
if [ -n "$COMSPEC" -a -x "$COMSPEC" ]; then EXT=".exe"; fi | ||
|
||
case "${SCHEDULER}" in | ||
legacy) | ||
if [ ! -f ./slang-build/LegacyDemo${EXT} ]; then | ||
if [ -f ./slang-build/Demo${EXT} ]; then | ||
echo "Error: Found program for Slang based schedulers. Pass '--legacy' to the" | ||
echo "transpiler script in order to use the legacy scheduler" | ||
else | ||
echo "Expected program not found, have you compiled? ${SCRIPT_HOME}/slang-build/LegacyDemo${EXT}" | ||
fi | ||
exit 1 | ||
fi | ||
|
||
launch "Manage_Regulator_Interface_impl_thermostat_regulate_temperature_manage_regulator_interface_App${EXT} Manage_Heat_Source_impl_thermostat_regulate_temperature_manage_heat_source_App${EXT} Manage_Regulator_Mode_impl_thermostat_regulate_temperature_manage_regulator_mode_App${EXT} Detect_Regulator_Failure_impl_thermostat_regulate_temperature_detect_regulator_failure_App${EXT} Manage_Monitor_Interface_impl_thermostat_monitor_temperature_manage_monitor_interface_App${EXT} Manage_Alarm_impl_thermostat_monitor_temperature_manage_alarm_App${EXT} Manage_Monitor_Mode_impl_thermostat_monitor_temperature_manage_monitor_mode_App${EXT} Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_App${EXT} operator_interface_thread_impl_operator_interface_oip_oit_App${EXT} Temperature_Sensor_impl_temperature_sensor_cpi_thermostat_App${EXT} Heat_Source_impl_heat_source_cpi_heat_controller_App${EXT}"; | ||
|
||
read -p "Press enter to initialise components ..." | ||
slang-build/LegacyDemo${EXT} | ||
read -p "Press enter again to start ..." | ||
slang-build/LegacyDemo${EXT} | ||
;; | ||
*) | ||
if [ ! -f ./slang-build/Demo${EXT} ]; then | ||
if [ -f ./slang-build/LegacyDemo${EXT} ]; then | ||
echo "Error: Found program for the legacy scheduler. Either pass '-s legacy' to the" | ||
echo "run script if you want to use the legacy scheduler, or, do not pass" | ||
echo "'--legacy' to the transpiler script if you want to use a Slang based scheduler" | ||
else | ||
echo "Expected program not found, have you compiled? ${SCRIPT_HOME}/slang-build/Demo${EXT}" | ||
fi | ||
exit 1 | ||
fi | ||
|
||
launch "Demo" ${SCHEDULER}; | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Do not edit this file as it will be overwritten if HAMR codegen is rerun | ||
# | ||
APPS="Demo Manage_Regulator_Interface_impl_thermostat_regulate_temperature_manage_regulator_interface_App Manage_Heat_Source_impl_thermostat_regulate_temperature_manage_heat_source_App Manage_Regulator_Mode_impl_thermostat_regulate_temperature_manage_regulator_mode_App Detect_Regulator_Failure_impl_thermostat_regulate_temperature_detect_regulator_failure_App Manage_Monitor_Interface_impl_thermostat_monitor_temperature_manage_monitor_interface_App Manage_Alarm_impl_thermostat_monitor_temperature_manage_alarm_App Manage_Monitor_Mode_impl_thermostat_monitor_temperature_manage_monitor_mode_App Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_App operator_interface_thread_impl_operator_interface_oip_oit_App Temperature_Sensor_impl_temperature_sensor_cpi_thermostat_App Heat_Source_impl_heat_source_cpi_heat_controller_App" | ||
for APP in ${APPS}; do | ||
pkill -SIGTERM -f $APP | ||
done | ||
ME=`whoami` | ||
|
||
# message queue | ||
IPCS_Q=`ipcs -q | egrep "[0-9a-f]+[0-9]+" | grep $ME | awk '{print $2}'` | ||
for id in $IPCS_Q; do | ||
ipcrm -q $id; | ||
done | ||
|
||
# shared memory | ||
IPCS_Q=`ipcs -m | egrep "[0-9a-f]+[0-9]+" | grep $ME | awk '{print $2}'` | ||
for id in $IPCS_Q; do | ||
ipcrm -m $id; | ||
done | ||
|
||
# semaphores | ||
IPCS_Q=`ipcs -s | egrep "[0-9a-f]+[0-9]+" | grep $ME | awk '{print $2}'` | ||
for id in $IPCS_Q; do | ||
ipcrm -s $id; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include <all.h> | ||
#include <sys/types.h> | ||
#include <sys/shm.h> | ||
#include <sys/sem.h> | ||
#include <unistd.h> | ||
|
||
// This file is auto-generated. Do not edit | ||
|
||
inline void sem_op(int sid, short val) { | ||
struct sembuf sem_op; | ||
sem_op.sem_num = 0; | ||
sem_op.sem_op = val; | ||
sem_op.sem_flg = 0; | ||
semop(sid, &sem_op, 1); | ||
} | ||
|
||
inline void lock(int sid) { | ||
sem_op(sid, -1); | ||
} | ||
|
||
inline void unlock(int sid) { | ||
sem_op(sid, 1); | ||
} | ||
|
||
inline int create_sem(Z msgid) { | ||
unsigned int permission = 0666; | ||
unsigned int mask = IPC_CREAT; | ||
int sem_set_id = semget((key_t) msgid, 1, mask | permission); | ||
|
||
if (sem_set_id >= 0) { | ||
union semun { | ||
int val; | ||
struct semid_ds *buf; | ||
ushort *array; | ||
} sem_val; | ||
sem_val.val = 1; | ||
semctl(sem_set_id, 0, SETVAL, sem_val); | ||
} | ||
return sem_set_id; | ||
} | ||
|
||
Z isolette_SharedMemory_create(STACK_FRAME Z id) { | ||
unsigned int permission = 0666; | ||
unsigned int mask = IPC_CREAT; | ||
|
||
create_sem(id); | ||
|
||
int shmid = shmget((key_t) id, sizeof(union Option_8E9F45), (int) (permission | mask)); | ||
void *p = shmat(shmid, (void *) 0, 0); | ||
memset(p, 0, sizeof(union Option_8E9F45)); | ||
shmdt(p); | ||
|
||
return (Z) shmid; | ||
} | ||
|
||
// MBox2_43CC67=MBox2[art.Art.PortId, art.DataContent] | ||
Unit isolette_SharedMemory_receive(STACK_FRAME Z port, MBox2_43CC67 out) { | ||
int sid = semget((key_t) port, 1, 0666); | ||
|
||
lock(sid); | ||
|
||
int shmid = shmget((key_t) port, sizeof(union Option_8E9F45), 0666); | ||
|
||
Option_8E9F45 p = (Option_8E9F45) shmat(shmid, (void *) 0, 0); | ||
|
||
while (p->type != TSome_D29615) { // wait until there is data | ||
unlock(sid); | ||
usleep((useconds_t) 10 * 1000); | ||
lock(sid); | ||
} | ||
|
||
art_DataContent d = &p->Some_D29615.value; | ||
Type_assign(&(out->value2), d, sizeOf((Type) d)); | ||
memset(p, 0, sizeof(union Option_8E9F45)); | ||
shmdt(p); | ||
|
||
unlock(sid); | ||
} | ||
|
||
// MBox2_37E193=MBox2[art.Art.PortId, Option[art.DataContent]] | ||
Unit isolette_SharedMemory_receiveAsync(STACK_FRAME Z port, MBox2_37E193 out) { | ||
int sid = semget((key_t) port, 1, 0666); | ||
|
||
lock(sid); | ||
|
||
int shmid = shmget((key_t) port, sizeof(union Option_8E9F45), 0666); | ||
|
||
Option_8E9F45 p = (Option_8E9F45) shmat(shmid, (void *) 0, 0); | ||
|
||
if (p->type == TSome_D29615) { | ||
Type_assign(&(out->value2), p, sizeOf((Type) p)); | ||
memset(p, 0, sizeof(union Option_8E9F45)); | ||
} else { | ||
out->value2.type = TNone_964667; | ||
} | ||
|
||
shmdt(p); | ||
|
||
unlock(sid); | ||
} | ||
|
||
Unit isolette_SharedMemory_send(STACK_FRAME Z appPortId, Z componentPortId, art_DataContent d) { | ||
int sid = semget((key_t) componentPortId, 1, 0666); | ||
|
||
lock(sid); | ||
|
||
int shmid = shmget((key_t) componentPortId, sizeof(union Option_8E9F45), 0666); | ||
|
||
Option_8E9F45 p = (Option_8E9F45) shmat(shmid, (void *) 0, 0); | ||
|
||
while (p->type == TSome_D29615) { | ||
unlock(sid); | ||
usleep((useconds_t) 10 * 1000); | ||
lock(sid); | ||
} | ||
|
||
p->type = TSome_D29615; | ||
Type_assign(&(p->Some_D29615.value), d, sizeOf((Type) d)); | ||
|
||
shmdt(p); | ||
|
||
unlock(sid); | ||
} | ||
|
||
B isolette_SharedMemory_sendAsync(STACK_FRAME Z appPortId, Z componentPortId, art_DataContent d) { | ||
int sid = semget((key_t) componentPortId, 1, 0666); | ||
|
||
lock(sid); | ||
|
||
int shmid = shmget((key_t) componentPortId, sizeof(union Option_8E9F45), 0666); | ||
|
||
Option_8E9F45 p = (Option_8E9F45) shmat(shmid, (void *) 0, 0); | ||
p->type = TSome_D29615; | ||
Type_assign(&(p->Some_D29615.value), d, sizeOf((Type) d)); | ||
|
||
shmdt(p); | ||
|
||
unlock(sid); | ||
return T; | ||
} | ||
|
||
Unit isolette_SharedMemory_remove(STACK_FRAME Z id) { | ||
semctl(semget((key_t) id, 1, 0666), 0, IPC_RMID); | ||
shmctl(shmget((key_t) id, sizeof(union Option_8E9F45), 0666), IPC_RMID, NULL); | ||
} | ||
|
||
Unit isolette_Process_sleep(STACK_FRAME Z n) { | ||
usleep((useconds_t) n * 1000); | ||
} |
36 changes: 36 additions & 0 deletions
36
...ilure/Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_api.h> | ||
#include <Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.h> | ||
#include <ext.h> | ||
|
||
// This file will not be overwritten so is safe to edit | ||
|
||
static char* component_id = "isolette_single_sensor_Instance_thermostat_monitor_temperature_detect_monitor_failure"; | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_initialise_(STACK_FRAME_ONLY) { | ||
DeclNewStackFrame(caller, "Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.c", "", "isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_initialise_", 0); | ||
|
||
printf("%s: isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_initialise_ called\n", component_id); | ||
|
||
// example usage of api setters | ||
|
||
DeclNewisolette_Isolette_Data_Model_Failure_Flag_impl(t0); | ||
isolette_Isolette_Data_Model_Failure_Flag_impl_example(SF &t0); | ||
api_put_internal_failure__isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure(SF &t0); | ||
|
||
/* example usage of api loggers. Commented out as the constructed String may be too long | ||
api_logInfo__isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure(SF string("Example logInfo")); | ||
api_logDebug__isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure(SF string("Example logDebug")); | ||
api_logError__isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure(SF string("Example logError")); | ||
*/ | ||
} | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_finalise_(STACK_FRAME_ONLY) { | ||
DeclNewStackFrame(caller, "Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.c", "", "isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_finalise_", 0); | ||
} | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_timeTriggered_(STACK_FRAME_ONLY) { | ||
DeclNewStackFrame(caller, "Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.c", "", "isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_timeTriggered_", 0); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...ilure/Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef DETECT_MONITOR_FAILURE_IMPL_THERMOSTAT_MONITOR_TEMPERATURE_DETECT_MONITOR_FAILURE_H | ||
#define DETECT_MONITOR_FAILURE_IMPL_THERMOSTAT_MONITOR_TEMPERATURE_DETECT_MONITOR_FAILURE_H | ||
|
||
#include <all.h> | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_initialise_(STACK_FRAME_ONLY); | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_finalise_(STACK_FRAME_ONLY); | ||
|
||
Unit isolette_Monitor_Detect_Monitor_Failure_impl_thermostat_monitor_temperature_detect_monitor_failure_timeTriggered_(STACK_FRAME_ONLY); | ||
|
||
#endif |
Oops, something went wrong.