Package org.yamcs.parameter
Class ParameterRequestManager
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.parameter.ParameterRequestManager
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,ParameterListener
public class ParameterRequestManager extends com.google.common.util.concurrent.AbstractService implements ParameterListener
Keeps track of which parameters are part of which subscriptions. There are two types of subscriptions: - subscribe all - subscribe to a set Both types have an unique id associated but different methods work with them
-
-
Constructor Summary
Constructors Constructor Description ParameterRequestManager(Processor yproc, XtceTmProcessor tmProcessor)Creates a new ParameterRequestManager, configured to listen to the specified XtceTmProcessor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItemsToRequest(int subscriptionId, List<Parameter> paraList)Add items to a subscription.voidaddItemsToRequest(int subscriptionId, Parameter para)Add items to an request id.voidaddParameterProvider(ParameterProvider parameterProvider)voidaddRequest(int subscriptionId, List<Parameter> paraList, ParameterConsumer tpc)Create request with a given id.intaddRequest(List<Parameter> paraList, DVParameterConsumer dvtpc)Creates a new request with a list of parametersintaddRequest(List<Parameter> paraList, ParameterConsumer tpc)intaddRequest(Parameter para, ParameterConsumer tpc)Creates a request with one parametervoidaddSoftwareParameterManager(DataSource ds, SoftwareParameterManager swParameterManager)Register aSoftwareParameterManagerfor the givenDataSource.protected voiddoStart()protected voiddoStop()ParameterAlarmCheckergetAlarmChecker()AlarmServer<Parameter,ParameterValue>getAlarmServer()LastValueCachegetLastValueCache()ParameterValuegetLastValueFromCache(Parameter param)Get the last value from cache for a specific parametersParametergetParameter(String fqn)returns a parameter based on fully qualified nameParametergetParameter(org.yamcs.protobuf.Yamcs.NamedObjectId paraId)ParameterCachegetParameterCache()<T extends ParameterProvider>
TgetParameterProvider(Class<T> type)SoftwareParameterManagergetSoftwareParameterManager(DataSource ds)List<ParameterValue>getValuesFromCache(Collection<Parameter> plist)Returns the last known value for each parameter.List<ParameterValue>getValuesFromCache(Parameter param)Get all the values from cache for a specific parameters The parameter are returned in descending order (newest parameter is returned first).ObjectgetXtceDb()booleanhasParameterCache()voidinit()This is called after all the parameter providers have been added but before the start.voidremoveItemsFromRequest(int subscriptionID, List<Parameter> paraList)Removes a list of parameters from a request.voidremoveItemsFromRequest(int subscriptionID, Parameter param)Removes a parameter from a rquest.List<Parameter>removeRequest(int subscriptionId)Removes all the items from this subscription and returns them into an List.intsubscribeAll(ParameterConsumer consumer)subscribes to all parametersStringtoString()booleanunsubscribeAll(int subscriptionId)removes the subscription to all parameters return true of the subscription has been removed or false if it was not therevoidupdate(Collection<ParameterValue> params)Called each time some parameters have been updated.
-
-
-
Field Detail
-
processor
public final Processor processor
-
-
Constructor Detail
-
ParameterRequestManager
public ParameterRequestManager(Processor yproc, XtceTmProcessor tmProcessor) throws ConfigurationException
Creates a new ParameterRequestManager, configured to listen to the specified XtceTmProcessor.- Throws:
ConfigurationException
-
-
Method Detail
-
addParameterProvider
public void addParameterProvider(ParameterProvider parameterProvider)
-
init
public void init()
This is called after all the parameter providers have been added but before the start.
-
subscribeAll
public int subscribeAll(ParameterConsumer consumer)
subscribes to all parameters
-
unsubscribeAll
public boolean unsubscribeAll(int subscriptionId)
removes the subscription to all parameters return true of the subscription has been removed or false if it was not there- Parameters:
subscriptionId-- Returns:
-
addRequest
public int addRequest(List<Parameter> paraList, ParameterConsumer tpc)
-
addRequest
public int addRequest(Parameter para, ParameterConsumer tpc)
Creates a request with one parameter- Parameters:
para-tpc-- Returns:
-
addRequest
public int addRequest(List<Parameter> paraList, DVParameterConsumer dvtpc)
Creates a new request with a list of parameters- Parameters:
paraList-dvtpc-- Returns:
- subscription id
-
addRequest
public void addRequest(int subscriptionId, List<Parameter> paraList, ParameterConsumer tpc)Create request with a given id. This is called when switching yprocessors, the id is coming from the other channel.- Parameters:
subscriptionId- - subscription idparaList-tpc-
-
addItemsToRequest
public void addItemsToRequest(int subscriptionId, Parameter para) throws InvalidRequestIdentificationAdd items to an request id.- Parameters:
subscriptionId-para-- Throws:
InvalidRequestIdentification
-
addItemsToRequest
public void addItemsToRequest(int subscriptionId, List<Parameter> paraList) throws InvalidRequestIdentificationAdd items to a subscription.- Parameters:
subscriptionId-paraList- list of parameters that are added to the subscription- Throws:
InvalidRequestIdentification
-
removeItemsFromRequest
public void removeItemsFromRequest(int subscriptionID, Parameter param)Removes a parameter from a rquest. If it is not part of the request, the operation will have no effect.- Parameters:
subscriptionID-param-
-
removeItemsFromRequest
public void removeItemsFromRequest(int subscriptionID, List<Parameter> paraList)Removes a list of parameters from a request. Any parameter specified that is not in the subscription will be ignored.- Parameters:
subscriptionID-paraList-
-
removeRequest
public List<Parameter> removeRequest(int subscriptionId)
Removes all the items from this subscription and returns them into an List. The result is usually used in the TelemetryImpl to move this subscription to a different ParameterRequestManager
-
getParameter
public Parameter getParameter(String fqn) throws InvalidIdentification
returns a parameter based on fully qualified name- Parameters:
fqn-- Returns:
- Throws:
InvalidIdentification
-
getParameter
public Parameter getParameter(org.yamcs.protobuf.Yamcs.NamedObjectId paraId) throws InvalidIdentification
- Parameters:
paraId-- Returns:
- the corresponding parameter definition for a IntemIdentification
- Throws:
InvalidIdentification- in case no provider knows of this parameter.
-
update
public void update(Collection<ParameterValue> params)
Description copied from interface:ParameterListenerCalled each time some parameters have been updated.- Specified by:
updatein interfaceParameterListener- Parameters:
params- - new delivered parameter values
-
getSoftwareParameterManager
public SoftwareParameterManager getSoftwareParameterManager(DataSource ds)
- Returns:
- the SoftwareParameterManager associated to the DataSource or null if not configured
-
getParameterProvider
public <T extends ParameterProvider> T getParameterProvider(Class<T> type)
-
getAlarmChecker
public ParameterAlarmChecker getAlarmChecker()
-
toString
public String toString()
- Overrides:
toStringin classcom.google.common.util.concurrent.AbstractService
-
getAlarmServer
public AlarmServer<Parameter,ParameterValue> getAlarmServer()
-
hasParameterCache
public boolean hasParameterCache()
-
getValuesFromCache
public List<ParameterValue> getValuesFromCache(Collection<Parameter> plist)
Returns the last known value for each parameter.- Parameters:
plist-- Returns:
-
getLastValueFromCache
public ParameterValue getLastValueFromCache(Parameter param)
Get the last value from cache for a specific parameters- Parameters:
param-- Returns:
-
getValuesFromCache
public List<ParameterValue> getValuesFromCache(Parameter param)
Get all the values from cache for a specific parameters The parameter are returned in descending order (newest parameter is returned first). Note that you can only all this function if thehasParameterCache()returns true.- Parameters:
param-- Returns:
-
getParameterCache
public ParameterCache getParameterCache()
-
getXtceDb
public Object getXtceDb()
-
doStart
protected void doStart()
- Specified by:
doStartin classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()
- Specified by:
doStopin classcom.google.common.util.concurrent.AbstractService
-
getLastValueCache
public LastValueCache getLastValueCache()
-
addSoftwareParameterManager
public void addSoftwareParameterManager(DataSource ds, SoftwareParameterManager swParameterManager)
Register aSoftwareParameterManagerfor the givenDataSource. Throws anIllegalStateExceptionif there is already registered a parameter manager for this data source.- Parameters:
ds-swParameterManager-
-
-