DAS  3.1.6 - 18/09/2017
Functions | Variables
RTC_Time.c File Reference
#include <fcntl.h>
#include <process.h>
#include <io.h>
#include <math.h>
#include <sys\stat.h>
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <string.h>
#include <windows.h>
#include <stdlib.h>
#include <errno.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "wsc.h"
#include "dxl.h"
#include "solpos.h"
#include "bil.h"
#include "dil.h"
+ Include dependency graph for RTC_Time.c:

Go to the source code of this file.

Functions

void D_AutoExecution (void)
 *.PRG Automatic Execution in Automatic Mode
More...
 
void D_FixSZA (void)
 
void D_WaitSZA (void)
 
void E_DeltaSZA (void)
 Re-Start or Stop the execution of the PRG file (depending on the SZA)
If the measurements at fixed delta SZA is active, this stop the execution (putting the DAS.Flag.ExeDSZA = 0) if the actual SZA is between the SZAMax and SZAMin. More...
 
void FileDat (void)
 
void FileLog (char datebuf[9], char timebuf[9])
 
void FormatData (void)
 trasform mm/gg/aa in gg/mm/aa More...
 
void FormatDataFile (void)
 
int FTP_Back_UP (char *dirhome, char *dirdata)
 
void MIGEAntiSunTrack (void)
 
void MIGESunTrack (void)
 
void SetWindowsReset ()
 
void Task_AutoEx (TIMEOUT_ID id, void *data)
 Automatic Execution Task.
. More...
 
void Task_HomeGrat (TIMEOUT_ID id, void *data)
 Home grating Task.
5) Check for reached end-run of the stepper motor for the grating
. More...
 
void Task_LOG (TIMEOUT_ID id, void *data)
 LOG Task.
Write on the LOG file during DAS execution. More...
 
void Task_Timer (TIMEOUT_ID id, void *data)
 Timer Task.
Very useful procedure that:
1) Provide to refresh the clock display
2) Check if daylight saving time is in effect
3) Calculate the Solar Zenith Angle
4) Check the FLAG.sza in order to back-up the daily data via FTP and if all the condition are satisfied the back-up is performed
5) Check for reached end-run of the stepper motor for the grating
. More...
 
void WinRes (void)
 
void WriteInit (const char *sname, char *dateffn, char *timebuff)
 Init the daily LOG file
. More...
 
void WriteStatusD (int w)
 NOT Used
. More...
 
void WriteTitolo (void)
 

Variables

bil BIL
 
das DAS
 DAS structure. More...
 
char ddmmyy [8]
 
char ddmmyyf [6]
 
dftp DFTP
 
dlog DLOG
 
DXL_par DXL
 
int ExeREM
 
flag FLAG
 flags structure More...
 
int Incr_Read_Temp
 
omuthr OMUTHR
 
stepm STEPM
 Stepper Motors. More...
 
dsza SZADelta
 

Function Documentation

§ D_AutoExecution()

void D_AutoExecution ( void  )

*.PRG Automatic Execution in Automatic Mode

Definition at line 560 of file RTC_Time.c.

References AAMEASURE, AAPOSIT, controlpanel::Albl_Azim, controlpanel::Albl_Elev, controlpanel::Albl_Script, ALMUCANTAR, AUTORNG, AVGCCD, AVGCCDHOR, AZIMUTH, BEGIN, CALIBRA, CHKEXLAMP, ChkMaster(), gui::ContrPanel, D_FixSZA(), D_WaitSZA(), DARKC, flag::DeltaSZA, DFMEASURE, das::DGeo, DIRECTSUN, E_AAMeasure(), E_AAPos(), E_Almucantar(), E_AutoRange(), E_Average(), E_AvgCCDHor(), E_Azimuth(), E_Calibra(), E_ChkExLamp(), E_Dark(), E_DeltaSZA(), E_DFMeasure(), E_DirectSun(), E_Expo(), E_ExtLampOFF(), E_ExtLampON(), E_ExtShutClose(), E_ExtShutOpen(), E_Filter(), E_GetCCD(), E_Hg_Off(), E_Hg_On(), E_HGratCal(), E_HgScan(), E_Home_SM1(), E_Home_SM2(), E_Home_SM3(), E_Home_SM4(), E_Home_SM5(), E_Home_SM6(), E_IRefSun(), E_Label(), E_Lambda(), E_Meashor(), E_Meashor2(), E_Measure(), E_Mirror(), E_NDFilter(), E_Plot(), E_Qj_Off(), E_Qj_On(), E_QjScan(), E_Radio(), E_REM(), E_Save(), E_SetCCDOffSet(), E_SetCCDPow(), E_SetCCDTemp(), E_SetCCDVBin(), E_WAIT(), E_Zenith(), ELAMPOFF, ELAMPON, master::eora, ESHUTCL, ESHUTOP, flag::exec, flag::ExeDSZA, flag::exemode, ExMast, EXPO, Fetch(), FILTER, das::Flag, GETCCD, GetDateTime(), das::Gui, H_AZI, H_FILTER, H_GRAT, H_GRAT_CAL, H_MIRROR, H_NDFW, H_ZEN, HG_OFF, HG_ON, HGSCAN, IREFSUN, LABEL, dsza::LastMSZA, d_geo::latitude, LoadExec(), d_geo::longitude, MainCommand, Master, MEASHOR, MEASHOR2, MEASURE, MIRROR, MMessageDialog(), MObjectSetText(), NDFILTER, on, PLOT, PrgNumExe, PrgNumInM, QJ_OFF, QJ_ON, QJSCAN, RADIO, omuthr::ReachTemp, REM, S_azim, S_zenetr, SAVE, SETCCDOFFS, SETCCDPOW, SETCCDTEMP, SETCCDVBIN, master::sora, Status(), flag::sza, SZACalc(), SZAMASTERM, SZAMODE, TEMPORIZED, TESTSZAMODE, time::ti_hour, time::ti_min, d_geo::timezone, WAIT, WAVELEN, XEND, and ZENITH.

Referenced by Task_AutoEx().

