Commit d1b11418 authored by Andrea Orlati's avatar Andrea Orlati Committed by Francesco Cepparo
Browse files

Initial commit, version 1.0.0

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+7 −0
Original line number Diff line number Diff line
.branchenv
introot*
bin/
lib/
object/
*~
*.swp

CHANGELOG.md

0 → 100644
+19 −0
Original line number Diff line number Diff line
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/

## [Unreleased]
### Added

### Changed

### Fixed 

- InjectCommand blocks if the system is down @aorlati


## 

CONTRIBUTING.md

0 → 100644
+83 −0
Original line number Diff line number Diff line
# How to Contribute

We'd love to accept any contribution from anybody. If you like to contribute, please take time to read this page.

## Contributor License Agreement

Contributions to this project implicitly adhere to this [agreement](https://discos.readthedocs.io/en/latest/license.html).

## Code reviews

All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult our [How-to](https://discos.readthedocs.io/en/latest/developer/howto/github/branch_and_merge.html#generating-a-pull-request) for more information on using pull requests.

## How to file a bug report

All issues are to be submitted through the GitHub tracking system.

When filing an issue, make sure to answer the following questions:

> 1. What version of DISCOS are you referring? Which telescope are you at?
> 2. What did you do?
> 3. What did you expect to see?
> 4. What did you see instead?

## How to suggest a feature or enhancement

If you find yourself wishing for a feature that doesn't exist, you are probably not alone. Open an issue on our issues list on GitHub which describes the feature you would like to see, why you need it, and how it should work.

## Our workflow with GitHub

Our GitHub-based [workflow](https://discos.readthedocs.io/en/latest/developer/howto/github/index.html)  is very simple. The master branch is dedicated to implement new features and capabilities. The stable branch will be used for software releases according to our [policy](https://discos.readthedocs.io/en/latest/developer/releasing.html).

### Hot-Fixes workflow

- Check out into master branch
`git checkout master`
- Update local master branch with remote copy
`git pull origin master`
- Check out into stable branch
`git checkout stable`
- Update local stable branch with remote copy
`git pull origin stable`
- Create a hotfix branch related to the issue xxx
`git checkout -b fix-issue-xxx`
- Do some fixes and commit to them
- Push the hotfix branch to remote repository
`git push origin fix-issue-xxx`
- Open a "Pull request" in GitHub, in order to merge the hotfix branch onto the stable branch, and reqeust a review from the team
- Once the team approves the pull request, the branch can be merged using the "Squash and merge" strategy. Be sure to delete the hotfix branch after it gets merged
- Open a second "Pull request" in GitHub, in order to merge the stable branch with the new hotfix onto the master branch
- Once again, as soon as the team approves the pull request, the branch can be merged, but now you have to select the "Create a merge commit" strategy. You have to insert the following commit message: "Merging latest bugfix onto master."
- If some conflict between the master and the stable branch arises, don't worry, they can be fixed right away when merging online. Resolve the conflict by porting the new lines from the stable branch into the master branch version of the file.
- You can now delete the hotfix branch from the local repository
`git branch -D fix-issue-xxx`
- Check out once again into master branch
`git checkout master`
- Update local master branch with remote copy
`git pull origin master`
- Check out once again into stable branch
`git checkout stable`
- Update local stable branch with remote copy
`git pull origin stable`
- Now that the hotfix is on the online repository, a new tag can be created onto the stable branch. In order to do this, go to the releases page of the repository, and select "Draft a new release". Fill the "Tag version" and "Release title" fields according to the previous releases. Also, be sure to select the stable branch as target and to check "This is a pre-release" if you are not sure if your release is ready to be deployed on production line.

### Feature implementation workflow

- Check out into master branch
`git checkout master`
- Update local master branch with remote copy
`git pull origin master`
- Create a branch related to the issue xxx
`git checkout -b fix-issue-xxx`
- Do some coding and commit to it
`git commit -m "Fix #xxx:…"`
- Push feature branch to remote repository
`git push origin fix-issue-xxx`
- Open a "Pull request" in GitHub for team to verify the feature
- Once the team approves the pull request, the branch can be merged using the "Squash and merge" strategy, and it can be deleted from the online repository
- You can now delete the feature branch from the local repository
`git branch -D fix-issue-xxx`
- Check out once again into master branch
`git checkout master`
- Update local master branch with remote copy
`git pull origin master`
+110 −0
Original line number Diff line number Diff line
#ifndef COMPONENTTEXTCLIENTTEMPLATE_H
#define COMPONENTTEXTCLIENTTEMPLATE_H

/* **************************************************************************************************** */
/* IRA Istituto di Radioastronomia                                                                      */
/*                                                                                                      */
/* This code is under GNU General Public Licence (GPL).                                                 */
/*                                                                                                      */
/* Who                                                    when             What                                              */
/* Andrea Orlati(aorlati@ira.inaf.it)         07/02/2008      Creation                                                  */
/* Andrea Orlati(aorlati@ira.inaf.it)         01/04/2010      Modified according the new AntennaBoss interface          */
/* Andrea Orlati(aorlati@ira.inaf.it)         09/04/2010      added the calls for the new wrappers methods of the boss    */
/* Andrea Orlati(aorlati@ira.inaf.it)         26/05/2011      review the code that displays the generators output    */
/* Andrea Orlati(aorlati@ira.inaf.it)         08/04/2013      changed the color of the led when correction are disabled from red to yellow  */
/* Andrea Orlati(aorlati@ira.inaf.it)         12/06/2014      displayed the reference and definition of radila velocity */


/* Add the component skeleton header file */
/* ************************************* */
#include <AntennaBossC.h>
/* ************************************* */

/* Add the component errors header file */
/* ************************************* */
#include <ComponentErrors.h>
#include <AntennaErrors.h>
/* ************************************* */

/* Add the client specific errors header file */
/* ************************************* */
#include <ClientErrors.h>
/* ************************************* */


#include <maciSimpleClient.h>
#include <baciThread.h>
#include <ClientErrors.h>
#include <baci.h>
#include <IRA>
#include <TW_Tools.h>
#include <TW_Frame.h>
#include <TW_PropertyText.h>
#include <TW_PropertyStatusBox.h> 
#include <TW_PropertyLedDisplay.h>
#include <TW_Label.h>
#include <TW_LedDisplay.h>
#include <TW_InputCommand.h>

#define GRAY_COLOR 0
#define BLUE_GRAY 0
#define GRAY_BLUE 1
#define BLACK_RED 2
#define BLACK_GREEN 3
#define BLACK_YELLOW 4
#define BLACK_BLUE 5
#define BLACK_MAGENTA 6
#define BLACK_WHITE 7

/* define the max number of arguments that can be passed to component methods */
/* ************************************************************************** */
#define MAXFIELDNUMBER 12
/* ************************************************************************** */

/* define the main frame dimension */
/* ******************************* */
#define WINDOW_WIDTH 82      /*columns */
#define WINDOW_HEIGHT 32     /* rows */
/* ******************************* */

/* define the routine name here, to be used for logging */
/* **************************************************** */
#define MODULE_NAME "antennaBossTui"   /* the name of this module (filename without .cpp) */
/* **************************************************** */

/* define the application title and style */
/* ************************************* */
#define APPLICATION_TITLE "Antenna Boss"        /* the title of the main frame */
#define TITLE_COLOR_PAIR CColorPair::RED_BLACK /* the title color and background */
#define TITLE_STYLE CStyle::BOLD|CStyle::UNDERLINE /* the title style */
/* ************************************* */

/* define name and component interface */
/* ********************************** */
//#define COMPONENT_NAME "ANTENNA/Boss"              /* the name of the istantiation of the component */
#define COMPONENT_INTERFACE_TPYE "IDL:alma/Antenna/AntennaBoss:1.0"  /* the type of the interface */
#define COMPONENT_IDL_MODULE Antenna	/* the IDL module that contains the component interface */
#define COMPONENT_IDL_INTERFACE AntennaBoss  /* the IDL interface of the component */
#define COMPONENT_SMARTPOINTER AntennaBoss_var /* the component type */
/* ********************************** */

/* define user input command style */
/* ******************************* */
#define USER_INPUT_COLOR_PAIR BLUE_GRAY    /* user input color and background */
#define USER_INPUT_STYLE CStyle::NORMAL    /* user input style */
/* ******************************* */

/* define output field look and feel */
/* ********************************* */
#define USE_OUTPUT_FIELD 1	/* 0 disable the output field */
#define OUTPUT_FIELD_COLOR_PAIR GRAY_BLUE  /* output field color and background */
#define OUTPUT_FIELD_STYLE CStyle::NORMAL  /* output field style */
#define OUTPUT_FIELD_HEIGHT 4				  /* output field height (number of rows) */
/* ********************************* */

/* define this value (milliseconds) to set the log guard interval */
#define GUARDINTERVAL 1000
/* to send the client to sleep for a certain ammount of time, setup this value (milliseconds) */
#define MAINTHREADSLEEPTIME 250

#endif
+254 −0
Original line number Diff line number Diff line
#ifndef _UPDATEGENERATOR_I_
#define _UPDATEGENERATOR_I_

// $Id: UpdateGenerator.i,v 1.9 2011-05-26 14:18:34 a.orlati Exp $

void updateGenerator(maci::SimpleClient& client,Antenna::TGeneratorType& lastGeneratorType,Antenna::EphemGenerator_var& lastGenerator) {
	//Antenna::EphemGenerator_var gen;
	char *gen;
	IRA::CString generatorName;
	Antenna::TGeneratorType type;
	IRA::CString outString,tmpString;
	baci::BACIValue bValue;
	try {
		gen=component->getGeneratorCURL(type);
		generatorName=IRA::CString(gen);
		CORBA::string_free(gen);
	}
	catch (CORBA::SystemException& ex) {
		_EXCPT(ClientErrors::CORBAProblemExImpl,impl,"::Main()"); 
		impl.setName(ex._name());
		impl.setMinor(ex.minor());
		_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
		return;
	}
	catch (...) {
		_EXCPT(ClientErrors::UnknownExImpl,impl,"::Main()");
		_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
		return;
	}
	if ((type==Antenna::ANT_NONE) || (type!=lastGeneratorType)) { // the current generator should be released
		if (!CORBA::is_nil(lastGenerator)) {
			try {
				client.releaseComponent(lastGenerator->name());
			}
			catch (maciErrType::CannotReleaseComponentExImpl& E) {
				_IRA_LOGGUARD_LOG_EXCEPTION(guard,E,LM_ERROR);
			}
			catch (...) {
			}
			lastGenerator=Antenna::EphemGenerator::_nil();
			lastGeneratorType=Antenna::ANT_NONE;
		}
	}
	//if (!CORBA::is_nil(gen)) {
	if (type!=lastGeneratorType) {
		try {
			lastGenerator=client.getComponent<Antenna::EphemGenerator>(generatorName,0,true);
		}
		catch (maciErrType::CannotGetComponentExImpl& E) {
			_ADD_BACKTRACE(ClientErrors::CouldntAccessComponentExImpl,impl,E,MODULE_NAME"::Main()");
			impl.setComponentName((const char *)generatorName);
			_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
			return;
		}	
		catch (CORBA::SystemException& ex) {
			_EXCPT(ClientErrors::CORBAProblemExImpl,impl,"::Main()"); 
			impl.setName(ex._name());
			impl.setMinor(ex.minor());
			_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
			return;
		}
		catch (...) {
			_EXCPT(ClientErrors::UnknownExImpl,impl,"::Main()");
			_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
			return;
		}
		lastGeneratorType=type;
	}
	if (!CORBA::is_nil(lastGenerator)) {
		switch (type) {
			case Antenna::ANT_SIDEREAL : {
				IRA::CString str1,str2;
				Antenna::SkySourceAttributes_var att;
				Antenna::SkySource_var sidereal;
				try {
					sidereal=Antenna::SkySource::_narrow(lastGenerator);
					//sidereal=Antenna::SkySource::_narrow(gen);
					if (!CORBA::is_nil(sidereal)) {
						sidereal->getAttributes(att);
					}
				}
				catch (...) {
					_EXCPT(ClientErrors::UnknownExImpl,impl,"::Main()");
					_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
					return;
				}
				tmpString=(const char*)att->sourceID;
				outString="Source name    : "+tmpString;
				extraLabel1->setValue(outString);
				extraLabel1->Refresh();	
				IRA::CIRATools::radToHourAngle(att->inputRightAscension,str1);
				IRA::CIRATools::radToSexagesimalAngle(att->inputDeclination,str2);
				outString="Catalog Eq.    : "+str1+"/"+str2+"/";
				tmpString.Format("%.1lf %.2lf %.2lf %.2lf %.2lf",att->inputJEpoch,att->inputRaProperMotion,att->inputDecProperMotion,
						att->inputParallax,att->inputRadialVelocity);
				outString+=tmpString;
				extraLabel2-> setValue(outString);
				extraLabel2->Refresh();
				IRA::CIRATools::radToAngle(att->inputGalacticLongitude,str1);
				IRA::CIRATools::radToAngle(att->inputGalacticLatitude,str2);
				outString="Catalog Gal.   : "+str1+"/"+str2;
				extraLabel3->setValue(outString);
				extraLabel3->Refresh();
				IRA::CIRATools::radToHourAngle(att->rightAscension,str1);
				IRA::CIRATools::radToSexagesimalAngle(att->declination,str2);
				outString="Apparent Eq.   : "+str1+"/"+str2+"/";
				str1.Format("%.5lf",att->julianEpoch);
				outString+=str1;
				extraLabel4->setValue(outString);
				extraLabel4->Refresh();
				IRA::CIRATools::radToAngle(att->gLongitude,str1);
				IRA::CIRATools::radToAngle(att->gLatitude,str2);
				outString="Galactic       : "+str1+"/"+str2;
				extraLabel5->setValue(outString);
				extraLabel5->Refresh();
				IRA::CIRATools::radToAngle(att->azimuth,str1);
				IRA::CIRATools::radToAngle(att->elevation,str2);
				outString="Horizontal     : "+str1+"/"+str2;
				extraLabel6->setValue(outString);
				extraLabel6->Refresh();				
				break;
			}
			case Antenna::ANT_MOON : {
				IRA::CString str1,str2;
				Antenna::MoonAttributes_var att;
				Antenna::Moon_var moon;
				try {
					moon=Antenna::Moon::_narrow(lastGenerator);
					if (!CORBA::is_nil(moon)) {
						moon->getAttributes(att);
					}
				}
				catch (...) {
					_EXCPT(ClientErrors::UnknownExImpl,impl,"::Main()");
					_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
					return;
				}			
				tmpString=(const char*)att->sourceID;
				outString="Source name    : "+tmpString;
				extraLabel1->setValue(outString);
				extraLabel1->Refresh();
				IRA::CIRATools::radToHourAngle(att->rightAscension,str1);
				IRA::CIRATools::radToSexagesimalAngle(att->declination,str2);
				outString="Apparent Eq.   : "+str1+"/"+str2+"/";
				str1.Format("%.5lf",att->julianEpoch);
				outString+=str1;
				extraLabel2->setValue(outString);
				extraLabel2->Refresh();
				IRA::CIRATools::radToAngle(att->gLongitude,str1);
				IRA::CIRATools::radToAngle(att->gLatitude,str2);
				outString="Galactic       : "+str1+"/"+str2;
				extraLabel3->setValue(outString);
				extraLabel4->Refresh();
				IRA::CIRATools::radToAngle(att->azimuth,str1);
				IRA::CIRATools::radToAngle(att->elevation,str2);
				outString="Horizontal     : "+str1+"/"+str2;
				extraLabel4->setValue(outString);
				extraLabel4->Refresh();								
				extraLabel5->setValue("");
				extraLabel5->Refresh();			
				extraLabel6->setValue("");
				extraLabel6->Refresh();	
				break;
			}
			case Antenna::ANT_OTF: {
				Antenna::OTFAttributes_var att;
				Antenna::OTF_var otf;
				IRA::CString str1,str2;
				try {
					otf=Antenna::OTF::_narrow(lastGenerator);
					if (!CORBA::is_nil(otf)) {
						otf->getAttributes(att);
					}
				}
				catch (...) {
					_EXCPT(ClientErrors::UnknownExImpl,impl,"::Main()");
					_IRA_LOGGUARD_LOG_EXCEPTION(guard,impl,LM_ERROR);
					return;
				}				
				IRA::CIRATools::radToAngle(att->startLon,str1);
				IRA::CIRATools::radToAngle(att->startLat,str2);
				outString="Start-Center-Stop: "+str1+"/"+str2+" - ";
				IRA::CIRATools::radToAngle(att->centerLon,str1);
				IRA::CIRATools::radToAngle(att->centerLat,str2);
				outString+=str1+"/"+str2+" - ";
				IRA::CIRATools::radToAngle(att->stopLon,str1);
				IRA::CIRATools::radToAngle(att->stopLat,str2);
				outString+=str1+"/"+str2;
				extraLabel1->setValue(outString);
				extraLabel1->Refresh();			
				IRA::CIRATools::timeToStr(att->startUT,str1);
				IRA::CIRATools::intervalToStr(att->subScanDuration,str2);
				outString="StartTime-Dur.   : "+str1+" - "+str2;
				extraLabel2->setValue(outString);
				extraLabel2->Refresh();			
				IRA::CIRATools::radToHourAngle(att->J2000RightAscension,str1);
				IRA::CIRATools::radToSexagesimalAngle(att->J2000Declination,str2);
				outString="J2000-Apparent eq: "+str1+"/"+str2+" - ";
				IRA::CIRATools::radToHourAngle(att->rightAscension,str1);
				IRA::CIRATools::radToSexagesimalAngle(att->declination,str2);
				outString+=str1+"/"+str2;
				extraLabel3->setValue(outString);
				extraLabel3->Refresh();
				IRA::CIRATools::radToAngle(att->azimuth,str1);
				IRA::CIRATools::radToAngle(att->elevation,str2);
				outString="Horizontal       : "+str1+"/"+str2;
				extraLabel4->setValue(outString);
				extraLabel4->Refresh();
				IRA::CIRATools::radToAngle(att->gLongitude,str1);
				IRA::CIRATools::radToAngle(att->gLatitude,str2);
				outString="Galactic         : "+str1+"/"+str2;
				extraLabel5->setValue(outString);
				extraLabel5->Refresh();
				str1.Format("%.4lf",att->skyRate*DR2D);
				str2.Format("%.4lf",att->phiRate*DR2D);
				outString="Sky/Phi rates    : "+str1+"/"+str1;
				extraLabel6->setValue(outString);
				extraLabel6->Refresh();
				break;
			}
			default : { //ANT_NONE
				extraLabel1-> setValue("");
				extraLabel1->Refresh();
				extraLabel2-> setValue("");
				extraLabel2->Refresh();
				extraLabel3-> setValue("");
				extraLabel3->Refresh();
				extraLabel4-> setValue("");
				extraLabel4->Refresh();		
				extraLabel5-> setValue("");
				extraLabel5->Refresh();		
				extraLabel6-> setValue("");
				extraLabel6->Refresh();	
			}
		}
	}
	else {
		extraLabel1-> setValue("");
		extraLabel1->Refresh();
		extraLabel2-> setValue("");
		extraLabel2->Refresh();
		extraLabel3-> setValue("");
		extraLabel3->Refresh();
		extraLabel4-> setValue("");
		extraLabel4->Refresh();		
		extraLabel5-> setValue("");
		extraLabel5->Refresh();		
		extraLabel6-> setValue("");
		extraLabel6->Refresh();	
	}
}


#endif /*UPDATEGENERATOR_I_*/