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 void
addItemsToRequest(int subscriptionId, List<Parameter> paraList)
Add items to a subscription.void
addItemsToRequest(int subscriptionId, Parameter para)
Add items to an request id.void
addParameterProvider(ParameterProvider parameterProvider)
void
addRequest(int subscriptionId, List<Parameter> paraList, ParameterConsumer tpc)
Create request with a given id.int
addRequest(List<Parameter> paraList, DVParameterConsumer dvtpc)
Creates a new request with a list of parametersint
addRequest(List<Parameter> paraList, ParameterConsumer tpc)
int
addRequest(Parameter para, ParameterConsumer tpc)
Creates a request with one parametervoid
addSoftwareParameterManager(DataSource ds, SoftwareParameterManager swParameterManager)
Register aSoftwareParameterManager
for the givenDataSource
.protected void
doStart()
protected void
doStop()
ParameterAlarmChecker
getAlarmChecker()
AlarmServer<Parameter,ParameterValue>
getAlarmServer()
LastValueCache
getLastValueCache()
ParameterValue
getLastValueFromCache(Parameter param)
Get the last value from cache for a specific parametersParameter
getParameter(String fqn)
returns a parameter based on fully qualified nameParameter
getParameter(org.yamcs.protobuf.Yamcs.NamedObjectId paraId)
ParameterCache
getParameterCache()
<T extends ParameterProvider>
TgetParameterProvider(Class<T> type)
SoftwareParameterManager
getSoftwareParameterManager(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).Object
getXtceDb()
boolean
hasParameterCache()
void
init()
This is called after all the parameter providers have been added but before the start.void
removeItemsFromRequest(int subscriptionID, List<Parameter> paraList)
Removes a list of parameters from a request.void
removeItemsFromRequest(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.int
subscribeAll(ParameterConsumer consumer)
subscribes to all parametersString
toString()
boolean
unsubscribeAll(int subscriptionId)
removes the subscription to all parameters return true of the subscription has been removed or false if it was not therevoid
update(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 InvalidRequestIdentification
Add items to an request id.- Parameters:
subscriptionId
-para
-- Throws:
InvalidRequestIdentification
-
addItemsToRequest
public void addItemsToRequest(int subscriptionId, List<Parameter> paraList) throws InvalidRequestIdentification
Add 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:ParameterListener
Called each time some parameters have been updated.- Specified by:
update
in 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:
toString
in 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:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()
- Specified by:
doStop
in classcom.google.common.util.concurrent.AbstractService
-
getLastValueCache
public LastValueCache getLastValueCache()
-
addSoftwareParameterManager
public void addSoftwareParameterManager(DataSource ds, SoftwareParameterManager swParameterManager)
Register aSoftwareParameterManager
for the givenDataSource
. Throws anIllegalStateException
if there is already registered a parameter manager for this data source.- Parameters:
ds
-swParameterManager
-
-
-