Skip to content

Instantly share code, notes, and snippets.

@dangpzanco
Last active August 29, 2015 13:57
Show Gist options
  • Save dangpzanco/9742302 to your computer and use it in GitHub Desktop.
Save dangpzanco/9742302 to your computer and use it in GitHub Desktop.
getData(module, type)
{
}
measureApp()
{
////sera?//////////while (1): //the app is always running, can only be stopped/paused by the OS
checkSpaceAvailable(); //limit each module data to some amount of space
//duas maneiras:
//1 - checar em cada execucao se os dados excederam o limite de "n" arquivos e deletar o mais antigo.
//2 - fazer a mesma checagem, mas com um intervalo maior de tempo e deletar mais de um arquivo antigo.
x = fopen("bat%i.txt", writeMode, TIME); //creates a file named "bat{REAL TIME}.txt" or something simpler
fprintf(x, EPS.getBatLevel()); //writes to x
fclose(x);
y = fopen("pow%i.txt", writeMode, TIME);
fprintf(x, EPS.getInstPower());
fclose(y);
z = fopen("att%i.txt", writeMode, TIME);
fprintf(x, ATT.getPos());
fclose(y);
w = fopen("pay%i.txt", writeMode, TIME);
fprintf(x, PAY.getData());
fclose(z);
return 0; // finished getting data
monitorApp(0); //call monitor app to check parameters
wait(5sec); //no need to run too frequently
}
monitorApp(option)
{
case 0:
x = fopen("bat$LAST.txt", readMode);
y = fopen("pow$LAST.txt", readMode);
if x < 0.5 and y == NOT_ENOUGH:
enter LOWPOWER_MODE(1)
appLog(lowpower_entered)???
else if x < 0.3 and y == NOT_ENOUGH:
enter LOWPOWER_MODE(2)
...
...
...
else:
enter ACTIVE_MODE
case 1:
RESTART_SYSTEM_OMG(); //case of a current peak
// NOTA:
// apos a inicializacao, gravar um codigo num arquivo de 1byte.
// sempre que ocorrer um RESTART "normal" deve-se apagar o arquivo, no caso de peak current, nao.
// em toda inicializacao deve-se primeiro checar se o arquivo contem aquele codigo.
// se ele contiver, significa que ocorreu uma reinializacao brusca, ou seja, houve pico de corrente
// e deve-se registrar o ocorrido com o app LOG.
}
cmdApp(COM_OUTPUT)
{
switch(COM_OUTPUT){
case 1:
SHUTDOWN_NOW(); // request to shutdown the sattelite when passing thru a forbidden area
case 2:
UPDATE_CONFIG(COM_OUTPUT); // ground station sends new parameters to be adopted by some part of the system
case 3:
SEND_DATA(); // request to send data collected with measureApp() back to Earth
default:
ERROR(NOT_RECOGNIZED); // the data recieved didn't follow any known paterns, keep a note in the log (?)
}
}
telApp()
{
}
logApp()
{
definir niveis de prioridade
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment