public static ReturnKnowType GRBHandler(String Ra, String Dec, String FOV, DateTime UpdateTIme) { StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == STATIONNAME.TNO); if (ThisSite == null) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Station TNO 2.4 Meter Telescope is now offline. Please contact Pakawat Prasit", null)); } try { //ReturnDeviceInformation OutHum = ThisSite.GetDataT07ByCommandName(DEVICENAME.T24WSC, InformationdName.WEATHER_ATTRIBUTE_DATA_OUTHUM); //ReturnDeviceInformation Temp = ThisSite.GetDataT07ByCommandName(DEVICENAME.T24WSC, InformationdName.WEATHER_ATTRIBUTE_DATA_TEMPOUT); //ReturnDeviceInformation DewPt = ThisSite.GetDataT07ByCommandName(DEVICENAME.T24WSC, InformationdName.WEATHER_ATTRIBUTE_DATA_DEWPT); //ReturnDeviceInformation InfoDate = ThisSite.GetDataT07ByCommandName(DEVICENAME.T24WSC, InformationdName.WEATHER_ATTRIBUTE_DATA_DATE); //ReturnDeviceInformation InfoTime = ThisSite.GetDataT07ByCommandName(DEVICENAME.T24WSC, InformationdName.WEATHER_ATTRIBUTE_DATA_TIME); //if (Convert.ToDouble(OutHum.ReturnValue.Value) > 85) // return ReturnKnowType.DefineReturn(ReturnStatus.Failed, "We can not open the dome because the humidity is heighter than 85%. (Weather time is " + InfoDate.ReturnValue.Value.ToString() + // " " + InfoTime.ReturnValue.Value.ToString() + ")", null); //else if (Convert.ToDouble(Temp.ReturnValue.Value) - Convert.ToDouble(DewPt.ReturnValue.Value) <= 2) // return ReturnKnowType.DefineReturn(ReturnStatus.Failed, "We can not open the dome because the dew point is too height. (Weather time is " + InfoDate.ReturnValue.Value.ToString() + // " " + InfoTime.ReturnValue.Value.ToString() + ")", null); } catch { } return(ThisSite.RelayGRB(Ra, Dec, FOV, UpdateTIme)); }
public ReturnKnowType AstroCreateStation(STATIONNAME StationName, Double Version = 0) { try { if (Version != RequirePackageVersion) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co003) Failed to create " + StationName + ". Your client version is " + Version + " (Require version " + RequirePackageVersion + ").")); } else { OperationContext context = OperationContext.Current; ServerCallBack SiteCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>(); CallBackHandler.AddSiteConnection(StationName, context.SessionId, SiteCallBack); OperationContext.Current.Channel.Closed += StationChannel_Closed; OperationContext.Current.Channel.Faulted += StationChannel_Closed; ReturnKnowType CreateSiteResult = AstroData.CreateStation(StationName, context.SessionId, SiteCallBack); return(CreateSiteResult); } } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co001) Failed to create site at TTCSCreateSite see. (" + e.Message + ")")); } }
public static ReturnKnowType GetAllOnlineStation() { if (KeeperData != null) { return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null, KeeperData)); } else { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT017) Failed to get online station because all station is offline.")); } }
public static ReturnKnowType RemoveInterfaceConnection(String InterfaceSessionID) { try { InterfaceConnectionList.RemoveAll(Item => Item.InterfaceSessionID == InterfaceSessionID); return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to remove interface connection see. (" + e.Message + ")")); } }
public static ReturnKnowType Loggout(String SessionID) { SessionStructure ThisSession = SessionList.FirstOrDefault(Item => Item.SessionID == SessionID); if (ThisSession != null) { SessionList.Remove(ThisSession); return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, "Successful loggout.")); } else { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Can not loggout. Invalid session ID.")); } }
public static ReturnKnowType SubscribeByCommmanName(ServerCallBack ClientCallBack, String ClientSessionID, STATIONNAME StationName, DEVICECATEGORY DeviceName, String CommandName) { try { SubscribeStructure.SubscribeType SubscribeType = GetSubscribeType(StationName, DeviceName, CommandName); DuplicationSubscribeChecking(SubscribeType, ClientSessionID, StationName, DeviceName, CommandName); SubscribeStructure ThisSubscribe = SubscribeList.FirstOrDefault(Item => Item.StationName == StationName && Item.DeviceName == DeviceName && Item.CommandName == CommandName); if (ThisSubscribe == null) { ClientSubscription ThisClient = new ClientSubscription(); ThisClient.ClientCallBack = ClientCallBack; ThisClient.ClientSessionID = ClientSessionID; ThisSubscribe = new SubscribeStructure(); ThisSubscribe.StationName = StationName; ThisSubscribe.DeviceName = DeviceName; ThisSubscribe.CommandName = CommandName; ThisSubscribe.Type = SubscribeType; ThisSubscribe.ClientList = new List <ClientSubscription>(); ThisSubscribe.ClientList.Add(ThisClient); } else { ClientSubscription ThisClient = ThisSubscribe.ClientList.FirstOrDefault(Item => Item.ClientSessionID == ClientSessionID); if (ThisClient == null) { ThisClient = new ClientSubscription(); ThisClient.ClientCallBack = ClientCallBack; ThisClient.ClientSessionID = ClientSessionID; ThisSubscribe.ClientList.Add(ThisClient); } else { return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, "Your request is already exist in subscribe list. Please check.")); } } return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to subscribe information see. (" + e.Message + ")")); } }
public static ReturnKnowType UpdateStationUser(String UserID, String UserName, String UserLoginName, String UserLoginPassword, String UserPermissionType, String USerStationPermission, String StationName, DATAACTION UserAction) { STATIONNAME ThisStationName = TTCSHelper.StationStrConveter(StationName); StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == ThisStationName); if (ThisSite != null) { ReturnKnowType ThisResult = ThisSite.UpdateStationUser(UserID, UserName, UserLoginName, UserLoginPassword, UserPermissionType, USerStationPermission, UserAction); if (ThisResult.ReturnType == ReturnStatus.SUCESSFUL) { return(ThisResult); } } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT004) Can not update user data to station. Will try again.", false)); }
public ReturnKnowType AstroCreateClientInterface(String InterfaceName) { try { OperationContext context = OperationContext.Current; ServerCallBack ServerCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>(); CallBackHandler.AddInterfaceConnection(InterfaceName, context.SessionId, ServerCallBack); OperationContext.Current.Channel.Closed += InterfaceChannel_Closed; OperationContext.Current.Channel.Faulted += InterfaceChannel_Closed; return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));; } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to create client interface at TTCSCreateClientInterface see. (" + e.Message + ")")); } }
public static ReturnKnowType AddInterfaceConnection(String InterfaceName, String InterfaceSessionID, ServerCallBack SiteCallBack) { try { InterfaceConnection NewInterfaceConnection = new InterfaceConnection(); NewInterfaceConnection.InterfaceName = InterfaceName; NewInterfaceConnection.InterfaceSessionID = InterfaceSessionID; NewInterfaceConnection.SiteCallBack = SiteCallBack; InterfaceConnectionList.Add(NewInterfaceConnection); return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Failed to add interface connection see. (" + e.Message + ")")); } }
public static ReturnKnowType UserVerification(String UserLoginName, String UserLoginPassword, int SessionTimeout) { foreach (UserStrcture ThisUser in UserList) { if (ThisUser.UserLoginName == UserLoginName && ThisUser.UserLoginPassword == UserLoginPassword) { SessionStructure ThisSession = new SessionStructure(); ThisSession.SessionID = SessionGenerator(ThisUser.UserID, ThisUser.UserLoginPassword); ThisSession.SessionLifeTime = SessionTimeout; ThisUser.SessionID = ThisSession.SessionID; SessionList.Add(ThisSession); return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null, ThisSession)); } } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "Invalid UserLoginName and UserLoginPassword.")); }
private static ReturnKnowType VerifyParameter(TCSCommandStructure ThisCommand, Object[] Value) { String ParameterFormat = ""; if (ThisCommand.Parameter != null) { ParameterFormat = String.Join(", ", ThisCommand.Parameter); } if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter != null) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD005) Missing parameter for Command name " + ThisCommand.Command + "(" + ParameterFormat + ")")); } else if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter == null) { return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); } else if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter == null) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD006) Command name (" + ThisCommand.Command + ") has no parameter. Please check.")); } if (ThisCommand.Parameter.Count() != Value.Count()) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD002) Command name (" + ThisCommand.Command + ") does not contain " + Value.Count() + " Parameters. Please cheange it to " + ThisCommand.Command + "(" + ParameterFormat + ")")); } else if (ThisCommand.Parameter.Count() == 0 && Value.Count() == 0) { return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); } for (int i = 0; i < Value.Count(); i++) { Type ParaType = VerifyDataType(Value[i], ThisCommand.Parameter[i]); if (ThisCommand.Parameter[i] != ParaType) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD003) Invalid parameter see. Command name " + ThisCommand.Command + "(" + ParameterFormat + ")")); } } return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); }
public static ReturnKnowType GetOnlineStation(STATIONNAME StationName) { if (KeeperData != null) { StationHandler ThisStation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (ThisStation != null) { return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null, ThisStation)); } else { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT015) Failed to get online station because all station " + StationName + " is offline.")); } } else { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT016) Failed to get online station because all station " + StationName + " is offline.")); } }
public static ReturnKnowType SetCommandHandler(STATIONNAME StationName, DEVICECATEGORY DeviceCategory, DEVICENAME DeviceName, dynamic CommandName, Object[] Values, DateTime CommandDateTime) { StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (ThisSite != null) { Boolean AckState = false; if (StationName == STATIONNAME.ASTROSERVER) { AckState = true; } else { return(ThisSite.RelayCommandToStation(DeviceCategory, DeviceName, CommandName, Values)); } return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null, AckState)); } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT003) Failed to relay set command to station.", false)); }
public static ReturnKnowType ScriptHandler(STATIONNAME StationDestination, ScriptStructure[] ThisScriptList) { StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == StationDestination); if (ThisSite != null) { Boolean AckState = false; if (StationDestination == STATIONNAME.ASTROSERVER) { AckState = true; } else { return(ThisSite.SendScriptToStation(ThisScriptList)); } return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null, AckState)); } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#TT003) Failed to relay set command to station.", false)); }
public static ReturnKnowType VerifyCommand(STATIONNAME StationName, DEVICECATEGORY DeviceCategory, dynamic CommandName, Object[] Value) { if (CommandName == null) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD001) Failed to get command name from list see. (Command name was not avaliable.)")); } TCSCommandStructure ThisCommand = CommandList.FirstOrDefault(Item => Item.StationOwner.Contains(StationName) && Item.DeviceCategory == DeviceCategory && Item.Command.ToString() == CommandName.ToString()); if (ThisCommand != null) { List <String> ValueStr = new List <String>(); foreach (Object ThisValue in Value) { ValueStr.Add(ThisValue.ToString()); } Object[] Values = ValueConvertion(ValueStr.ToArray()); ReturnKnowType ThisReturn = VerifyParameter(ThisCommand, Values); return(ThisReturn); } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD004) Could not be found commmand (" + CommandName + ") that contain station name : (" + StationName + ") Device Name : (" + DeviceCategory + "). Please check station name or device name.")); }
public ReturnKnowType AddImage(STATIONNAME StationName, DEVICENAME DeviceName, UInt16[][] Value, DateTime DataTimeStamp) { AstroData.NewIMAGINGInformation(StationName, DeviceName, IMAGING.IMAGING_CCD_IMAGEARRAY16, Value, DataTimeStamp); return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null)); }