Git Product home page Git Product logo

Comments (10)

AstroAir avatar AstroAir commented on September 1, 2024

@agalasso
Today,I tried "php socket"and "php curl",but they didn't work at all.Then I changed the way to connect PHD2.I use telnet and it works very good.There is also a question,Can I communicate with PHD2 by c++?This API (https://github.com/agalasso/phd2client/) could not get useful informations about drawing guding lines on website.I think we can add some outputs to solve this problem.
PS:How can I put data in JSON format to the TCP socket?
This is telnet's log:
log.txt

from phd2client.

agalasso avatar agalasso commented on September 1, 2024

@AstroAir

Can I communicate with PHD2 by c++?This API (https://github.com/agalasso/phd2client/) could not get useful informations about drawing guding lines on website.

This github issue (#3) was created to track the feature request. When the feature is implemented, the API will include a way for clients to receive event notifications including GuideStep events. At that point you can use the new API plot the data. Until then you'll need to use a direct socket connection to PHD2 to receive the event notification messages.

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

No problem.I can use telnet to connect PHD2,and only need to read the log.But I think it is not easy to do .So I hope the new API will come soon.I think maybe I can take a part in developing this API,I kown a little about C++ and C.

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

Hi.I want to ask a question what is the relation between "RADistanceRaw" and "RADistanceGuide" ?

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

This is my php demo.

`<?php
/*
* This a part of AstroAir Web Tools.
* This is used to draw guiding line on website
* Write on Aug,4,2020
*/

//----------Read the log file-----------

$file = 'log.txt';	//open log file
$fp = fopen($file, 'r');
fseek($fp,-1,SEEK_END);		//read last line's informations
$log = '';
while(($c = fgetc($fp)) !== falloge)
{
	if($c == "\n" && $log)
		break;
	$log = $c . $log;
	fseek($fp, -2, SEEK_CUR);	//read next-to-last line's informations
}
fclose($fp);	//close log file

//--------Choose useful informations---------

$log=trim($log);						//delete " "
$log=preg_replace("/\s/","",$log);		//delete "\s"
$log=preg_replace('/"/',"",$log);		//delete ":"
$log=preg_replace("/{/","",$log);		//delete "{"
$log=preg_replace("/}/","",$log);		//delete "}"

//--------get the guide stats----------

$stats=explode(",",$log);
$stats=explode(":",$stats[0]);

//--------judge the guide stats----------

if($stats[1] == "GuideStep")		//Guiding
{
	$dir=explode(",",$log);
	$dir=explode(":",$dir[14]);
	$dir1=explode(",",$log);
	$dir1=explode(":",$dir1[16]);
	if($dir[0] == "StarMass")		//moving direction did not change
	{
		$file=fopen("guiding_ra.txt.txt","r");		//get ra moving direction from data
		$RAdir=trim(fgets($file));
		fclose($file);
		
		$file=fopen("guiding_dec.txt.txt","r");		//get dec moving direction from data
		$DECdir=trim(fgets($file));
		fclose($file);
	}
	else
	{
		if($dir[0] == "RADirection" && $dir1[0] == "DECDirection")		//both RA and DEC moving directions have changed
		{
			if($dir[1] == "East")		//judge RA moving direction
				$RAdir=1;				//RA direction is east
			else
				$RAdir=0;				//RA direction is west
				
			//Write RA moving direction into data 
			$file = fopen("guiding_ra.txt", "w") or die("Unable to open file!");            
			fwrite($file, $RAdir);
			fclose($file);
			
			if($dir1[1] == "North")		//judge DEC moving direction
				$DECdir=1;				//DEC direction is north
			else
				$DECdir=0;				//DEC direction is south
				
			//Write DEC moving direction into data
			$file = fopen("guiding_dec.txt", "w") or die("Unable to open file!");            
			fwrite($file, $DECdir);
			fclose($file);
		}
		else
		{
			if($dir[0] == "RADirection")		//RA moving direction has changed
			{
				if($dir[1] == "East")		//judge RA moving direction
					$RAdir=1;				//RA direction is east
				else
					$RAdir=0;				//RA direction is west
					
				$file = fopen("guiding_ra.txt", "w") or die("Unable to open file!");            
				fwrite($file,$RAdir);
				fclose($file);
				
				$file=fopen("guiding_dec.txt","r");		//get dec moving direction from data
				$DECdir=trim(fgets($file));
				fclose($file);
			}
			else	//DEC moving direction has changed
			{
				if($dir[1] == "North")		//judge DEC moving direction
					$DECdir=1;				//DEC direction is north
				else
					$DECdir=0;				//DEC direction is south
					
				$file = fopen("guiding_dec.txt", "w") or die("Unable to open file!");            
				fwrite($file, $DECdir);
				fclose($file);
				
				$file=fopen("guiding_ra.txt","r");		//get ra moving direction from data
				$RAdir=trim(fgets($file));
				fclose($file);
			}
		}
	}
	
	//calculate RA moving distance
	
	$radis=explode(",",$log);		//get RA distance
	$radis=explode(":",$radis[9]);
	if($RAdir == 0)		//RA moving direction is west
		$radis[1]=0-$radis[1];
		
	//calculate DEC moving distance
	
	$decdis=explode(",",$log);		//get dec distance
	$decdis=explode(":",$decdis[10]);
	if($decdir == 0)		//DEC moving direction is south
		$decdis[1]=0-$decdis[1];
	echo "    DRIFT_DATA:$radis[1] $decdis[1]\n";
	
}
if($stats[1] == "Alert")		//Alert
{
	$alert=explode(",",$log);
	$alert=explode(":",$alert[4]);
	$file = fopen("guiding_alert.txt", "a") or die("Unable to open file!");            
	fwrite($file,$alert[1]);
	fclose($file);
	passthru("php notify_guiding.php");
	echo "AAAAA";
}
if($stats[1] == "GuidingStopped" || $stats[1] == "LoopingExposuresStopped")		//Stopped
{
	$file = fopen("guiding.txt", "a") or die("Unable to open file!");            
	fwrite($file,"Stopped.");
	fclose($file);
	echo "GGGGG";
}
if($stats[0] == "jsonrpc")		//PHD2 Error
{
	$error=explode(",",$log);
	$error = strstr($error[2],"message");
	$file = fopen("guiding_error.txt", "a") or die("Unable to open file!");            
	fwrite($file,"$error\n");
	fclose($file);
	echo "PHD2 Error";
}

?>`

from phd2client.

agalasso avatar agalasso commented on September 1, 2024

what is the relation between "RADistanceRaw" and "RADistanceGuide"

RADistanceRaw is RA offset of the guide star centroid relative to the lock position
RADistanceGuide is the size of the offset that PHD2's selected RA guide algorithm will attempt to correct. In other words, the output of the guide algorithm's calculation.

For plotting purposes, you almost certainly would be more interested in RADistanceRaw

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

You are right.I am insterested in RADistanceRaw and DECDistanceRaw.But I am not sure that should I consider adding RADistanceGuide and DECDistanceGuide when plotting.How PHD2 plots its graph and need which informations?

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

And I also have a question do RADirection and DECDirection affect the size of the data drawn?

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

I found a question that The DEC curve I drew on the web page is the opposite of that in PHD2.Maybe I should check out my code to find the problem.Can you help todo this ?

from phd2client.

AstroAir avatar AstroAir commented on September 1, 2024

I tried to modify the source code of PHD2 and found that guidelog.cpp There is a code to output the data of the guide line, so we add our own code. Is this feasible?

from phd2client.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.