561 {
562 
563  struct time RTime;
564  struct date RDate;
565  struct tm today;
566  char buf[128];
567  static int mrun = 0;
568  float DecTimeStart;
569  float DecTimeStop;
570  float DecActTime;
571 
572 //int PrgNumInM = 0; ///< Actual number of PRG File in current MASTER or MASTERSZA File
573 //int PrgNumExe = 0; ///< number of PRG file in execution
574 /*************************/
575  char str[80];
576  int er;
577 // char timebuf[9];
578 // char datebuf[9];
579 // long dp = 500;
580  struct tm newtime;
581 // long ltime;
582  float t_acc = 0;
583 // int sunrs;
584 // int sunsm;
585 
586 // _strdate(datebuf);
587 
588 // time( &ltime );
589 // _strtime(timebuf);
590 // time( &ltime );
591 
592 // newtime = localtime( &ltime );
593 
594  /**************************************************************/
595  // Check if daylight saving time is in effect
596  // tm_isdst > 0 if daylight saving time is in effect
597  // tm_isdst = 0 if daylight saving time is not in effect
598  // tm_isdst < 0 if status of daylight saving time is unknown.
599 // if (newtime ->tm_isdst)
600 // newtime ->tm_hour = newtime ->tm_hour - 1;
601  //NOTE - In Daylight saving period on midnight the hours became -1 so...
602 // if((newtime -> tm_hour) == -1)
603  {
604  // Necessary for measurements performed at high latitude in summer seasons
605 // newtime->tm_hour = 23;
606 // newtime -> tm_yday = newtime -> tm_yday - 1;
607  }
608 
609  /**************************************************************/
610  GetDateTime(&RDate, &RTime, &newtime);
611 
612  /**************************************************************/
613  // Calc solar Zenith Angle (SZA)
614 // er = SZACalc(DAS.DGeo.latitude, DAS.DGeo.longitude, (float) DAS.DGeo.timezone, newtime ->tm_year + 1900,
615 // newtime -> tm_yday, newtime ->tm_hour, newtime ->tm_min, newtime ->tm_sec,
616 // 0, 1024, 0, 0);
617 
619  newtime.tm_year + 1900,
620  newtime.tm_yday, newtime.tm_hour, newtime.tm_min, newtime.tm_sec,
621  0, 1024, 0, 0);
622 
623  /**************************************************************/
624  sprintf(str, "%.1lf", 90 - S_zenetr); //S_elevref = elevation refracted
626 
627  sprintf(str, "%.1lf", S_azim);
629 
630 
631 
632 /****************************/
633 
634 
635  //gettime(&RTime);
636  GetDateTime(&RDate, &RTime, &today);
637  if(Master)
638  {
639  if(DAS.Flag.exemode == TEMPORIZED)
640  {
641 
642  if(mrun == 0)
643  {
644 
645  // check for the next available prg
646  PrgNumExe = ChkMaster(0);
647  // Time to decimal time
648  DecActTime = RTime.ti_hour + ((float)RTime.ti_min / 60);
649  DecTimeStart = ExMast[PrgNumExe].sora + ((float) ExMast[PrgNumExe].smin / 60) + ((float) ExMast[PrgNumExe].ssec / 3600);
650  DecTimeStop = ExMast[PrgNumExe].eora + ((float) ExMast[PrgNumExe].emin / 60) + ((float) ExMast[PrgNumExe].esec / 3600);
651 
652  if((DecActTime >= DecTimeStart) && (DecActTime <= DecTimeStop))
653  //if(ExMast[PrgNumExe].sora == (int) RTime.ti_hour &&
654  // ExMast[PrgNumExe].smin <= (int) RTime.ti_min)
655  {
656  on = LoadExec(ExMast[PrgNumExe].prg);
657  mrun = 1;
658  sprintf(buf,"%s",ExMast[PrgNumExe].prg );
660  }
661  }
662  else //mrun = 1
663  {
664 // if(ExMast[PrgNumExe].eora == (int) RTime.ti_hour &&
665 // ExMast[PrgNumExe].emin <= (int) RTime.ti_min)
666  // Time to decimal time
667  DecActTime = RTime.ti_hour + ((float)RTime.ti_min / 60);
668  DecTimeStart = ExMast[PrgNumExe].sora + ((float) ExMast[PrgNumExe].smin / 60) + ((float) ExMast[PrgNumExe].ssec / 3600);
669  DecTimeStop = ExMast[PrgNumExe].eora + ((float) ExMast[PrgNumExe].emin / 60) + ((float) ExMast[PrgNumExe].esec / 3600);
670 
671  if((DecActTime < DecTimeStart) || (DecActTime > DecTimeStop))
672 
673  {
674  on = 0;
675  mrun = 0;
676  //PrgNumExe = ChkMaster(0);
677  sprintf(buf,"MASTER-Wait");
679 // if(PrgNumExe > PrgNumInM || ExMast[PrgNumExe].prg == NULL)
680 // PrgNumExe = 0;
681  }
682  }
683  }
684  else if (DAS.Flag.exemode == SZAMASTERM)
685  {
686  /*********************************************************************************************/
687  //SZAMASTERM Mode 1
688  /*********************************************************************************************/
689  // This part of code take into account the different slope of the SZA function from
690  // the local noon to the local midnigth and from the local midnight to the local noon.
691  // It allows also the the execution of a MASTERSZA file where can appear different PRG
692  // files for the AM and PM Measurements
693  // FORMAT MASTERSZA: Start SZA, End SZA , PRG file
694  // (i.e.) 100.00 88.00 a.prg
695  // 87.99 70.00 e.prg
696  // 69.99 0.00 b.prg
697  // 0.00 87.99 b.prg
698  // 88.00 100.00 a.prg
699  // 100.01 180.00 c.prg
700  // 180.00 100.01 c.prg
701  // TO BE DONE: the conditions "<=12" and ">12" have to be replaced with something
702  // indicating the real time of local noon and local midnight ( I have to calculate
703  // the "effemeridis" at the begining of the program and each time the date change!!!)
704  if(mrun == 0)
705  {
706  if((int) RTime.ti_hour <= 12)
707  {
708  //Actual SZA between Start SZA and End SZA
709  if ( ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].ssza * 100))
710  && ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].esza * 100)) )
711  {
712  on = LoadExec(ExMast[PrgNumExe].prg);
713  mrun = 1;
714  sprintf(buf,"%s",ExMast[PrgNumExe].prg );
716  }
717  }
718  if((int) RTime.ti_hour > 12)
719  {
720  if ( ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].ssza * 100))
721  && ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].esza * 100)) )
722  {
723  on = LoadExec(ExMast[PrgNumExe].prg);
724  mrun = 1;
725  sprintf(buf,"%s",ExMast[PrgNumExe].prg );
727  }
728  }
729  }
730  else //mrun=1
731  {
732  if((int) RTime.ti_hour <= 12)
733  {
734  if ( ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].ssza * 100))
735  || ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].esza * 100)) )
736  {
737  on = 0;
738  mrun = 0;
739  PrgNumExe = ChkMaster(1);
740  sprintf(buf,"MASTERSZA-Wait");
742  if(PrgNumExe > PrgNumInM || ExMast[PrgNumExe].prg == NULL)
743  PrgNumExe = 0;
744  }
745  }
746  if((int) RTime.ti_hour > 12)
747  {
748  if ( ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].ssza * 100))
749  || ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].esza * 100)) )
750  {
751  on = 0;
752  mrun = 0;
753  PrgNumExe = ChkMaster(1);
754  sprintf(buf,"MASTERSZA-Wait");
756  if(PrgNumExe > PrgNumInM || ExMast[PrgNumExe].prg == NULL)
757  PrgNumExe = 0;
758  }
759  }
760  }
761  }
762  /*********************************************************************************************/
763  /*********************************************************************************************/
764  else if ((DAS.Flag.exemode == SZAMODE) | (DAS.Flag.exemode == TESTSZAMODE))
765  {
766  /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
767  //SZAMASTERM Mode 2
768  /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
769 
770  // This part of code instead doesn't consider the different slope of the SZA Function
771  // The scheduled PRG files can be specified in any order, and they will be executed
772  // when the Actual SZA is between SZAMax and SZAMin (S_zenetr > ssza & S_zenetr < esza)
773  // but when the PRG file changes (the SZAs condition are not satisfied) I have to
774  // look for the following available scheduled PRG. This means that I can't increase the
775  // "PrgNumExe" of 1, but I have to scan all the entries in the MASTERSZA.
776  // The main advantege of this mode is the possibility to write the half of record in the
777  // MASTERSZA file, but the measurements will be the same in the 24 hours.
778  // More over I don't have to use something like
779  // "88.00 0.00 namefileprg
780  // 0.00 88.00 namefileprg"
781  // to ensure the continuity of measurements during the day
782  //
783  // FORMAT MASTERSZA: SZA Min, SZA Max, PRG file
784  // (i.e.) 20.00 90.00 a.prg
785  // 90.01 100.00 b.prg
786  // 100.01 180 c.prg
787  // When the SZA is between 20 and 90 degrees DAS will execute the a.prg table (Daylight measurements)
788  // When the SZA is between 90.01 and 100.00 degrees DAS will execute the b.prg table (twilight measurements)
789  // When the SZA is between 100.01 and 180.00 degrees DAS will execute the c.prg table (night measurements)
790 
791  if(mrun == 0)
792  {
793  // check for the next available prg
794  PrgNumExe = ChkMaster(2);
795 
796  if ( ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].minsza * 100))
797  && ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].maxsza * 100)) )
798  {
799  on = LoadExec(ExMast[PrgNumExe].prg);
800  mrun = 1;
801  sprintf(buf,"%s",ExMast[PrgNumExe].prg );
803  }
804  }
805  else //mrun = 1
806  {
807  if ( ((int)(S_zenetr * 100) < (int)(ExMast[PrgNumExe].minsza * 100))
808  || ((int)(S_zenetr * 100) > (int)(ExMast[PrgNumExe].maxsza * 100)) )
809  {
810  on = 0;
811  mrun = 0;
812  sprintf(buf,"SZA MODE Wait");
814  }
815 
816  }
817  /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
818  }
819 
820  }
821 
822 /*
823 Il flag ExeDSZA all'inizio deve essere 1
824 
825  si entra nel ciclo e sicuramente esegue un ciclo di prg (fino a BEGIN)
826  poi BEGIN mette il flag ExeDSZA a zero se il SZA e' tra il massimo e il minimo di
827  SZA (E_DeltaSZA).
828  al successivo passaggio nell'autoexecution se ExeDSZA = 0 esegue il FixNextSZA e
829  fissa il SZA della prossima misura (NextSZA) e mette il flag ExeDSZA = -1.
830  Al successivo passaggio se il Flag ExeDSZA = -1 esegue il CheckSZA che mette a 1 il
831  Flag se il SZA e' uguale al NextSZA
832 
833 
834 
835 */
836 // DAS.Flag.ExeDSZA = 0;
837  if(DAS.Flag.DeltaSZA == 1)
838  {
839  if (DAS.Flag.ExeDSZA == 1) //PRG Execution
840  {
841  //Store last SZA
843  }
844  else if (DAS.Flag.ExeDSZA == 0)//Fix next SZA
845  {
846  D_FixSZA();
847  }
848  else if (DAS.Flag.ExeDSZA == -1) //Waiting next SZA
849  {
850  D_WaitSZA();
851 
852  }
853  else
854  {
855  MMessageDialog("DAS information", "Unknow value for DAS.Flag.ExeDSZA" , "OK", NULL);
856  }
857  }
858  else
859  //DAS.Flag.ExeDSZA = 1;
860 
861  // A background task or an event can launch a procedure initializing the
862  // variable MainCommand
863 
864  // Temperature of the CCD
865  // If the following instruction is commented the measdurements are carried out only
866  // when the CCD reach the working temperature, otherwise the measurements are
867  // performed continuosly
868  OMUTHR.ReachTemp = 1;
869 
870  //if(on && (OMUTHR.ReachTemp == 1) && FLAG.sza && FLAG.exec && (DAS.Flag.ExeDSZA == 1))
871  if(on && FLAG.sza && FLAG.exec && (DAS.Flag.ExeDSZA == 1))
872  {
873  /* if((SaveCnt % CHECKDGR) == 0)
874  MainCommand = QJSCAN;
875  else if ((SaveCnt % SCHEDHGRAT) == 0)
876  {
877  MainCommand = H_GRAT_CAL;
878  SaveCnt++;
879  }
880  else
881  */
882 
883  MainCommand = Fetch();
884 
885 
886  if(MainCommand)
887  {
888  // List of the activable procedures
889  switch(MainCommand)
890  {
891 
892  case AUTORNG: on = MainCommand = 0; E_AutoRange(); on = 1; break; // 1
893  case AVGCCD: on = MainCommand = 0; E_Average(); on = 1; break; // 2
894  case BEGIN: MainCommand = 0; E_DeltaSZA(); break; // 3
895  case CALIBRA: on = MainCommand = 0; E_Calibra(); on = 1; break; // 4
896  case DARKC: on = MainCommand = 0; E_Dark(); on = 1; break; // 5
897  case EXPO: on = MainCommand = 0; E_Expo(); on = 1; break; // 6
898  case FILTER: on = MainCommand = 0; E_Filter(); on = 1; break; // 7
899  case GETCCD: on = MainCommand = 0; E_GetCCD(); on = 1; break; // 8
900  case H_FILTER: on = MainCommand = 0; E_Home_SM3(); on = 1; break; // 9
901  case H_GRAT: on = MainCommand = 0; E_Home_SM2(); on = 1; break; // 10
902  case H_MIRROR: on = MainCommand = 0; E_Home_SM1(); on = 1; break; // 11
903  case HG_OFF: on = MainCommand = 0; E_Hg_Off(); on = 1; break; // 12
904  case HG_ON: on = MainCommand = 0; E_Hg_On(); on = 1; break; // 13
905  case LABEL: on = MainCommand = 0; E_Label(); on = 1; break; // 14
906  case MEASURE: on = MainCommand = 0; E_Measure(); on = 1; break; // 15
907  case MEASHOR: on = MainCommand = 0; E_Meashor(); on = 1; break; // 16
908  case MIRROR: on = MainCommand = 0; E_Mirror(); on = 1; break; // 17
909  case PLOT: on = MainCommand = 0; E_Plot(); on = 1; break; // 18
910  case QJ_OFF: on = MainCommand = 0; E_Qj_Off(); on = 1; break; // 19
911  case QJ_ON: on = MainCommand = 0; E_Qj_On(); on = 1; break; // 20
912  case RADIO: on = MainCommand = 0; E_Radio(); on = 1; break; // 21
913  case REM: on = MainCommand = 0; E_REM(); on = 1; break; // 22
914  case SAVE: on = MainCommand = 0; E_Save(); on = 1; break; // 23
915  case WAIT: on = MainCommand = 0; E_WAIT(); on = 1; break; // 24
916  case WAVELEN: on = MainCommand = 0; E_Lambda(); on = 1; break; // 25
917  case XEND: MainCommand = 0; Status("End"); on = 0; break; // 26
918  case ELAMPON: on = MainCommand = 0; E_ExtLampON(); on = 1; break; // 27
919  case ELAMPOFF: on = MainCommand = 0; E_ExtLampOFF(); on = 1; break; // 28
920  case ESHUTOP: on = MainCommand = 0; E_ExtShutOpen(); on = 1; break; // 29
921  case ESHUTCL: on = MainCommand = 0; E_ExtShutClose(); on = 1; break; // 30
922  case H_ZEN: on = MainCommand = 0; E_Home_SM5(); on = 1; break; // 31
923  case H_AZI: on = MainCommand = 0; E_Home_SM6(); on = 1; break; // 32
924  case ZENITH: on = MainCommand = 0; E_Zenith(); on = 1; break; // 33
925  case AZIMUTH: on = MainCommand = 0; E_Azimuth(); on = 1; break; // 34
926  case AAMEASURE:on = MainCommand = 0; E_AAMeasure(); on = 1; break; // 35
927  case AVGCCDHOR:on = MainCommand = 0; E_AvgCCDHor(); on = 1; break; // 36
928  case CHKEXLAMP:on = MainCommand = 0; E_ChkExLamp(); on = 1; break; // 37
929  case AAPOSIT :on = MainCommand = 0; E_AAPos(); on = 1; break; // 38
930  case IREFSUN :on = MainCommand = 0; E_IRefSun(); on = 1; break; // 39
931  case MEASHOR2 :on = MainCommand = 0; E_Meashor2(); on = 1; break; // 40
932  case SETCCDTEMP :on = MainCommand = 0; E_SetCCDTemp(); on = 1; break; // 41
933  case SETCCDVBIN :on = MainCommand = 0; E_SetCCDVBin(); on = 1; break; // 42
934  case SETCCDPOW :on = MainCommand = 0; E_SetCCDPow(); on = 1; break; // 43
935  case NDFILTER :on = MainCommand = 0; E_NDFilter(); on = 1; break; // 44
936  case H_NDFW :on = MainCommand = 0; E_Home_SM4(); on = 1; break; // 45
937  case DFMEASURE :on = MainCommand = 0; E_DFMeasure(); on = 1; break; // 46
938  case SETCCDOFFS :on = MainCommand = 0; E_SetCCDOffSet();on = 1; break; // 47
939  case QJSCAN :on = MainCommand = 0; E_QjScan(); on = 1; break; // 48
940  case H_GRAT_CAL :on = MainCommand = 0; E_HGratCal(); on = 1; break; // 49
941  case HGSCAN :on = MainCommand = 0; E_HgScan(); on = 1; break; // 49
942  case ALMUCANTAR :on = MainCommand = 0; E_Almucantar(); on = 1; break; // 51
943  case DIRECTSUN :on = MainCommand = 0; E_DirectSun(); on = 1; break; // 52
944  /*
945  case 100: MainCommand = 0; on = 0; // 26
946  Status("PROGRAM HALTED"); break;
947  case 101: MainCommand = 0; on = 1; break; // 27
948  */
949 
950  }
951 
952  }
953 
954  }
955 }
#define ELAMPOFF
External Lamp OFF.
#define H_NDFW
Home for ND FilterWheel.
gui Gui
Graphic User Interface Structure.
void E_NDFilter(void)
Set ND Filter. Set ND Filter All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:429
void E_DeltaSZA(void)
Re-Start or Stop the execution of the PRG file (depending on the SZA) If the measurements at fixed de...
Definition: RTC_Time.c:436
double S_zenetr
Definition: SOLPOS.C:92
void E_Meashor2(void)
perform horizontal measurements (2) 1) measurement with external lamp 2) measurement without the exte...
Definition: Exec.c:1370
#define LABEL
text after this command is displayed in the status label
void E_Filter(void)
Filter Wheel positioning. Procedure for Filter Wheel positioning. All the E_xxxxx() function are used...
Definition: Exec.c:761
#define SETCCDVBIN
SET the CCD vertical Binning.
void E_Hg_On(void)
HG ON. Hg lamp ON. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:246
void E_Lambda(void)
Lambda Reading. When the WAVELEN key-word is encountred in the PRG file, the Wavelength code from PRG...
Definition: Exec.c:718
#define H_GRAT_CAL
Perform home for the grating and executa a calibration.
#define H_ZEN
Home for zenith Axis.
void E_IRefSun(void)
Io Measured near the sun. This procedure carries out a measurements for the reference spectrum used i...
Definition: Exec.c:845
void E_DirectSun(void)
. All the E_xxxxx() function are used during the execution in PRG mode
Definition: Exec.c:1596
int E_Home_SM4(void)
Home for SM4. Set the reference position for Stepper motor 4 (Neutral density filter wheel)...
Definition: Exec.c:209
int Master
Definition: DAS_Spat.c:100
void E_WAIT(void)
Delay Procedure. sleep the program . All the E_xxxxx() function are used during the execution in PRG ...
Definition: Exec.c:731
double LastMSZA
SZA of the previous measurement.
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
#define AAMEASURE
Measuremets with Alt Azimut platform (stepper motors positioning simoultaneously) ...
#define AAPOSIT
Position the Alt Azimuth Platform.
int sza
= 1 -> perform measurements; = 0 -> waiting mode
int PrgNumExe
number of PRG file in execution
Definition: DAS_Spat.c:98
void E_Radio(void)
Radiometric Measurements. Procedure for Radiometric Measurements. All the E_xxxxx() function are used...
Definition: Exec.c:684
#define QJ_ON
QJ lamp on.
#define TESTSZAMODE
execution driven by SZAPRG file
double latitude
Station latitude.
int eora
End hour.
#define WAIT
stop the program execution for xx millisec
omuthr OMUTHR
Definition: RTC_Time.c:36
#define PLOT
display plot
flag Flag
Structure for different flags.
void E_Meashor(void)
perform horizontal measurements (3) 1) measurement with external lamp 2) measurement without the exte...
Definition: Exec.c:1280
#define HG_ON
HG lamp on.
void E_Label(void)
labeling. The text after the key-word is a label. All the E_xxxxx() function are used during the exec...
Definition: Exec.c:745
#define QJSCAN
Scan spectral range with QJ on.
int Fetch()
Reads the key-word in PRG Files .
Definition: DAS_Spat.c:298
void E_Hg_Off(void)
HG OFF. Hg lamp OFF. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:255
void E_AAPos(void)
alt Az Positioning. Available for SPATRAMPLUS and TROPOGAS (with the AltAzPlatform) ...
Definition: Exec.c:893
int E_Home_SM6(void)
Home for SM6. Set the reference position for Stepper motor 6 (MIGE Azimuth). All the E_xxxxx() functi...
Definition: Exec.c:182
#define CHKEXLAMP
Check External lamp status.
#define TEMPORIZED
execution driven by MASTER file
int PrgNumInM
Actual number of PRG File in current MASTER or MASTERSZA File.
Definition: DAS_Spat.c:97
#define SZAMASTERM
execution driven by MASTERSZA file ( there is the possibility to distinguish between AM and PM measur...
#define GETCCD
Performs a LIGHT Measurement (shutter opened)
int E_Home_SM5(void)
Home for SM5. Set the reference position for Stepper motor 5 (MIGE Zenith). All the E_xxxxx() functio...
Definition: Exec.c:168
void MObjectSetText(MOBJECT obj, const char *text)
#define IREFSUN
Io Measurement with AA Platform near the Sun.
void E_ExtLampON(void)
External lamp ON.
Definition: Exec.c:54
void E_Calibra(void)
Execute D_Calibra. D_Calibra is a procedure for the spectral calibration with HG lamp. Shift of HG spectral line at 4358.4 on pixel 512 All the E_xxxxx() function are used during the execution in PRG mode.
Definition: Exec.c:330
void D_FixSZA(void)
Definition: RTC_Time.c:467
d_geo DGeo
struct for Station location
MOBJECT Albl_Azim
Active Control Panel Labels for Sun Azimuth.
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
#define MEASHOR
horizontal measurements with external lamp (lamp,
void E_Azimuth(void)
Position Azimuth Axis.
Definition: Exec.c:1473
int timezone
Station timezone.
void E_HgScan(void)
Check the full spectral range with HG ON. All the E_xxxxx() function are used during the execution in...
Definition: Exec.c:1504
#define H_FILTER
Home for filter wheel.
#define WAVELEN
set the grating position
void E_Dark(void)
Execute Dark Measurement. Procedure for Dark Measurement. All the E_xxxxx() function are used during ...
Definition: Exec.c:279
void E_Qj_On(void)
Qj ON. QJ - Halogen - lamp ON. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:263
#define AUTORNG
Autoranging for optimal exposure time.
int E_GetCCD(void)
Get CCD. Execute DB_GetCCD. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:705
void E_ExtLampOFF(void)
External lamp OFF.
Definition: Exec.c:66
#define ESHUTCL
External Shutter CLOSED.
#define AZIMUTH
Positioning of Azimut Axis.
#define AVGCCDHOR
horizontal AVERAGED measurements with external lamp
void E_DFMeasure(void)
Perform Measurement setting the ND Filter Wheel also. All the E_xxxxx() function are used during the ...
Definition: Exec.c:911
int sora
Start hour.
MOBJECT Albl_Script
Active Control Panel Labels for Script in execution.
void E_SetCCDPow(void)
Set CCD Power. Set CCD Power. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:411
#define EXPO
Set the exposure time.
#define QJ_OFF
QJ lamp off.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void E_ChkExLamp(void)
Definition: Exec.c:1225
void E_Mirror(void)
Inpot Mirror positioning. Procedure for Input mirror positioning. All the E_xxxxx() function are used...
Definition: Exec.c:773
int DeltaSZA
= 1 Delta SZA measurements activated, = 0 Continous measurements
Definition: Dildef.h:240
void E_SetCCDTemp(void)
Set CCD Temp. Set CCD Temp. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:375
#define DARKC
Perform a DARK Measurement (shutter closed)
#define DIRECTSUN
#define SAVE
save the measurement in the predefined file
#define ELAMPON
External Lamp ON.
das DAS
DAS structure.
Definition: RTC_Time.c:34
#define FILTER
Set the filter position (0 - 6)
#define ZENITH
Positioning of zenith Axis.
#define MEASHOR2
Perform horizontal measurement.
void E_Average(void)
Averaged Measurements. Procedure for Averaged Measurements. All the E_xxxxx() function are used durin...
Definition: Exec.c:612
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
#define ALMUCANTAR
void D_WaitSZA(void)
Definition: RTC_Time.c:532
void E_Measure(void)
Perform Measurement. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:1060
flag FLAG
flags structure
Definition: RTC_Time.c:25
#define H_AZI
Home for Azimut Axis.
#define SETCCDOFFS
CCD Offset for HiresV.
int E_Home_SM2(void)
Home for SM2. Set the reference position for Stepper motor 2 (Grating). All the E_xxxxx() function ar...
Definition: Exec.c:139
#define SZAMODE
execution driven by SZAPRG file
int E_Home_SM3(void)
Home for SM3. Set the reference position for Stepper motor 3 (Filter Wheel). All the E_xxxxx() functi...
Definition: Exec.c:154
int MainCommand
Command switch in main loop.
Definition: DAS_Spat.c:105
void E_REM(void)
Flush string since the Carriege Return. Procedure for flushing the readed string since the Carriege R...
Definition: Exec.c:47
#define DFMEASURE
Measurement procedure using the double ND FilterWheel (when Installed)
#define CALIBRA
Auto calibration with HG Lamp (hg line at 4358A on pix 512)
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
#define SETCCDPOW
SET the CCD Power.
void E_Expo(void)
Exposuring. Read the Exposure time from PRG file. All the E_xxxxx() function are used during the exec...
Definition: Exec.c:365
controlpanel ContrPanel
Control Panel Structure.
#define MEASURE
Performs a measurement setting mirror, filter, grating, TExp...
void E_QjScan(void)
Check the full spectral range with QJ ON. All the E_xxxxx() function are used during the execution in...
Definition: Exec.c:1548
void E_HGratCal(void)
Perform home grating and HG Calibration. All the E_xxxxx() function are used during the execution in ...
Definition: Exec.c:1488
#define H_MIRROR
Home for Mirror.
void E_Save(void)
Save Image. Procedure for saving image or data. All the E_xxxxx() function are used during the execut...
Definition: Exec.c:355
double longitude
Station longitude.
int LoadExec(char *fname)
Load file for automatic execution. Procedure that load the file for automatic execution.
Definition: Load.c:1534
void E_Almucantar(void)
. All the E_xxxxx() function are used during the execution in PRG mode
Definition: Exec.c:1680
#define BEGIN
re-start the execution of the PRG file
void E_Zenith(void)
Position Zenith Axis.
Definition: Exec.c:1461
Definition: Dildef.h:234
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
void E_SetCCDVBin(void)
Set CCD Vert Binn. Set CCD Vert Binn. All the E_xxxxx() function are used during the execution in PRG...
Definition: Exec.c:446
#define H_GRAT
Home for Grating.
void E_AutoRange(void)
Autoranging. Procedure for Autoranging. All the E_xxxxx() function are used during the execution in P...
Definition: Exec.c:342
#define XEND
stop the execution of the PRG file
int ChkMaster(int mod)
Definition: DAS_Spat.c:2730
void E_AAMeasure(void)
perform measurements with the Alt Azimuth Platform perform measurements with the Alt Azimuth Platform...
Definition: Exec.c:997
MOBJECT Albl_Elev
Active Control Panel Labels for Sun Elevation.
void E_SetCCDOffSet(void)
Set the CCD Offst (only for HIRES-V. All the E_xxxxx() function are used during the execution in PRG ...
Definition: Exec.c:394
#define RADIO
Unused.
void E_ExtShutClose(void)
Close External Shutter.
Definition: Exec.c:91
#define HG_OFF
HG lamp off.
#define SETCCDTEMP
SET the CCD working Temperature.
void E_AvgCCDHor(void)
Averaged Horizontal Measurements. Procedure for Averaged Measurements with external lamp...
Definition: Exec.c:538
#define HGSCAN
Scan spectral range with HG on.
master ExMast[PRGMAXNUM]
Definition: DAS_Spat.c:55
int on
PRG execution control variabile.
Definition: DAS_Spat.c:109
int exemode
Set the Execution MODE (Execution modes)
void E_Qj_Off(void)
Qj OFF. QJ - Halogen - lamp OFF. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:271
#define ESHUTOP
External Shutter OPEN.
void E_Plot(void)
Plot Spectrum. Plot Spectrum. All the E_xxxxx() function are used during the execution in PRG mode...
Definition: Exec.c:237
dsza SZADelta
Definition: RTC_Time.c:32
int SZACalc(double d_lat, double d_long, double d_tzone, int d_year, int d_daynum, int d_hour, int d_minute, int d_second, float d_temp, float d_press, float d_tilt, float d_aspect)
Calc. Solar angles and radiatives quantities. .
Definition: CalcSZA.c:89
int E_Home_SM1(void)
Home for SM1. Set the reference position for Stepper motor 1 (Input Mirror). All the E_xxxxx() functi...
Definition: Exec.c:111
#define MIRROR
set mirror position (0-3)
#define NDFILTER
SET the ND FilterWheel Position.
int ReachTemp
Target Temperature status.
#define AVGCCD
Averaged measurement.
#define REM
text after this is a comment
void E_ExtShutOpen(void)
Open External Shutter.
Definition: Exec.c:79
+ Here is the caller graph for this function:

§ D_FixSZA()

void D_FixSZA ( void  )

Definition at line 467 of file RTC_Time.c.

References dsza::Dailymaxsza, dsza::Dailyminsza, dsza::DeltaSZA, flag::ExeDSZA, das::Flag, dsza::LastMSZA, dsza::NextSZA, and S_zenetr.

Referenced by D_AutoExecution(), DB_Pause(), and Task_CCD_Temp().

468 {
469 
470 
471  double SZAInt;
472  double SZATest;
473  int k=0;
474  double er;
475 
476  if((S_zenetr - SZADelta.LastMSZA) > 0) // 66.5-66 > 0 --> Afternoon period -->After local noon
477  {
478 
479  SZAInt = floor(S_zenetr);
480  k = 1;
481  do
482  {
483  SZATest = SZAInt + ((double)k * SZADelta.DeltaSZA);
484  SZADelta.NextSZA = SZATest;
485  k++;
486  er = SZATest - (S_zenetr + SZADelta.DeltaSZA);
487  }while(er<0);
489  DAS.Flag.ExeDSZA = -1;
491  {
493  DAS.Flag.ExeDSZA = 1;
494  }
496  {
498  DAS.Flag.ExeDSZA = 1;
499  }
500 
501 
502 
503  }
504  else if ((S_zenetr - SZADelta.LastMSZA) < 0)//66.2-66.5 < 0 --> Morning Period --> Before Local Noon
505  {
506  SZAInt = ceil((double)S_zenetr); //62 62.45
507  k = 1;
508  do
509  {
510  SZATest = SZAInt - ((double)k * SZADelta.DeltaSZA); //62.1
511  SZADelta.NextSZA = SZATest;
512  k++;
513  er = SZATest-(S_zenetr );
514 
515  }while(er > 0 );
516  DAS.Flag.ExeDSZA = -1;
517 
519  {
521  DAS.Flag.ExeDSZA = 1;
522  }
524  {
526  DAS.Flag.ExeDSZA = 1;
527  }
528 
529  }
530 }
double S_zenetr
Definition: SOLPOS.C:92
double Dailymaxsza
Daily maximum SZA.
double LastMSZA
SZA of the previous measurement.
flag Flag
Structure for different flags.
double Dailyminsza
Daily minimum SZA.
double DeltaSZA
DeltaSZA.
das DAS
DAS structure.
Definition: RTC_Time.c:34
double NextSZA
SZA of the Next measurement.
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
dsza SZADelta
Definition: RTC_Time.c:32
+ Here is the caller graph for this function:

§ D_WaitSZA()

void D_WaitSZA ( void  )

Definition at line 532 of file RTC_Time.c.

References flag::exec, flag::ExeDSZA, das::Flag, dsza::NextSZA, S_zenetr, and Status().

Referenced by D_AutoExecution().

533 {
534  char buff[256];
535  int a, b, c;
536  a= (int)(S_zenetr *100);
537  b=(int)(SZADelta.NextSZA*100);
538 
539  c = abs(a-b);
540 
541  if(c == 0)
542  {
543  DAS.Flag.ExeDSZA = 1; //This RESUME the measurements (via PRG file)
544  }
545  else
546  {
547  if(FLAG.exec == 0)
548  {
549  Status("Execution Paused");
550  }
551  else
552  {
553  sprintf(buff, "Waiting for SZA = %.2f", SZADelta.NextSZA);
554  Status(buff);
555  }
556  }
557 }
double S_zenetr
Definition: SOLPOS.C:92
flag Flag
Structure for different flags.
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
das DAS
DAS structure.
Definition: RTC_Time.c:34
flag FLAG
flags structure
Definition: RTC_Time.c:25
double NextSZA
SZA of the Next measurement.
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
dsza SZADelta
Definition: RTC_Time.c:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ E_DeltaSZA()

void E_DeltaSZA ( void  )

Re-Start or Stop the execution of the PRG file (depending on the SZA)
If the measurements at fixed delta SZA is active, this stop the execution (putting the DAS.Flag.ExeDSZA = 0) if the actual SZA is between the SZAMax and SZAMin.

Returns
void

Definition at line 436 of file RTC_Time.c.

Referenced by D_AutoExecution(), and FTP_Back_UP().

437 {
438 
439  int a, b, c;
440 
441  ExeREM = 0;
442 
443  a = (int) (S_zenetr * 100); //Actual SZA
444  b = (int) ((SZADelta.Dailyminsza+SZADelta.DeltaSZA) * 100); //Daily Min SZA + DeltaSZA
445  c = (int) (SZADelta.MaxSZA * 100); //Max SZA
446  PrgCnt = 0;
447  if(DAS.Flag.DeltaSZA == 1)
448  {
449  //if((int)(S_zenetr >= SZADelta.MinSZA) && (int)(S_zenetr <= SZADelta.MaxSZA))
450  if((a >= b) && ( a <= c))
451  {
452  DAS.Flag.ExeDSZA = 0; //This STOP the measurements (via PRG file)
453  Status("In E_DeltaSZA");
454  delay(500);
455  }
456  else
457  DAS.Flag.ExeDSZA = 1;
458  }
459  else
460  DAS.Flag.ExeDSZA = 1;
461 
462  ExeREM = 1;
463 }
double S_zenetr
Definition: SOLPOS.C:92
flag Flag
Structure for different flags.
double Dailyminsza
Daily minimum SZA.
long PrgCnt
Counter for the position in the PRG file.
Definition: DAS_Spat.c:93
int ExeREM
Definition: DAS_Spat.c:143
double MaxSZA
Maximum SZA.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
double DeltaSZA
DeltaSZA.
int DeltaSZA
= 1 Delta SZA measurements activated, = 0 Continous measurements
das DAS
DAS structure.
Definition: RTC_Time.c:34
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
dsza SZADelta
Definition: RTC_Time.c:32
+ Here is the caller graph for this function:

§ FileDat()

void FileDat ( void  )

Definition at line 120 of file RTC_Time.c.

121 {
122 // int k, x, i;
123 // char datebuf[9];
124 // char dday[2], dmonth[2], dyear[2];
125 /*
126  _strdate(datebuf);
127  k = 0;
128  x = 0;
129  for(i = 0; i < 9; i++)
130  {
131  if(i<2)
132  {
133  dmonth[i] = datebuf[i];
134  }
135 
136  if(i > 2 && i < 5)
137  {
138  dday[k] = datebuf[i];
139  k++;
140  }
141  if(i > 5 && i < 8)
142  {
143  dyear[x] = datebuf[i];
144  x++;
145  }
146  }
147  sprintf(sd,"%c%c%c%c%c%c", dday[0],dday[1],dmonth[0],dmonth[1],dyear[0],dyear[1]);
148  Status(filedati);
149  return SaveDate
150  */
151 }

§ FileLog()

void FileLog ( char  datebuf[9],
char  timebuf[9] 
)

Definition at line 111 of file RTC_Time.c.

References FormatDataFile().

112 {
113 
114  _strdate(datebuf);
115  _strtime(timebuf);
116  FormatDataFile();
117 }
void FormatDataFile(void)
Definition: RTC_Time.c:77
+ Here is the call graph for this function:

§ FormatData()

void FormatData ( void  )

trasform mm/gg/aa in gg/mm/aa

Definition at line 45 of file RTC_Time.c.

References ddmmyy.

46 {
47  int k, x, i;
48  char datebuf[9];
49  char dday[2], dmonth[2], dyear[2];
50 
51 
52  _strdate(datebuf);
53  k = 0;
54  x = 0;
55  for(i = 0; i < 9; i++)
56  {
57  if(i<2)
58  {
59  dmonth[i] = datebuf[i];
60  }
61 
62  if(i > 2 && i < 5)
63  {
64  dday[k] = datebuf[i];
65  k++;
66  }
67  if(i > 5 && i < 8)
68  {
69  dyear[x] = datebuf[i];
70  x++;
71  }
72  }
73  sprintf(ddmmyy,"%c%c/%c%c/%c%c", dday[0],dday[1],dmonth[0],dmonth[1],dyear[0],dyear[1]);
74 }
char ddmmyy[8]
Definition: RTC_Time.c:38

§ FormatDataFile()

void FormatDataFile ( void  )

Definition at line 77 of file RTC_Time.c.

References ddmmyyf.

Referenced by FileLog().

78 {
79  int k, x, i;
80  char datebuf[9];
81  char dday[2], dmonth[2], dyear[2];
82 
83  _strdate(datebuf);
84  k = 0;
85  x = 0;
86  for(i = 0; i < 9; i++)
87  {
88  if(i<2)
89  {
90  dmonth[i] = datebuf[i];
91  }
92 
93  if(i > 2 && i < 5)
94  {
95  dday[k] = datebuf[i];
96  k++;
97  }
98  if(i > 5 && i < 8)
99  {
100  dyear[x] = datebuf[i];
101  x++;
102  }
103  }
104 
105  sprintf(ddmmyyf,"%c%c%c%c%c%c", dday[0],dday[1],dmonth[0],dmonth[1],dyear[0],dyear[1]);
106 
107 
108 }
char ddmmyyf[6]
Definition: RTC_Time.c:39
+ Here is the caller graph for this function:

§ FTP_Back_UP()

int FTP_Back_UP ( char *  dirhome,
char *  dirdata 
)

Definition at line 336 of file RTC_Time.c.

References _MAX_PATH, dsza::Dailyminsza, delay(), flag::DeltaSZA, dsza::DeltaSZA, das::DOption, E_DeltaSZA(), flag::ExeDSZA, ExeREM, das::Flag, dftp::ftppwd, dftp::ftpserver, flag::ftpstatus, dftp::ftpuser, spectrumheader::location, dsza::MaxSZA, MMessageDialog(), PrgCnt, S_zenetr, optionini::savingmode, bil::SPH, and Status().

Referenced by Task_Timer().

337 {
338  int er = 0, l;
339  char COMANDO[_MAX_PATH];
340  char buff[_MAX_PATH];
341 
342  char dailydir[6];
343  FILE *fd;
344  dailydir[0] = '\0';
345 
346 
347 
348  if(dirdata[0] != 0)
349  {
350 
351 
352  l = strlen(dirdata);
353  sprintf(dailydir, "%s", dirdata + (l - 6));
354 
355  sprintf(buff, "%s\\Config\\%s", dirhome, "DataTransf.txt");
356  fd = fopen(buff, "w");
357 
358  if(fd == NULL)
359  {
360  MMessageDialog("DAS information", "Problems in opening file", " Ok ", NULL);
361  return 1;
362  }
363 
364  sprintf(buff, "%s\n", DFTP.ftpuser);
365  fprintf(fd,buff);
366 
367  sprintf(buff, "%s\n", DFTP.ftppwd);
368  fprintf(fd,buff);
369 
370  sprintf(buff, "%s\n", "bi");
371  fprintf(fd,buff);
372 
373  buff[0] = '\0';
374  sprintf(buff, "mkdir %s\n", dailydir);
375  fprintf(fd,buff);
376 
377  buff[0] = '\0';
378  sprintf(buff, "cd %s\n", dailydir);
379  fprintf(fd,buff);
380 
382  {
383  sprintf(buff, "mput %s\\*.bif\n", dirdata);
384  fprintf(fd,buff);
385  }
386  else
387  {
388  sprintf(buff, "mput %s\\*.dat\n", dirdata);
389  fprintf(fd,buff);
390 
391  }
392 
393  buff[0] = '\0';
394  sprintf(buff, "cd ..\n");
395  fprintf(fd,buff);
396 
397 
398  //Log file
399  buff[0] = '\0';
400  sprintf(buff, "%s\\Log\\%s%s.log\n", dirhome, BIL.SPH.location,dailydir);
401  fprintf(fd,buff);
402 
403 
404 
405  sprintf(buff, "%s\n", "quit");
406  fprintf(fd,buff);
407 
408  fclose(fd);
409 
410 
411  COMANDO[0] = '\0';
412 
413  //Write Command file
414  sprintf(buff, "%s\\Config\\%s", dirhome, "DataTransf.txt");
415 
416  sprintf(COMANDO, "ftp -i -s:%s %s",buff, DFTP.ftpserver);
417 
418 // er = WinExec(COMANDO, SW_HIDE); // or SW_SHOW
419  er = WinExec(COMANDO, SW_SHOW); // or
420 
421  FLAG.ftpstatus = 1;
422 
423 
424  }
425  return 0;
426 
427 }
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
bil BIL
Definition: RTC_Time.c:30
char ftpuser[32]
FTP server users.
das DAS
DAS structure.
Definition: RTC_Time.c:34
char ftpserver[32]
FTP server address.
#define _MAX_PATH
Definition: Dildef.h:202
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
flag FLAG
flags structure
Definition: RTC_Time.c:25
int ftpstatus
0 = FTP Back-UP Not executed; 1 = FTP Back-UP executed;
char location[4]
Name of the Station (BLQ, LPA, EVR, TNB, DMC.....)
Definition: bildef.h:128
char ftppwd[32]
FTP server pwd.
dftp DFTP
Definition: RTC_Time.c:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ MIGEAntiSunTrack()

void MIGEAntiSunTrack ( void  )

Definition at line 206 of file RTC_Time.c.

References elev, S_azim, S_zenetr, and SD_PosAADev().

Referenced by Task_Timer().

207 {
208 
209  char str[16];
210  float azi, elev;
211 
212  sprintf(str, "%.01lf", (90 + S_zenetr) );
213  elev = (float)atof(str);
214 
215  sprintf(str, "%.01lf", S_azim);
216  azi = (float)atof(str);
217 
218  SD_PosAADev(elev, azi);
219 
220 }
double S_zenetr
Definition: SOLPOS.C:92
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
int SD_PosAADev(double z, double a)
perform the simoultaneous positioning of the AltAzimuth platform z = Zenith Axis a = Grating Position...
Definition: Spat_Device.c:447
static double elev
Definition: SOLPOS.C:130
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ MIGESunTrack()

void MIGESunTrack ( void  )

Definition at line 222 of file RTC_Time.c.

References elev, S_azim, S_zenetr, and SD_PosAADev().

Referenced by Task_Timer().

223 {
224 
225  char str[16];
226  float azi, elev;
227 
228  sprintf(str, "%.01lf", (90 - S_zenetr));
229  elev = (float)atof(str);
230 
231  sprintf(str, "%.01lf", S_azim);
232  azi = (float)atof(str);
233 
234 // azi= MIGEActualZenAz(0);
235 // elev= MIGEActualZenAz(1);
236 
237  SD_PosAADev(elev, azi);
238 
239 
240 
241 
242 
243 }
double S_zenetr
Definition: SOLPOS.C:92
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
int SD_PosAADev(double z, double a)
perform the simoultaneous positioning of the AltAzimuth platform z = Zenith Axis a = Grating Position...
Definition: Spat_Device.c:447
static double elev
Definition: SOLPOS.C:130
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ SetWindowsReset()

void SetWindowsReset ( )

Definition at line 1125 of file RTC_Time.c.

References CELSIUS, DAS_StartDOY, DAS_StartHour, DB_Pause(), DC_SetTemp(), das::DOption, das::Flag, GetDateTime(), RDAY, optionini::resetFreq, optionini::resetType, RHOUR, and flag::WindowsReboot.

Referenced by Task_Timer().

1126 {
1127 
1128 // char buff[80];
1129 // float CCD_Pwr;
1130  int ActualHour;
1131  int ActualDOY;
1132  struct time RTime;
1133  struct date RDate;
1134  struct tm today;
1135 
1136  GetDateTime(&RDate, &RTime, &today);
1137 
1138 
1139  // Time to decimal time
1140  ActualHour = (int)(((double)today.tm_hour + (1.0/60.0*(double)today.tm_min)) * 10); // + ((float) today.tm_min / 60) + ((float) today.tm_sec / 3600);
1141  ActualDOY = (int)(((double)today.tm_yday + (1/24*(double)today.tm_hour))) * 10;;
1142 
1143  //For shutdown and restart for hourly periods (for debug & testing)
1144 if(DAS.DOption.resetType == RHOUR)
1145 {
1146  //check the start time and actual time
1147  if(labs(ActualHour - DAS_StartHour) >= (DAS.DOption.resetFreq * 10))
1148  {
1149  //stop the measurements and wait until the current one is finished
1150  DB_Pause();
1151 
1152  //shutdown CCD (wait until when CCD peltier power is 0)
1153  DC_SetTemp(25.0, CELSIUS, 0);
1154 
1155 
1156 
1157  DAS.Flag.WindowsReboot = 1;
1158 
1159  }
1160 
1161 }
1162  //For shutdown and restart for hourly periods
1163 if(DAS.DOption.resetType == RDAY)
1164 {
1165  //check the start time and actual time
1166  if(labs(ActualDOY - DAS_StartDOY) >= (DAS.DOption.resetFreq * 10))
1167  {
1168  //stop the measurements and wait until the current one is finished
1169  DB_Pause();
1170 
1171  //shutdown CCD (wait until when CCD peltier power is 0)
1172  DC_SetTemp(25.0, CELSIUS, 0);
1173 
1174  DAS.Flag.WindowsReboot = 1;
1175 
1176  }
1177 
1178 
1179 
1180 }
1181 
1182 }
optionini DOption
Options for DAS execution.
#define RDAY
double filter wheel
flag Flag
Structure for different flags.
CTYPE void DLL DC_SetTemp(double TargetTemperature, int Scale, int Camera)
Procedure that turns the camera cooler on and allows you to set an operative temperature of the CCD...
Definition: Dildef.h:240
int resetFreq
frequency of DAS/Windows Reset
int DAS_StartDOY
Definition: DAS_Spat.c:107
void DB_Pause(void)
Definition: CreateForms.c:3766
das DAS
DAS structure.
Definition: RTC_Time.c:34
#define RHOUR
simple filter wheel
int WindowsReboot
Flag that became 1 when Windows reboot is setted (SetWinowsReset)
#define CELSIUS
Return CCD temperature in Celsius.
Definition: dcldef.h:449
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
Definition: Dildef.h:234
int resetType
type of period for DAS Reset: 0=Hours, 1=Days
int DAS_StartHour
Definition: DAS_Spat.c:106
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Task_AutoEx()

void Task_AutoEx ( TIMEOUT_ID  id,
void *  data 
)

Automatic Execution Task.
.

Definition at line 963 of file RTC_Time.c.

References AUTOEX_TASK_TIME, D_AutoExecution(), and MAddTimeout().

Referenced by LaunchBackTask().

965 {
966  // Here it can be added a call to a function for the execution of the operations
967  // in the while(1) loop in the RunFULL function.
968  // This in order to remove the MLoopWhileEvents(0) in RunFULL for a low use of the CPU
969  // i.e. -->
970  D_AutoExecution();
971 
972 
973  id = MAddTimeout(AUTOEX_TASK_TIME, Task_AutoEx, data); // rilancia il task
974 
975 }
void Task_AutoEx(TIMEOUT_ID id, void *data)
Automatic Execution Task. .
Definition: RTC_Time.c:963
void D_AutoExecution(void)
*.PRG Automatic Execution in Automatic Mode
Definition: RTC_Time.c:560
#define AUTOEX_TASK_TIME
Autoexecution.
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
TIMEOUT_ID MAddTimeout(CARD32 tmout, TIMEOUT_CB cb, void *ud)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Task_HomeGrat()

void Task_HomeGrat ( TIMEOUT_ID  id,
void *  data 
)

Home grating Task.
5) Check for reached end-run of the stepper motor for the grating
.


Definition at line 980 of file RTC_Time.c.

References controlpanel::Albl_LS, AMS1, AMS_AzzeraCoord(), AMS_chkbitsts(), AMS_MotorOn_Off(), AMS_ReadStep(), flag::AMSPres, DXL_par::bufrx, gui::ContrPanel, flag::exemode, das::Flag, GRAT_TASK_TIME, ids::GRATHOME, das::Gui, HomeGratingFast(), IDS, MANUAL, MObjectSetText(), MRefreshTimeout(), stepm::postime, PRGFILE, stepm::SM_B, st, Status(), das::StepM, SZAMASTERM, SZAMODE, TEMPORIZED, and TESTAMS.

Referenced by E_Home_SM1(), HomeTrack(), and LaunchBackTask().

981 {
982  int cwer = 0, ccwer = 0; //Clock Wise, Counter Clock Wise er values
983  char buf[80];
984  int er = 0;
985  long ns, np;
986  int HomeGratActive = 0;
987  unsigned long st, et, x;
988  long tout;
989 
990  /**************************************************************/
991  // check for reached end-run of the stepper motor for the grating
992  if ((DAS.Flag.exemode == TEMPORIZED) |
993  (DAS.Flag.exemode == PRGFILE) |
994  (DAS.Flag.exemode == TESTAMS) |
995  (DAS.Flag.exemode == MANUAL) |
996  (DAS.Flag.exemode == SZAMASTERM) |
997  (DAS.Flag.exemode == SZAMODE))
998  {
999  if(FLAG.AMSPres == 0)
1000  {
1001 
1002  cwer = AMS_chkbitsts(AMS1, 6); //AMS1-IOP(6) = 1: end-run Vis.
1003  ccwer = AMS_chkbitsts(AMS1, 7);//AMS1-IOP(7) = 1: end-run UV
1004 
1005  if (cwer || ccwer)
1006  {
1007  //Flag to be passed to HomeGratingFast in order to refresh the task time
1008  HomeGratActive = 1;
1009  //Read steps
1010  np = AMS_ReadStep(0, 1);
1011  //Grating Motor OFF
1012  er = AMS_MotorOn_Off(0, 1, 0);
1013  //wait for remaining steps finalization
1014 
1015 
1016 //*********************************************
1017 
1018 
1019  tout = DAS.StepM.postime[AMS1][DAS.StepM.SM_B]+1000;
1020  st = GetTickCount();
1021  do
1022  {
1023  et = GetTickCount();
1024  x = labs(et - st);
1025  //MLoopWhileEvents(0);
1026  //if((x % 10 == 0) && (x > 0))
1027  if(x > 0)
1028  {
1029 
1030  sprintf(buf, "%.1lf sec. left", (double)fabs(((double)(labs(et - st) - tout))/1000.0 ));
1031  Status (buf);
1032 
1033  }
1034  }while(labs(et - st) < tout);
1035 
1036 
1037 
1039 
1040 
1041 
1042  //delay(30000);
1043 
1044  er = AMS_AzzeraCoord(0, 1);
1045  ns = AMS_ReadStep(0, 1);
1046  sprintf(buf, "%ld", ns);
1047 
1048  //Mirror and Grating Motor ON
1049  er = AMS_MotorOn_Off(0, 1, 1);
1050 
1051  DXL.bufrx[0] = '0';
1052  DXL.bufrx[1] = '0';
1053  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], "4358");
1054  HomeGratingFast(HomeGratActive);
1055 
1056  }
1057  else
1058  {
1059  //Home Grating Task
1061 
1062  }
1063  }
1064  }
1065 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
void MRefreshTimeout(TIMEOUT_ID *pid, CARD32 msec, TIMEOUT_CB cb, void *ud)
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
flag Flag
Structure for different flags.
int HomeGratingFast(int mod)
(Fastest) Grating in the reference Position. The Grating reaches the reference Position. Similar to HomeGrating(void), but faster
Definition: Init.c:780
#define TEMPORIZED
execution driven by MASTER file
#define SZAMASTERM
execution driven by MASTERSZA file ( there is the possibility to distinguish between AM and PM measur...
void MObjectSetText(MOBJECT obj, const char *text)
int GRATHOME
Home for Grating ID.
char bufrx[1024]
Rx buffer.
Definition: DXL.H:20
long postime[AMSMAX][2]
time necessary for positioning
int AMS_MotorOn_Off(int id, int mtr1, int mtr2)
Motor ON-OFF. Switch On-Off the selected motor of the selected AMS.
Definition: Dxl.c:930
DXL_par DXL
Definition: RTC_Time.c:24
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
#define GRAT_TASK_TIME
Grating Home.
#define PRGFILE
execution driven by *.prg file
das DAS
DAS structure.
Definition: RTC_Time.c:34
unsigned long AMS_ReadStep(int id, int motor)
read performed steps Procedure for the determination of the number of steps executed.
Definition: Dxl.c:60
ids IDS
ID tasks.
Definition: DAS_Spat.c:54
flag FLAG
flags structure
Definition: RTC_Time.c:25
#define SZAMODE
execution driven by SZAPRG file
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
controlpanel ContrPanel
Control Panel Structure.
int AMS_AzzeraCoord(int id, int mtr)
Set to zero the number of steps on the selected motor Set to zero the number of steps on the selecte...
Definition: Dxl.c:439
#define AMS1
AMS1 address.
int AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
Definition: Dxl.c:192
static double st
Definition: SOLPOS.C:142
void Task_HomeGrat(TIMEOUT_ID id, void *data)
Home grating Task. 5) Check for reached end-run of the stepper motor for the grating ...
Definition: RTC_Time.c:980
int AMSPres
AMS Presence: 0 = AMS FOUND; 1 = AMS NOT FOUND.
int exemode
Set the Execution MODE (Execution modes)
#define TESTAMS
execution for testing AMS&#39;s devices
#define MANUAL
execution in manual mode (for lab use)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Task_LOG()

void Task_LOG ( TIMEOUT_ID  id,
void *  data 
)

LOG Task.
Write on the LOG file during DAS execution.

Definition at line 246 of file RTC_Time.c.

References controlpanel::Albl_CS, controlpanel::Albl_LS, flag::AMS_H, marconi::CCDTemp, gui::ContrPanel, bil::DFILEM, das::DGeo, dlog::flog, dlog::fsmlog, GetDateTime(), das::Gui, LOG_TASK_TIME, d_fileman::LOGDIR, MAddTimeout(), das::Marconi, MObjectGetText(), dlog::ndate, dlog::ntime, dlog::odate, d_geo::s_name, ShutterOpening(), SZA_FindMin(), and omuthr::Temperature.

Referenced by LaunchBackTask().

247 {
248  int fc;
249  int cont;
250  char str[80];
251  char tit1[256];
252 // time_t ltime;
253  struct tm today;
254  struct time RTime;
255  struct date RDate;
256 
257  GetDateTime(&RDate, &RTime, &today);
258  /* Get UNIX-style time */
259  //time( &ltime );
260  /* Use time structure to build a customized time string. */
261  //today = localtime( &ltime );
262  /* Use strftime to build a customized time string. */
263  strftime( DLOG.ndate, 7,"%y%m%d", &today );
264  strftime( DLOG.ntime, 9,"%H:%M:%S", &today );
265 
266  // If the date is changed, the log filename changes...
267  if(strcmp(DLOG.ndate, DLOG.odate) != 0)
268  {
269  sprintf(DLOG.odate, "%s",DLOG.ndate);
270  sprintf(DLOG.flog,"%s\\%s%s.log", BIL.DFILEM.LOGDIR, DAS.DGeo.s_name, DLOG.ndate);
271 
272  //for stepper motors log
273  sprintf(DLOG.fsmlog,"%s\\SM_%s.log", BIL.DFILEM.LOGDIR, DLOG.ndate);
274 
275  fc = open(DLOG.flog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
276  if(fc < 0) return;
277 
278  // Write title for monitored values
279  sprintf(tit1,"Time TCCD PwCCD PwPlt T.Optic T.IntSX T.OutSX T.IntDX T.OutDX T.Grat SPARE T.Elec SPARE SPARE SPARE SPARE SPARE SPARE SPARE SPARE \n");
280  write(fc, tit1, strlen(tit1));
281  close(fc);
282 
283  SZA_FindMin(); //...and the minimum daily SZA is calculate...
284 
285  ShutterOpening(1);// ...and write on the Shutter.ini the number of shuts
286 
287  }
288 
289  fc = open(DLOG.flog, O_WRONLY | O_APPEND | O_TEXT| O_CREAT, S_IWRITE);
290  if(fc > 0)
291  {
292 
293  sprintf(str, "%s ",DLOG.ntime); //Time
294  write(fc, str, strlen(str));
295 
296  sprintf(str, "%5.1lf ", DAS.Marconi.CCDTemp); // Temperature CCD
297  //MObjectGetText(DAS.Gui.ContrPanel.Albl_CS[0], str);
298  //strcat(str," ");
299  write(fc, str, strlen(str));
300 
301  MObjectGetText(DAS.Gui.ContrPanel.Albl_CS[1], str); //Power CCD
302  strcat(str," ");
303  write(fc, str, strlen(str));
304 
305  MObjectGetText(DAS.Gui.ContrPanel.Albl_LS[7], str); //Power Peltier
306  strcat(str," ");
307  write(fc, str, strlen(str));
308 
309 
310 
311  for(cont = 15; cont >= 0; cont--)
312  {
313 
314  sprintf(str, "%5.1lf ", OMUTHR.Temperature[cont]);
315  write(fc, str, strlen(str));
316  }
317 
318  sprintf(str, "\n","");
319  write(fc, str, strlen(str));
320 
321  //sprintf(str, "%5.1lf %d %2d:%02d:%02d\n\r",Temp, CoolPw, t.ti_hour, t.ti_min, t.ti_sec);
322  //write(fc, str, strlen(str));
323 
324  }
325 
326  close(fc);
327 
328 
329 
330 
331 
332  if(!FLAG.AMS_H)
333  MAddTimeout(LOG_TASK_TIME, Task_LOG, data); // rilancia il task
334 }
gui Gui
Graphic User Interface Structure.
char odate[10]
Old Date.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
char fsmlog[_MAX_PATH]
daily LOG file for stepper motor moovements
char LOGDIR[_MAX_PATH]
Definition: bildef.h:209
omuthr OMUTHR
Definition: RTC_Time.c:36
char * MObjectGetText(MOBJECT obj, char *text)
float Temperature[16]
Temperatures.
MOBJECT Albl_CS[4]
Active Control Panel Labels for Camera Status 4.
char ndate[10]
New Date.
d_geo DGeo
struct for Station location
char ntime[10]
New Time.
bil BIL
Definition: RTC_Time.c:30
char s_name[4]
Station name.
void Task_LOG(TIMEOUT_ID id, void *data)
LOG Task. Write on the LOG file during DAS execution.
Definition: RTC_Time.c:246
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
float CCDTemp
Actual CCD Temperature.
d_fileman DFILEM
Definition: bildef.h:257
Definition: Dildef.h:240
das DAS
DAS structure.
Definition: RTC_Time.c:34
void SZA_FindMin()
computation of daily minimum SZA
Definition: DAS_Spat.c:2808
flag FLAG
flags structure
Definition: RTC_Time.c:25
int AMS_H
Home AMS.
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
controlpanel ContrPanel
Control Panel Structure.
dlog DLOG
Definition: RTC_Time.c:29
char flog[_MAX_PATH]
daily LOG file
Definition: Dildef.h:234
#define LOG_TASK_TIME
LOG files.
TIMEOUT_ID MAddTimeout(CARD32 tmout, TIMEOUT_CB cb, void *ud)
void ShutterOpening(int mod)
Definition: Procedures.c:1685
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Task_Timer()

void Task_Timer ( TIMEOUT_ID  id,
void *  data 
)

Timer Task.
Very useful procedure that:
1) Provide to refresh the clock display
2) Check if daylight saving time is in effect
3) Calculate the Solar Zenith Angle
4) Check the FLAG.sza in order to back-up the daily data via FTP and if all the condition are satisfied the back-up is performed
5) Check for reached end-run of the stepper motor for the grating
.

