Commit 7f165431 authored by Florence Guitton's avatar Florence Guitton

point de sauvegarde

parent 4b01e6f5
allsky.jpg

49.8 KB | W: | H:

allsky.jpg

49.8 KB | W: | H:

allsky.jpg
allsky.jpg
allsky.jpg
allsky.jpg
  • 2-up
  • Swipe
  • Onion skin
<?php
error_reporting(E_ALL);
//PASSER REQUETE
//if( $_GET["pointage"] ){
//$in='$'.'pointage!';
// getActions($in);
//}
function getActions($in){
/* port du service */
$service_port = 10001;
/* Lit l'adresse IP du serveur de destination */
//$address = gethostbyname('bbking.oca.eu');
/* Crée un socket TCP/IP. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket == false) {
echo "socket_create() a échoué : raison : " . socket_strerror(socket_last_error()) . "<br>";
}
$result = socket_connect($socket, '127.0.0.1', $service_port);
if ($socket == false) {
echo "socket_connect() a échoué : raison : ($result) " . socket_strerror(socket_last_error($socket)) . "<br>";
}
socket_write($socket, $in, 10);
$out = socket_read($socket, 50);
return $out;
}
?>
......@@ -12,8 +12,7 @@ function ping($host, $port, $timeout) {
$is_ftp = true;
$Origine_path_pictures = "c:/ALLSKY_DATA/";
$picture1 = "allsky.jpg";
//$picturenew = "allsky.jpg";
$picturenew = "/var/www/html/testFlorence/allsky.jpg";
$picturenew = "allsky.jpg";
$title1 = "Allsky calern View";
$picture2 = "allsky_detected.jpg";
$title2 = "Allsky detection calern View";
......@@ -38,10 +37,6 @@ if ($is_ftp == false)
// Ouverture du fichier pour écriture
$handle = fopen($local_file, 'w');
if($handle == FALSE){
echo $local_file;
print_r(error_get_last());
}
// Mise en place d'une connexion basique
$conn_id = ftp_connect($ftp_server, 21) or exit('Erreur : connexion au serveur FTP impossible.');
......@@ -49,9 +44,6 @@ if ($is_ftp == false)
// Identification avec un nom d'utilisateur et un mot de passe
$login_result = ftp_login($conn_id, $ftp_login, $ftp_pass);
if ($login_result == FALSE){
echo "ftp login ko\n";}
// Tente de téléchargement le fichier $remote_file et de le sauvegarder dans $handle
if (ftp_fget($conn_id, $handle, $remote_file, FTP_BINARY, 0)) {
......
// pour compiler seul : main decommente
// g++ -I ./ getparam.cpp -> a.out
#include <cstdio>
#include <cstdlib>
#include <string>
//#include <basic_string.h>
#include <iostream>
#include <fstream>
using namespace std;
template class std::basic_string<char>;
template class std::basic_ifstream<char>;
template class std::basic_istream<char>;
template class std::basic_ostream<char>;
template class std::basic_ios<char>;
#include <getparam.h>
void tracer(int res);
int getparam()
{
string line;
string myStr;
size_t pos1;
int size;
string param,valeur;
int res;
ifstream myfile;
////////////////////////////////////////////////////////////
res=0;
///////////////////////////////////////////////////////////
myfile.open ("./fichier.config");
if (myfile.is_open()) {
while (getline (myfile,line)) {
pos1 = line.find("=",0);
if ( pos1 < line.size() )
{
param=line.substr(0,pos1);
size=line.size();
valeur=line.substr(pos1+1,size-pos1);
if (param.compare(0,8,"pointage") == 0){
pointage=valeur.c_str();
}
if (param.compare(0,12,"acquisitions") == 0){
acquisitions=valeur.c_str();
}
if (param.compare(0,4,"plan") == 0){
plan=valeur.c_str();
}
if (param.compare(0,7,"cameras") == 0){
cameras=valeur.c_str();
}
if (param.compare(0,9,"setcamera") == 0){
setcamera=valeur.c_str();
}
if (param.compare(0,11,"etatmonture") == 0){
etatmonture=valeur.c_str();
}
if (param.compare(0,4,"toit") == 0){
toit=valeur.c_str();
}
if (param.compare(0,8,"automate") == 0){
automate=valeur.c_str();
}
if (param.compare(0,7,"secteur") == 0){
secteur=valeur.c_str();
}
if (param.compare(0,4,"alim") == 0){
alim=valeur.c_str();
}
if (param.compare(0,8,"pilotage") == 0){
pilotage=valeur.c_str();
}
if (param.compare(0,11,"acquisition") == 0){
acquisition=valeur.c_str();
}
if (param.compare(0,7,"filtre1") == 0){
filtre1=valeur.c_str();
}
if (param.compare(0,7,"filtre2") == 0){
filtre2=valeur.c_str();
}
if (param.compare(0,4,"CCD1") == 0){
CCD1=valeur.c_str();
}
if (param.compare(0,4,"CCD2") == 0){
CCD2=valeur.c_str();
}
if (param.compare(0,8,"Alphames") == 0){
Alphames=valeur.c_str();
}
if (param.compare(0,8,"Deltames") == 0){
Deltames=valeur.c_str();
}
if (param.compare(0,10,"ecartalpha") == 0){
ecartalpha=valeur.c_str();
}
if (param.compare(0,10,"ecartdelta") == 0){
ecartdelta=valeur.c_str();
}
if (param.compare(0,8,"commande") == 0){
commande=valeur.c_str();
}
if (param.compare(0,12,"etatcommande") == 0){
etatcommande=valeur.c_str();
}
}
}
myfile.close();
}
return(res);
}
///////////////////////////////////////
void tracer()
{
cout << "acquisitions = " << acquisitions << endl;
cout << "pointage = " << pointage << endl;
cout << "plan = " << plan << endl;
cout << "cameras = " << cameras << endl;
cout << "setcamera = " << setcamera << endl;
cout << "secteur = " << secteur << endl;
cout << "CCD1 = " << CCD1 << endl;
cout << "acquisition = " << acquisition << endl;
cout << "etatmonture = " << etatmonture << endl;
cout << "automate = " << automate << endl;
cout << "filtre2 = " << filtre2 << endl;
cout << "pilotage = " << pilotage << endl;
cout << "toit = " << toit << endl;
cout << "alim = " << alim << endl;
cout << "CCD2 = " << CCD2 << endl;
cout << "filtre1 = " << filtre1 << endl;
cout << "Deltames = " << Deltames << endl;
cout << "Alphames = " << Alphames << endl;
cout << "ecartalpha = " << ecartalpha << endl;
cout << "ecartdelta = " << ecartdelta << endl;
cout << "commande = " << commande << endl;
cout << "etatcommande = " << etatcommande << endl;
}
///////////////////////////////////////
/*int main()
{int res;
bool tr;
tr=true;
//res=get_config(tr);
res=getparam();
tracer();
return(0);
}*/
string pointage;
string acquisitions;
string plan;
string cameras;
string setcamera;
string etatmonture;
string toit;
string automate;
string secteur;
string alim;
string pilotage;
string acquisition;
string filtre1;
string filtre2;
string CCD1;
string CCD2;
string Alphames;
string Deltames;
string ecartalpha;
string ecartdelta;
string commande;
string etatcommande;
string image;
File added
......@@ -9,6 +9,7 @@ include "status_meteo.php";
include "get_pictures_allsky.php";
include "graph_data.php";
include "image.php";
include "client.php";
......@@ -42,6 +43,7 @@ include "image.php";
<img src="<?php echo $picture1 ?>" alt="<?php echo $title1 ?>" style="width:300px;height:260px;">
</a>
</div>
</center>
</td>
......@@ -49,6 +51,11 @@ include "image.php";
<center>METEO</center>
<?php exec('date', $chaine) ;
echo '<p>'.$chaine[0].'</p>';
?>
<!-- <a href="graphMeteo.php?data=Humidity"><div id="graph_humidity" style="width: 175px; height: 105px"></div></a>
<a href="graphMeteo.php?data=Temperature"><div id="graph_temp" style="width: 175px; height: 105px"></div></a>
<a href="graphMeteo.php?data=Wind"><div id="graph_windspeed" style="width: 175px; height: 105px"></div></a> -->
......@@ -84,19 +91,19 @@ include "image.php";
<center>
<?php echo '<img src='.$images[0].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;">'; ?>
<?php echo '<a href='.$images[0].'><img src='.$images[0].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;"></a>'; ?>
</center>
</td></tr>
<tr><td colspan=2>
<center>
<?php echo '<img src='.$images[1].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;">'; ?>
<?php echo '<a href='.$images[1].'><img src='.$images[1].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;"></a>'; ?>
</center>
</td></tr>
<tr><td colspan=2>
<center>
<?php echo '<img src='.$images[2].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;">'; ?>
<?php echo '<a href='.$images[2].'><img src='.$images[2].' alt="<?php echo $title1 ?>" style="width:200px;height:200px;"></a>'; ?>
</center>
</td></tr>
<tr>
......@@ -108,10 +115,11 @@ include "image.php";
<tr><td colspan=2><center> etat disque</center>
<!-- en rouge si >90% -->
<?php exec('df -h /', $chaine) ;
$info=explode(" ",$chaine[1]);
$info=explode(" ",$chaine[2]);
$number= (double)substr($info[4],-5,2);
if ($number<90){
echo '<p style="Color:green" >disque: '.explode(" ",$info[4])[1].', occupation: '.$number.'%</p>';
//echo '<p style="Color:green" >disque: '.$chaine[2].', occupation: '.$number.'%</p>';
}
else{
echo '<p style="Color:red">disque: '.explode(" ",$info[4])[1].', occupation: '.$number.'%</p>';
......@@ -133,17 +141,54 @@ else{
</td></tr>
<tr>
<td style="border:2px solid red"><center>actions</center></td>
<td style="border:2px solid red"><center>actions toit</center></td>
<!-- definir plus precessisement ce que l on y met: bouton pour selectionner requete? quel affichage ?... -->
<td style="border:2px solid red" ><center>actions</center>
<table>
<tr >
<td><center>ACTIONS OBS</center></td>
<!-- spliter la réponse pour avoir la led a allumer et sa couleur -->
<td><center>ACTIONS TOIT</center></td>
</tr>
<tr>
<td>
<form action='index.php' method='post' >
<input type="hidden" name="bouton" value="pointage" />
<input type="submit" name="submit" id="submit" value="POINTER"> <!-- :<input type="image" src="red.bmp"> -->
</form>
<?php
if ($_POST["bouton"]){
$out=getActions('$'.'pointage!');
if (strcmp($out,"KO")==0)
{echo '<input type="image" src="red.bmp">'; }
else
{echo '<input type="image" src="green.bmp">'; }
//disparait au refresh de la page!!!!
}
?>
</td>
<td>une autre action</td>
</tr>
</table>
</td>
<td><center>STATUS COM</center></td>
</tr>
<!--
<a href="graphMeteo.php?data=Wind">
<?php echo '<button type="submit"> wind :'.$notGraph_wind.' (m/s)</button>'; ?>
</a>
->
</table>
</center>
</body>
#include <string.h>
#include <stdio.h>
#include "fitsio.h"
int main(int argc, char *argv[])
{
fitsfile *fptr; /* FITS file pointer, defined in fitsio.h */
char card[FLEN_CARD]; /* Standard string lengths defined in fitsio.h */
int status = 0, single = 1, hdupos, nkeys, ii;
if (argc != 2) {
printf("Usage: listheader filename[ext] \n");
printf("\n");
printf("List the FITS header keywords in a single extension, or, if \n");
printf("ext is not given, list the keywords in all the extensions. \n");
printf("\n");
printf("Examples: \n");
printf(" listheader file.fits - list every header in the file \n");
printf(" listheader file.fits[0] - list primary array header \n");
printf(" listheader file.fits[2] - list header of 2nd extension \n");
printf(" listheader file.fits+2 - same as above \n");
printf(" listheader file.fits[GTI] - list header of GTI extension\n");
printf("\n");
printf("Note that it may be necessary to enclose the input file\n");
printf("name in single quote characters on the Unix command line.\n");
return(0);
}
if (!fits_open_file(&fptr, argv[1], READONLY, &status))
{
fits_get_hdu_num(fptr, &hdupos); /* Get the current HDU position */
/* List only a single header if a specific extension was given */
if (hdupos != 1 || strchr(argv[1], '[')) single = 1;
for (; !status; hdupos++) /* Main loop through each extension */
{
fits_get_hdrspace(fptr, &nkeys, NULL, &status); /* get # of keywords */
printf("Header listing for HDU #%d:\n", hdupos);
for (ii = 1; ii <= nkeys; ii++) { /* Read and print each keywords */
if (fits_read_record(fptr, ii, card, &status))break;
printf("%s\n", card);
}
printf("END\n\n"); /* terminate listing with END */
if (single) break; /* quit if only listing a single header */
fits_movrel_hdu(fptr, 1, NULL, &status); /* try to move to next HDU */
}
if (status == END_OF_FILE) status = 0; /* Reset after normal error */
fits_close_file(fptr, &status);
}
if (status) fits_report_error(stderr, status); /* print any error message */
return(status);
}
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <string.h> //strlen
#include <sys/socket.h>
#include <arpa/inet.h> //inet_addr
#include <unistd.h> //write
#include <stdbool.h>
#include <pthread.h>
////////////////////////
///////////////////////////////////////////
//
// compiler par :
// g++ -I ./ -c -o getparam.o getparam.cpp
// gcc -Wall serveur_automate.c getparam.o -o serveur_automate -fno-builtin -lpthread
///////////////////////////////////////////
#define PORT 10001 // The first 1000 ports are reserved for specific applications on linux
#define NUM_THREADS 2
///////////////////////////////////////////
extern string toit;
extern automate;
extern secteur;
extern alim;
// lecture des parametres :
extern int getparam();
///////////////////////
// Variables globales:
time_t t;
struct tm tm;
int client_sock, read_size;
bool mess1, mess2;
bool breakreadwrite;
FILE *trace;
int status;
///////////////////////////////////////////////////////
void *readsocket(){
//
int n1;
char buffer[256];
char buffertrace[256];
while (1) {
bzero(buffer, 256);
read_size = recv(client_sock, buffer, 256, 0);
if (read_size > 0 ){
t = time(NULL);
tm = *localtime(&t);
hms_fincor = tm.tm_hour*60+tm.tm_min;
printf("Message recu = %s (hh=%d mn=%d %d sec)\n",
buffer, tm.tm_hour, tm.tm_min, tm.tm_sec) ;
fflush(stdout);
getparam(); // lecture des etats
/* messages attendus:
$toit!
$automate!
$secteur!
$alim!
*/
n1=strncmp(buffer, "$toit!", 6);
if (n1 == 0) {
fflush(stdout);
bzero(buffer, 256);
sprintf(buffer, "$toit:%s!", toit);
status = write(client_sock, buffer, strlen(buffer));
} else {
n1=strncmp(buffer, "$automate!", 10);
if (n1 == 0) {
fflush(stdout);
bzero(buffer, 256);
sprintf(buffer, "$automate:%s!",automate );
status = write(client_sock, buffer, strlen(buffer));
} else {
n1=strncmp(buffer, "$secteur!", 9);
if (n1 == 0) {
fflush(stdout);
bzero(buffer, 256);
sprintf(buffer, "$secteur:%s!", secteur);
status = write(client_sock, buffer, strlen(buffer));
} else {
n1=strncmp(buffer, "$alim!", 6);
if (n1 == 0) {
fflush(stdout);
bzero(buffer, 256);
sprintf(buffer, "$alim:%s!", alim);
status = write(client_sock, buffer, strlen(buffer));
} else {
printf("message non reconnu %s\n", buffer);
fflush(stdout);
bzero(buffer, 256);
sprintf(buffer, "$notcommand!");
status = write(client_sock, buffer, strlen(buffer));
}
}
}
}
} else {
breakreadwrite=true;
printf("Connection arretee de la part de l'automate' %d\n", read_size);
fflush(stdout);
close(client_sock);
pthread_exit(NULL);
}
} // while (1)
} // fin de readsocket
////////////////////////////////////////////
//
////////////////////////////////////////////
////////////////////////////////////////////
int main(int argc, char *argv[]) {
int socket_desc, c;
struct sockaddr_in server, client;
char buffer[256];
size_t buffer_size;
char * word;
char * pch1;
char * pch2 ;
int status;
bool fichtrace, findujour;
//////////////////////////////
pthread_t threads[1];
//////////////////////////////////
t = time(NULL);
tm = *localtime(&t);
printf("Debut de serveur automate a %dh%dmn%ds (%d/%d/%d) \n",
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900);
fflush(stdout);
status=0;
t = time(NULL);
tm = *localtime(&t);
hh=tm.tm_hour;
mn=tm.tm_min;
fflush(stdout);
/////////////////////////////////////////////
//Create socket
socket_desc = socket(AF_INET, SOCK_STREAM, 0);
if (socket_desc == -1) {
perror(strerror(errno));
return(-1);
}
printf("Socket cree\n");
fflush(stdout);
tm = *localtime(&t);
//Preparation structure sockaddr_in
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);// INADDR_ANY;
server.sin_port = htons(PORT );
if( bind(socket_desc, (struct sockaddr *)&server, sizeof(server)) < 0){
//print the error message
perror(strerror(errno));
fflush(stdout);
return(-1);
}
/////////////////////////////////////////////////////////
while ( 0 == 0 ) {
// On attend la connection du client :
/////////////////////////////////////////////////////////
breakreadwrite=false;
listen(socket_desc, 3);
printf("Waiting for incoming connections...\n");
fflush(stdout);
c = sizeof(struct sockaddr_in);
client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c);
if (client_sock < 0){
perror(strerror(errno));
return 1;
}
t = time(NULL);
tm = *localtime(&t);
hh = tm.tm_hour;
mn = tm.tm_min;
printf("Client connected %dh %dmn (%d/%d/%d) \n", hh, mn,
tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900);
fflush(stdout);
sprintf(buffer, "$CONNECTIONOK!");
status=write(client_sock, buffer, strlen(buffer));
bzero(buffer, 256);
read_size = recv(client_sock, buffer, 256, 0);
if (read_size > 0 ){
printf("Message recu = %s \n", buffer) ;
fflush(stdout);
}
/////////////////////////////////////////////////////////
// Le client est connecte, on gere les messages de correction dans la boucle qui suit
// lancement du thread de lecture sur le socket
pthread_create(&threads[0], NULL, readsocket, NULL);
while (( 1 != 0 ) && (breakreadwrite == false)) {
/////////////////////////////////////////////////////////
//
if (status < 0) {
breakreadwrite=true;
}
} // fin de while ( 1 != 0 ) && (breakreadwrite == false)
sleep(10);
} // fin de while ( 0 == 0 )
return(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <string.h> //strlen
#include <sys/socket.h>
#include <arpa/inet.h> //inet_addr
#include <unistd.h> //write
#include <stdbool.h>
#include <pthread.h>
////////////////////////
///////////////////////////////////////////
//
// compiler par :
// g++ -I ./ -c -o getparam.o getparam.cpp
// gcc -Wall serveur_automate.c getparam.o -o serveur_automate -fno-builtin -lpthread
///////////////////////////////////////////
#define PORT 10001 // The first 1000 ports are reserved for specific applications on linux
#define NUM_THREADS 2
///////////////////////////////////////////
extern string toit;
extern automate;
extern secteur;
extern alim;
// lecture des parametres :
extern int getparam();
///////////////////////
// Variables globales:
time_t t;
struct tm tm;
int client_sock, read_size;
bool mess1, mess2;
bool breakreadwrite;
FILE *trace;
int status;
///////////////////////////////////////////////////////
void *readsocket(){
//
int n1;
char buffer[256];
char buffertrace[256];
while (1) {
bzero(buffer, 256);
read_size = recv(client_sock, buffer, 256, 0);
if (read_size > 0 ){
t = time(NULL);
tm = *localtime(&t);
hms_fincor = tm.tm_hour*60+tm.tm_min;
printf("Message recu = %s (hh=%d mn=%d %d sec)\n",
buffer, tm.tm_hour, tm.tm_min, tm.tm_sec) ;
fflush(stdout);
getparam(); // lecture des etats
/* messages attendus:
$toit!
$automate!
$secteur!
$alim!
*/
n1=strncmp(buffer, "$toit!", 6);