Class TriggeredScraperImpl
- java.lang.Object
-
- org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScraperImpl
-
- All Implemented Interfaces:
Scraper,TriggeredScraperMBean
public class TriggeredScraperImpl extends Object implements Scraper, TriggeredScraperMBean
replaces the old Scraper that only could do scheduled scraping jobs Triggers have been introduced, so that in configuration "scrapeTime" has been exchanged by "triggerConfig" Some example: - 200ms scheduling is now performed by "triggerConfig: (SCHEDULED,200)" in scraper-configuration - a triggered S7 variable can be used as follows: "triggerConfig: (S7_TRIGGER_VAR,10,(%M0.3:BOOL)==(true))" meaning that Boolean in Marker-Block in Byte-Offset 0, Bit-Offset 3 is scanned every 10ms, when trigger has a rising-edge the acquirement of data-block is triggered the trigger variable must be a valid address as defined with PLC4X-S7-Driver right now boolean variables as well as numeric variables could be used as data-types available comparators are ==,!= for all data-types and >,>=,<,<= for numeric data-types
-
-
Constructor Summary
Constructors Constructor Description TriggeredScraperImpl(ScraperConfiguration config, PlcConnectionManager plcConnectionManager, ResultHandler resultHandler, TriggerCollector triggerCollector)Creates a Scraper instance from a configuration.TriggeredScraperImpl(ScraperConfiguration config, ResultHandler resultHandler, TriggerCollector triggerCollector)Creates a Scraper instance from a configuration.TriggeredScraperImpl(ScraperConfigurationTriggeredImpl config, PlcConnectionManager plcConnectionManager, ResultHandler resultHandler, TriggerCollector triggerCollector, int poolSizeScheduler, int poolSizeExecutor)Creates a Scraper instance from a configuration.TriggeredScraperImpl(ResultHandler resultHandler, PlcConnectionManager plcConnectionManager, List<ScrapeJob> jobs, TriggerCollector triggerCollector, long futureTimeOut)Creates a Scraper instance from a configuration.TriggeredScraperImpl(ResultHandler resultHandler, PlcConnectionManager plcConnectionManager, List<ScrapeJob> jobs, TriggerCollector triggerCollector, long futureTimeOut, int poolSizeScheduler, int poolSizeExecutor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>convertPlcResponseToMap(PlcReadResponse plcReadResponse)transforms the results from aPlcReadResponseinto a mapintgetNumberOfActiveTasks()retrieves active tasks used for scrapingstatic PlcConnectiongetPlcConnection(PlcConnectionManager plcConnectionManager, String connectionString, ExecutorService executorService, long requestTimeoutMs)acquires a plc connection from connection poolstatic PlcConnectiongetPlcConnection(PlcConnectionManager plcConnectionManager, String connectionString, ExecutorService executorService, long requestTimeoutMs, String info)acquires a plc connection from connection poolbooleanisRunning()voidstart()Start the scraping.voidstop()stops active scraping processes
-
-
-
Constructor Detail
-
TriggeredScraperImpl
public TriggeredScraperImpl(ScraperConfiguration config, ResultHandler resultHandler, TriggerCollector triggerCollector) throws ScraperException
Creates a Scraper instance from a configuration. By default aCachedPlcConnectionManageris used.- Parameters:
config- Configuration to use.resultHandler- handler the defines the processing of acquired datatriggerCollector- the trigger collector- Throws:
ScraperException- something went wrong
-
TriggeredScraperImpl
public TriggeredScraperImpl(ScraperConfiguration config, PlcConnectionManager plcConnectionManager, ResultHandler resultHandler, TriggerCollector triggerCollector) throws ScraperException
Creates a Scraper instance from a configuration.- Parameters:
config- Configuration to use.plcConnectionManager- external DriverManagerresultHandler- handler the defines the processing of acquired datatriggerCollector- the trigger collector- Throws:
ScraperException- something went wrong
-
TriggeredScraperImpl
public TriggeredScraperImpl(ScraperConfigurationTriggeredImpl config, PlcConnectionManager plcConnectionManager, ResultHandler resultHandler, TriggerCollector triggerCollector, int poolSizeScheduler, int poolSizeExecutor) throws ScraperException
Creates a Scraper instance from a configuration.- Parameters:
config- Configuration to use.plcConnectionManager- external DriverManagerresultHandler- handler the defines the processing of acquired datatriggerCollector- the trigger collectorpoolSizeExecutor- the pool size of the executorpoolSizeScheduler- the pool size of the scheduler- Throws:
ScraperException- something went wrong
-
TriggeredScraperImpl
public TriggeredScraperImpl(ResultHandler resultHandler, PlcConnectionManager plcConnectionManager, List<ScrapeJob> jobs, TriggerCollector triggerCollector, long futureTimeOut)
Creates a Scraper instance from a configuration.- Parameters:
plcConnectionManager- external DriverManagerresultHandler- handler the defines the processing of acquired datajobs- list of jobs that scraper shall handletriggerCollector- a collection that centralizes the trigger requests and joins them to grouped plc requestsfutureTimeOut- max duration of future to return a result
-
TriggeredScraperImpl
public TriggeredScraperImpl(ResultHandler resultHandler, PlcConnectionManager plcConnectionManager, List<ScrapeJob> jobs, TriggerCollector triggerCollector, long futureTimeOut, int poolSizeScheduler, int poolSizeExecutor)
-
-
Method Detail
-
stop
public void stop()
Description copied from interface:Scraperstops active scraping processes
-
getPlcConnection
public static PlcConnection getPlcConnection(PlcConnectionManager plcConnectionManager, String connectionString, ExecutorService executorService, long requestTimeoutMs, String info) throws InterruptedException, ExecutionException, TimeoutException
acquires a plc connection from connection pool- Parameters:
plcConnectionManager- Connection manager handling connection and poolsconnectionString- Connection string as defined in the regarding implementation ofPlcDriverexecutorService- ExecutorService holding a pool as threads handling requests and stuffrequestTimeoutMs- maximum wait time for the future to return a resultinfo- additional info for trace reasons- Returns:
- the
PlcConnectionused for acquiring data from PLC endpoint - Throws:
InterruptedException- something went wrongExecutionException- something went wrongTimeoutException- something went wrong
-
getPlcConnection
public static PlcConnection getPlcConnection(PlcConnectionManager plcConnectionManager, String connectionString, ExecutorService executorService, long requestTimeoutMs) throws InterruptedException, ExecutionException, TimeoutException
acquires a plc connection from connection pool- Parameters:
plcConnectionManager- Connection manager handling connection and poolsconnectionString- Connection string as defined in the regarding implementation ofPlcDriverexecutorService- ExecuterService holding a pool as threads handling requests and stuffrequestTimeoutMs- maximum waiting time for the future to return a result- Returns:
- the
PlcConnectionused for acquiring data from PLC endpoint - Throws:
InterruptedException- something went wrongExecutionException- something went wrongTimeoutException- something went wrong
-
convertPlcResponseToMap
public static Map<String,Object> convertPlcResponseToMap(PlcReadResponse plcReadResponse)
transforms the results from aPlcReadResponseinto a map- Parameters:
plcReadResponse- response that shall be converted to map for further processing- Returns:
- the converted map
-
isRunning
public boolean isRunning()
- Specified by:
isRunningin interfaceTriggeredScraperMBean
-
getNumberOfActiveTasks
public int getNumberOfActiveTasks()
Description copied from interface:Scraperretrieves active tasks used for scraping- Specified by:
getNumberOfActiveTasksin interfaceScraper- Specified by:
getNumberOfActiveTasksin interfaceTriggeredScraperMBean- Returns:
- number of active tasks
-
-