Definition at line 1184 of file RTC_Time.c.

References optionini::aaopmode, controlpanel::Albl_Azim, controlpanel::Albl_CS, controlpanel::Albl_Elev, controlpanel::Albl_sunr, controlpanel::Albl_suns, flag::AMS_H, gui::ContrPanel, d_fileman::DAILYDATADIRECTORY, bil::DFILEM, das::DGeo, das::DOption, das::Flag, FTP_Back_UP(), optionini::ftpbackup, flag::ftpstatus, GetDateTime(), das::Gui, d_fileman::HOMEDIRECTORY, d_geo::latitude, controlpanel::lbl_Time, d_geo::longitude, MAddTimeout(), MIGEAntiSunTrack(), MIGESunTrack(), MObjectGetText(), MObjectSetText(), optionini::resetEnabled, S_azim, d_geo::s_name, S_sunrise, S_sunset, S_zenetr, SetWindowsReset(), flag::sza, SZACalc(), SZAMax, TIMER_TASK_TIME, d_geo::timezone, flag::WindowsReboot, and WinRes().

Referenced by DB_ToolsKeyB_CB(), and LaunchBackTask().

1185 {
1186 
1187  char str[80];
1188  int er;
1189  char buff[32];
1190 // char datebuf[9];
1191 // long dp = 500;
1192  struct time RTime;
1193  struct date RDate;
1194 
1195  struct tm newtime;
1196 // long ltime;
1197  float t_acc = 0;
1198  int sunrh,sunrm,sunrs;
1199  int sunsh,sunsm,sunss;
1200  float CCD_Pwr;
1201 
1202 
1203  if (DAS.DOption.resetEnabled)
1204  {
1205  if(DAS.Flag.WindowsReboot == 0)
1206  SetWindowsReset();
1207 
1209  CCD_Pwr = (float)atof(buff);
1210 
1211  if (DAS.Flag.WindowsReboot ==1 && CCD_Pwr<=10.0)
1212  WinRes();
1213  }
1214 // _strdate(datebuf);
1215 
1216 // _strtime(timebuf);
1217 // time( &ltime );
1218 
1219 // newtime = localtime( &ltime );
1220 
1221  /**************************************************************/
1222  // Check if daylight saving time is in effect
1223  // tm_isdst > 0 if daylight saving time is in effect
1224  // tm_isdst = 0 if daylight saving time is not in effect
1225  // tm_isdst < 0 if status of daylight saving time is unknown.
1226 // if (newtime ->tm_isdst)
1227 // newtime ->tm_hour = newtime ->tm_hour - 1;
1228  //NOTE - In Daylight saving period on midnight the hours became -1 so...
1229 // if((newtime -> tm_hour) == -1)
1230 // {
1231  // Necessary for measurements performed at high latitude in summer seasons
1232 // newtime->tm_hour = 23;
1233 // newtime -> tm_yday = newtime -> tm_yday - 1;
1234 // }
1235 
1236  /**************************************************************/
1237  GetDateTime(&RDate, &RTime, &newtime);
1238 
1239  /**************************************************************/
1240  // Calc solar Zenith Angle (SZA)
1242  newtime.tm_year + 1900,
1243  newtime.tm_yday, newtime.tm_hour, newtime.tm_min, newtime.tm_sec,
1244  0, 1024, 0, 0);
1245  /**************************************************************/
1246  sprintf(str, "%.1lf", 90 - S_zenetr); //S_elevref = elevation refracted
1248 
1249  sprintf(str, "%.1lf", S_azim);
1251 
1252  // Sunrise and sunset times
1253  /*++++++++++++++++++++++++++++++++++++++*/
1254  sunrh = (int)floor(S_sunrise/60);
1255  sunrm = (int)floor( ((S_sunrise/60) - floor(S_sunrise/60))*60 );
1256  sunrs = (int)floor( ( (((S_sunrise/60) - floor(S_sunrise/60))*60) - floor((((S_sunrise/60) - floor(S_sunrise/60))*60)) )*60 );
1257 
1258  sprintf(str, "%02d:%02d:%02d", sunrh, sunrm, sunrs);
1259  //sprintf(str, "%.02lf", S_sunrise);
1261 
1262  sunsh = (int)floor(S_sunset/60);
1263  sunsm = (int)floor( ((S_sunset/60) - floor(S_sunset/60))*60 );
1264  sunss = (int)floor( ( (((S_sunset/60) - floor(S_sunset/60))*60) - floor((((S_sunset/60) - floor(S_sunset/60))*60)) )*60 );
1265 
1266  //sprintf(str, "%.02lf", S_sunset);
1267  sprintf(str, "%02d:%02d:%02d", sunsh, sunsm, sunss);
1269  /*++++++++++++++++++++++++++++++++++++++*/
1270 // S_sunrise = 720.0 - 4.0 * S_ssha - S_tstfix;
1271 // S_sunset = 720.0 + 4.0 * S_ssha - S_tstfix;
1272 
1273 
1274  /**************************************************************/
1275  // write on the STATUS label
1276  sprintf(str, "Loc.: %s, Date: %d/%02d/%02d, Local Solar Time: %02d:%02d:%02d, SZA:%.02lf",
1277  DAS.DGeo.s_name, newtime.tm_year + 1900, newtime.tm_mon + 1,newtime.tm_mday,
1278  newtime.tm_hour, newtime.tm_min, newtime.tm_sec, S_zenetr);
1279 
1281  /**************************************************************/
1282 
1283  /**************************************************************/
1284  // Set FLAG.sza
1285  // FLAG.sza = 1 --> perform measurements
1286  // FLAG.sza = 0 --> waiting mode
1287  if(S_zenetr < SZAMax)
1288  {
1289  FLAG.sza =1;
1290  FLAG.ftpstatus = 0; // back-up that will be performed when FLAG.sza = 0
1291  }
1292  else
1293  {
1294  FLAG.sza =0;
1295  if(FLAG.ftpstatus == 1) //Back-up performed
1296  FLAG.ftpstatus = 2; //Wait until the next sunset
1297 
1298  }
1299  /**************************************************************/
1300 
1301  /**************************************************************/
1302 
1303  /**************************************************************/
1304 
1305  //CHECK IF ALL THE CONDITION ARE SATISFIED
1306  //IN ORDER TO PERFORM BACKUP OF THE DATA VIA FTP
1307  /**************************************************************/
1308  if((FLAG.sza == 0) & (DAS.DOption.ftpbackup == 1) & (FLAG.ftpstatus == 0))
1310 
1311  // MIGE Sun tracker
1312  if (DAS.DOption.aaopmode == 0)
1313  MIGESunTrack();
1314 
1315  // MIGE ANTI Sun tracker
1316  if (DAS.DOption.aaopmode == 1)
1317  MIGEAntiSunTrack();
1318 
1319  /**************************************************************/
1320  if(!FLAG.AMS_H)
1321  //MRefreshTimeout(&IDS.TIMER, TIMER_TASK_TIME, Task_Timer, NULL);
1322  MAddTimeout(TIMER_TASK_TIME, Task_Timer, data); // rilancia il task
1323 
1324 
1325 }
gui Gui
Graphic User Interface Structure.
double S_zenetr
Definition: SOLPOS.C:92
optionini DOption
Options for DAS execution.
MOBJECT Albl_sunr
Active Control Panel Labels for Sunrise.
double S_azim
O: Solar azimuth angle: N=0, E=90, S=180, W=270.
Definition: SOLPOS.C:45
void Task_Timer(TIMEOUT_ID id, void *data)
Timer Task. Very useful procedure that: 1) Provide to refresh the clock display 2) Check if daylight ...
Definition: RTC_Time.c:1184
int sza
= 1 -> perform measurements; = 0 -> waiting mode
double latitude
Station latitude.
char DAILYDATADIRECTORY[_MAX_PATH]
Definition: bildef.h:203
void SetWindowsReset()
Definition: RTC_Time.c:1125
flag Flag
Structure for different flags.
char HOMEDIRECTORY[_MAX_PATH]
Definition: bildef.h:200
char * MObjectGetText(MOBJECT obj, char *text)
MOBJECT Albl_CS[4]
Active Control Panel Labels for Camera Status 4.
void MObjectSetText(MOBJECT obj, const char *text)
int SZAMax
Maximum SZA for performing measurements.
Definition: DAS_Spat.c:116
MOBJECT Albl_suns
Active Control Panel Labels for Sunset.
*double S_sunset
Definition: SOLPOS.C:82
d_geo DGeo
struct for Station location
MOBJECT Albl_Azim
Active Control Panel Labels for Sun Azimuth.
int FTP_Back_UP(char *dirhome, char *dirdata)
Definition: RTC_Time.c:336
MOBJECT lbl_Time
Control Panel Labels for Time.
bil BIL
Definition: RTC_Time.c:30
int timezone
Station timezone.
char s_name[4]
Station name.
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
d_fileman DFILEM
Definition: bildef.h:257
double S_sunrise
Definition: SOLPOS.C:80
Definition: Dildef.h:240
das DAS
DAS structure.
Definition: RTC_Time.c:34
void MIGEAntiSunTrack(void)
Definition: RTC_Time.c:206
int WindowsReboot
Flag that became 1 when Windows reboot is setted (SetWinowsReset)
flag FLAG
flags structure
Definition: RTC_Time.c:25
int ftpstatus
0 = FTP Back-UP Not executed; 1 = FTP Back-UP executed;
int AMS_H
Home AMS.
#define TIMER_TASK_TIME
timer
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
controlpanel ContrPanel
Control Panel Structure.
int ftpbackup
Flag to set back up: 0 = NO FTP Back-UP; 1 = Perform FTP Back-UP.
double longitude
Station longitude.
Definition: Dildef.h:234
int aaopmode
operation mode for the Alt Az Platform, 0 = solar Traxker; 1 = Anti-Solar Tracker; 2 = Free Positioni...
void MIGESunTrack(void)
Definition: RTC_Time.c:222
MOBJECT Albl_Elev
Active Control Panel Labels for Sun Elevation.
void WinRes(void)
Definition: RTC_Time.c:1067
int resetEnabled
DAS/Windows reset option (1 = Enabled; 0 = disabled)
TIMEOUT_ID MAddTimeout(CARD32 tmout, TIMEOUT_CB cb, void *ud)
int SZACalc(double d_lat, double d_long, double d_tzone, int d_year, int d_daynum, int d_hour, int d_minute, int d_second, float d_temp, float d_press, float d_tilt, float d_aspect)
Calc. Solar angles and radiatives quantities. .
Definition: CalcSZA.c:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ WinRes()

