public bool FindStarByName(string Name) { try { SocketCommandSender fss = new SocketCommandSender(); CommandMessage message = CommandMessage.FindStarByName; logger.Debug("Send Command. Msg:" + message.ToString()); string star = int.Parse(Name).ToString("00"); fss.Send(message, new string[] { star }); return true; } catch (Exception ex) { logger.Error("Send command failed. Msg:" + CommandMessage.FindStarByName.ToString(), ex); return false; } }
public bool FindStarByPosition(string RaH,string RaM,string RaS,string DecFlag,string DecD,string DecM,string DecS) { try { int Ra = (int.Parse(RaH) * 3600 + int.Parse(RaM) * 60 + int.Parse(RaS)) * 15; int Dec = int.Parse(DecD) * 3600 + int.Parse(DecM) * 60 + int.Parse(DecS); if (DecFlag == "-") Dec = -Dec; SocketCommandSender fss = new SocketCommandSender(); CommandMessage message = CommandMessage.FindStarByPosition; logger.Debug("Send Command. Msg:" + message.ToString()); logger.Debug(string.Format("Ra:{0},Dec:{1}.", Ra.ToString("0000000"), DecFlag + Dec.ToString("000000"))); fss.Send(message, new string[] { Ra.ToString("0000000"), DecFlag + Dec.ToString("000000") }); return true; } catch (Exception ex) { logger.Error("Send command failed. Msg:" + CommandMessage.FindStarByPosition.ToString(), ex); return false; } }
public bool FindStarByPosition(string position) { try { string[] array = position.Split(";".ToCharArray()); if (array.Length == 2) { SocketCommandSender fss = new SocketCommandSender(); float ra, dec; if (float.TryParse(array[0], out ra) && float.TryParse(array[1], out dec)) { if (ra < 0 || ra > 24 || dec < -90 || dec > 90) return false; int Ra = (int)ra * 3600 * 15; int Dec = (int)dec * 3600; string DecFlag = "+"; if (Dec < 0) DecFlag = "-"; CommandMessage message = CommandMessage.FindStarByPosition; logger.Debug("Send Command. Msg:" + message.ToString()); logger.Debug(string.Format("Ra:{0},Dec:{1}.", Ra.ToString("0000000"), DecFlag + Dec.ToString("000000"))); fss.Send(message, new string[] { Ra.ToString("0000000"), DecFlag + Dec.ToString("000000") }); return true; } } return false; } catch (Exception ex) { logger.Error("Send command failed. Msg:" + CommandMessage.FindStarByName.ToString(), ex); return false; } }
public bool StopFindStar() { try { SocketCommandSender fss = new SocketCommandSender(); CommandMessage message = CommandMessage.StopFindStar; logger.Debug("Send Command. Msg:" + message.ToString()); fss.Send(message); return true; } catch (Exception ex) { logger.Error("Send command failed. Msg:" + CommandMessage.StopFindStar.ToString(), ex); return false; } }
public bool SendCommand(string Name) { try { int command = int.Parse(Name); SocketCommandSender fss = new SocketCommandSender(); CommandMessage message = (CommandMessage)command; logger.Debug("Send Command. Msg:" + message.ToString()); fss.Send(message); return true; } catch (Exception ex) { logger.Error("Send command failed. Msg:" + Name, ex); return false; } }