void WinRes ( void  )

Definition at line 1067 of file RTC_Time.c.

References DXL_par::com, D_WriteInitLog(), DB_WriteMode(), DC_Close(), paramini::EqType, das::Flag, GASCODNG1, GetDateTime(), HGFlg, HgLamp(), LookforWl_X(), MGUITerm(), das::Nova, NOVA_Out(), das::Paramini, QJFlg, QjLamp(), SD_Grating(), ShutterOpening(), SioDone(), nova::type, WDT_func(), and flag::WindowsReboot.

Referenced by InitTempAD(), and Task_Timer().

1068 {
1069 
1070  int PosRefWl, er;
1071  struct time RTime;
1072  struct date RDate;
1073  struct tm today;
1074  char buff[10];
1075  char str[10];
1076  char buf[256];
1077 
1078 
1079 
1080 
1081  PosRefWl = LookforWl_X(4358);
1082 
1083  SD_Grating(PosRefWl); //Positioning at 4358 A
1084 
1085 
1086 
1087  GetDateTime(&RDate, &RTime, &today);
1088  strftime( buff, 7,"%y%m%d", &today );
1089  strftime( str, 9,"%H:%M:%S", &today );
1090  sprintf(buf, "*++++++++++++++++++++++++++++++++++++++++++++*");
1091  D_WriteInitLog(buf);
1092  sprintf(buf, "Windows reboot on %s at %s", buff, str );
1093  D_WriteInitLog(buf);
1094  sprintf(buf, "**********************************************");
1095  D_WriteInitLog(buf);
1096 
1097 
1098 
1099  DB_WriteMode(1);
1100  ShutterOpening(1);
1101  DC_Close(0); //DA RIMETTERE!!!!!!!!!!!!!!!!!1
1102  if (HGFlg)
1103  HgLamp(0);//HG Off
1104  if (QJFlg)
1105  QjLamp(0);//QJ Off
1106  //Switch off 12 V, Hires, 24V
1107  if(DAS.Paramini.EqType == GASCODNG1)
1108  er = NOVA_Out(DAS.Nova.type, 15); //1111 bin
1109 
1110 
1111  WDT_func(0); //Stop WDT
1112  SioDone(DXL.com);//Close Com connection
1113  DAS.Flag.WindowsReboot = 2;
1114 
1115 
1116  MGUITerm();
1117  //restart the instrument
1118  system("shutdown -r -t 10 -f");
1119 
1120 
1121 
1122 }
int SD_Grating(int ang)
Positioning Grating. The Grating move to the position specified by ang (Wavelength) ...
Definition: Spat_Device.c:2108
void HgLamp(int mod)
HG Lamp ON/OFF .
Definition: Spat_Device.c:2673
int QJFlg
Definition: DAS_Spatram.h:2969
flag Flag
Structure for different flags.
void WDT_func(int mod)
Definition: DAS_Spat.c:1572
NoMangle int DLL_IMPORT_EXPORT SioDone(int)
void QjLamp(int mod)
QJ Lamp ON/OFF .
Definition: Spat_Device.c:2724
CTYPE void DLL DC_Close(int Camera)
Shuts down the control operations of the camera. Procedure that shuts down the control operations of ...
void MGUITerm(void)
DXL_par DXL
Definition: RTC_Time.c:24
int NOVA_Out(int novatype, unsigned int out)
Write the NOVA Output port.
Definition: DAS_Spat.c:1375
Definition: Dildef.h:240
das DAS
DAS structure.
Definition: RTC_Time.c:34
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
int WindowsReboot
Flag that became 1 when Windows reboot is setted (SetWinowsReset)
nova Nova
NOVA structure.
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
int D_WriteInitLog(char *str)
writes devices errors(AMS, CCD...) on the Devices.log file.
Definition: Save.c:144
Definition: Dildef.h:234
void DB_WriteMode(int mod)
Definition: CreateForms.c:6722
int EqType
Spectrometer Type.
int HGFlg
Definition: DAS_Spatram.h:2968
int com
Comunication port.
Definition: DXL.H:17
int type
type of NOVA monoboard used (7892 or 945GSE)
void ShutterOpening(int mod)
Definition: Procedures.c:1685
int LookforWl_X(int x)
Definition: Procedures.c:2295
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ WriteInit()

void WriteInit ( const char *  sname,
char *  dateffn,
char *  timebuff 
)

Init the daily LOG file
.

Parameters
*sname= Name of the station (3 char)
*dateffn= date
*timebuff= time

Definition at line 158 of file RTC_Time.c.

References bil::DFILEM, dlog::flog, dlog::fsmlog, and d_fileman::LOGDIR.

Referenced by MGUIMain().

159 {
160  int fc, er;
161  char tit1[256], datebuff[9];
162 
163 
164  //for stepper motors log
165  sprintf(DLOG.fsmlog,"%s\\SM_%s.log", BIL.DFILEM.LOGDIR, dateffn);
166 
167 
168 
169  sprintf(DLOG.flog,"%s\\%s%s.log",BIL.DFILEM.LOGDIR, sname, dateffn);
170 
171  fc = _open(DLOG.flog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
172  //test for errno
173  //fc = _open(DLOG.flog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT| O_EXCL, S_IWRITE);
174 
175 
176  if(fc < 0)
177  {
178  er = errno;
179  }return;
180 
181  sprintf(datebuff,"%c%c/%c%c/%c%c", dateffn[0],dateffn[1],dateffn[2],dateffn[3],dateffn[4],dateffn[5]);
182  sprintf(tit1,"DAS Started on: %s, at: %s\n",datebuff,timebuff);
183  write(fc, &tit1, strlen(tit1));
184  // Write title for monitored values
185  sprintf(tit1,"Time TCCD PwCCD PwPlt T.Optic T.IntSX T.OutSX T.IntDX T.OutDX T.Grat SPARE T.Elec SPARE SPARE SPARE SPARE SPARE SPARE SPARE SPARE \n");
186  write(fc, &tit1, strlen(tit1));
187 
188  close(fc);
189 }
char fsmlog[_MAX_PATH]
daily LOG file for stepper motor moovements
char LOGDIR[_MAX_PATH]
Definition: bildef.h:209
bil BIL
Definition: RTC_Time.c:30
d_fileman DFILEM
Definition: bildef.h:257
dlog DLOG
Definition: RTC_Time.c:29
char flog[_MAX_PATH]
daily LOG file
+ Here is the caller graph for this function:

§ WriteStatusD()

void WriteStatusD ( int  w)

NOT Used
.

Definition at line 1331 of file RTC_Time.c.

1332 {
1333 /*
1334  int fc;
1335  char tit1[80];
1336 
1337  fc = open(flog, O_WRONLY | O_APPEND | O_TEXT, S_IWRITE);
1338  if(fc < 0) return;
1339 
1340  sprintf(tit1, CCD_Err[--w], w);
1341  write(fc, &tit1, strlen(tit1));
1342  close(fc);
1343 */
1344 }

§ WriteTitolo()

void WriteTitolo ( void  )

Definition at line 191 of file RTC_Time.c.

References dlog::flog.

192 {
193  int fc;
194  char tit1[90];
195 
196 
197 
198  fc = open(DLOG.flog, O_WRONLY | O_APPEND | O_TEXT | O_CREAT, S_IWRITE);
199  if(fc < 0) return;
200  sprintf(tit1,"Time TCCD PwCCD PwPlt T.Optic T.IntSX T.OutSX T.IntDX T.OutDX T.Grat SPARE T.Elec SPARE SPARE SPARE SPARE SPARE SPARE SPARE SPARE \n");
201  write(fc, &tit1, strlen(tit1));
202  close(fc);
203 }
dlog DLOG
Definition: RTC_Time.c:29
char flog[_MAX_PATH]
daily LOG file

Variable Documentation

§ BIL

bil BIL

Definition at line 30 of file RTC_Time.c.

§ DAS

das DAS

DAS structure.

Definition at line 34 of file RTC_Time.c.

§ ddmmyy

char ddmmyy[8]

Definition at line 38 of file RTC_Time.c.

Referenced by FormatData().

§ ddmmyyf

char ddmmyyf[6]

Definition at line 39 of file RTC_Time.c.

Referenced by FormatDataFile().

§ DFTP

dftp DFTP

Definition at line 31 of file RTC_Time.c.

§ DLOG

dlog DLOG

Definition at line 29 of file RTC_Time.c.

§ DXL

DXL_par DXL

Definition at line 24 of file RTC_Time.c.

§ ExeREM

int ExeREM

Definition at line 143 of file DAS_Spat.c.

Referenced by FTP_Back_UP().

§ FLAG

flag FLAG

flags structure

Definition at line 25 of file RTC_Time.c.

§ Incr_Read_Temp

int Incr_Read_Temp

Definition at line 101 of file DAS_Spat.c.

Referenced by D_readtemp(), and Task_LIS_Temp().

§ OMUTHR

omuthr OMUTHR

Definition at line 36 of file RTC_Time.c.

§ STEPM

stepm STEPM

Stepper Motors.

Definition at line 28 of file RTC_Time.c.

§ SZADelta

dsza SZADelta

Definition at line 32 of file RTC_Time.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:43 for DAS - Rel. 3.1.6 - 18/09/2017.