Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

## Release 6.1.0

### New features
- Function to set image pool size
- Check if persistent data to load provides all relevant parameters. Otherwise add default values.
- React on "OnStopFlowConfigProviders" event of FlowConfig module to stop cameras if in "Continuous Mode"

### Improvements
- Prevent to change camera type via UI if camera is already connected

## Release 6.0.0

### New features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@
path="param/args/status"
auto-commit>
</crown-binding>
<crown-edpws-binding
property="disabled"
name="CSK_MultiRemoteCamera/OnCameraConnected"
update-on-resume>
</crown-edpws-binding>
</davinci-toggle-switch>
</layout-row>
<stacked-view id="SV_GigEVision">
Expand Down Expand Up @@ -560,6 +565,11 @@
protocol="crownMSGPACK"
crown-path="camModel">
</crown-set>
<crown-edpws-binding
property="disabled"
name="CSK_MultiRemoteCamera/OnCameraConnected"
update-on-resume>
</crown-edpws-binding>
</davinci-drop-down>
</layout-column>
</layout-row>
Expand Down Expand Up @@ -630,6 +640,45 @@
update-on-resume>
</crown-edpws-binding>
</stacked-view>
<layout-row id="RowLayout63"
style="align-items: center">
<layout-column id="ColumnLayout18"
style="align-items: stretch">
<davinci-value-display
id="VD_ImagePoolSize"
value="Image pool size:"
title="Limits the number of images which can be acquired and used at the same time.">
</davinci-value-display>
</layout-column>
<layout-column id="ColumnLayout19"
style="align-items: stretch">
<davinci-numeric-field
id="NF_ImagePoolSize"
type="outline" min="1"
max="100" ticks="1"
group-separator=","
decimal-separator="."
format-pattern="0"
title="Limits the number of images which can be acquired and used at the same time.">
<crown-binding
event="change"
name="CSK_MultiRemoteCamera/setImagePoolSize"
path="param/args/size"
auto-commit>
</crown-binding>
<crown-edpws-binding
property="value"
name="CSK_MultiRemoteCamera/OnNewImagePoolSize"
update-on-resume>
</crown-edpws-binding>
<crown-edpws-binding
property="disabled"
name="CSK_MultiRemoteCamera/OnCameraConnected"
update-on-resume>
</crown-edpws-binding>
</davinci-numeric-field>
</layout-column>
</layout-row>
<layout-row id="RowLayout38"
style="align-items: center">
<layout-column id="ColumnLayout52"
Expand Down
14 changes: 13 additions & 1 deletion CSK_Module_MultiRemoteCamera/project.mf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ INFO: Other modules can check via "Script.isServedAsEvent" if event of sepecific
<desc>Notify if module can be used on device.</desc>
<param desc="Status" multiplicity="1" name="status" type="bool"/>
</event>
<event name="OnNewImagePoolSize">
<desc>Notfiy image pool size to use for camera.</desc>
<param desc="Size" multiplicity="1" name="size" type="int"/>
</event>
<function name="pageCalled">
<desc>Function to register "OnResume" of the module UI (only as helper function).</desc>
<return desc="Empty string (only needed to simplify binding)." multiplicity="1" name="emptyString" type="string"/>
Expand Down Expand Up @@ -594,6 +598,14 @@ According to the selected model it will use some predefined GigE Vision paramete
<function name="resetModule">
<desc>Function to reset main configuration of module.</desc>
</function>
<function name="setImagePoolSize">
<desc>Function to limit the number of images which can be acquired and used at the same time</desc>
<param desc="Size of the internal image pool (default = 10)." multiplicity="1" name="size" type="int"/>
</function>
<function name="stopFlowConfigRelevantProvider">
<desc>Function to stop FlowConfig relevant providers.</desc>
<param desc="Instance of camera to stop." multiplicity="1" name="instance" type="int"/>
</function>
</serves>
</crown>
<crown name="MultiRemoteCamera_FC">
Expand Down Expand Up @@ -628,7 +640,7 @@ According to the selected model it will use some predefined GigE Vision paramete
</crown>
</crown>
<meta key="author">SICK AG</meta>
<meta key="version">6.0.0</meta>
<meta key="version">6.1.0</meta>
<meta key="priority">low</meta>
<meta key="copy-protected">false</meta>
<meta key="read-protected">false</meta>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ local function handleOnClearOldFlow()
end
Script.register('CSK_FlowConfig.OnClearOldFlow', handleOnClearOldFlow)

--- Function to react if FlowConfig was updated
local function handleOnStopProvider()
if _G.availableAPIs.default and _G.availableAPIs.imageProvider then
for i = 1, #multiRemoteCamera_Instances do
if multiRemoteCamera_Instances[i].parameters.flowConfigPriority then
CSK_MultiRemoteCamera.stopFlowConfigRelevantProvider(i)
break
end
end
end
end
Script.register('CSK_FlowConfig.OnStopFlowConfigProviders', handleOnStopProvider)

--- Function to get access to the multiRemoteCamera_Instances
---@param handle handle Handle of multiRemoteCamera_Instances object
local function setMultiRemoteCamera_Instances_Handle(handle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ local nameOfModule = 'CSK_MultiRemoteCamera'
-- Required to keep track of already allocated resource
local instanceTable = {}

--- Timer to start camera via FlowConfig if in CONTINUOUS (FIXED_FREQUENCY) mode
local tmrStartCamera = Timer.create()
tmrStartCamera:setExpirationTime(5000)
tmrStartCamera:setPeriodic(false)

--- Function to start camera via FlowConig
local function handleOnExpired()
local amount = CSK_MultiRemoteCamera.getInstancesAmount()
for i=1, amount do
CSK_MultiRemoteCamera.setSelectedInstance(i)
local mode = CSK_MultiRemoteCamera.getAcquisitionMode()
if mode == 'FIXED_FREQUENCY' then
CSK_MultiRemoteCamera.startCamera()
end
end
end
Timer.register(tmrStartCamera, 'OnExpired', handleOnExpired)

local function register(handle, _ , callback)

Container.remove(handle, "CB_Function")
Expand Down Expand Up @@ -35,6 +53,8 @@ local function register(handle, _ , callback)
end
Script.register('CSK_FlowConfig.OnNewFlowConfig', localCallback)

tmrStartCamera:start()

return true
end
Script.serveFunction(BLOCK_NAMESPACE ..".register", register)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Script.serveEvent("CSK_MultiRemoteCamera.OnNewStatusSaveAllImagesActive", "Multi
Script.serveEvent("CSK_MultiRemoteCamera.OnNewStatusTempImageActive", "MultiRemoteCamera_OnNewStatusTempImageActive")
Script.serveEvent("CSK_MultiRemoteCamera.OnNewCameraOverviewTable", "MultiRemoteCamera_OnNewCameraOverviewTable")
Script.serveEvent("CSK_MultiRemoteCamera.OnNewProcessingMode", "MultiRemoteCamera_OnNewProcessingMode")
Script.serveEvent('CSK_MultiRemoteCamera.OnNewImagePoolSize', 'MultiRemoteCamera_OnNewImagePoolSize')
Script.serveEvent("CSK_MultiRemoteCamera.OnNewSwitchMode", "MultiRemoteCamera_OnNewSwitchMode")
Script.serveEvent("CSK_MultiRemoteCamera.OnNewMonitoring", "MultiRemoteCamera_OnNewMonitoring")
Script.serveEvent("CSK_MultiRemoteCamera.OnNewMonitoringState", "MultiRemoteCamera_OnNewMonitoringState") --for UI
Expand Down Expand Up @@ -304,6 +305,7 @@ local function handleOnExpiredTmrCamera()
Script.notifyEvent('MultiRemoteCamera_OnNewGigEVisionConfigTableContent', multiRemoteCamera_Instances[selectedInstance].gigEVisionConfigUITable)
end
end
Script.notifyEvent('MultiRemoteCamera_OnNewImagePoolSize', multiRemoteCamera_Instances[selectedInstance].parameters.imagePoolSize)
Script.notifyEvent('MultiRemoteCamera_OnNewMonitoring', multiRemoteCamera_Instances[selectedInstance].parameters.monitorCamera)
Script.notifyEvent('MultiRemoteCamera_OnNewSwitchMode', multiRemoteCamera_Instances[selectedInstance].parameters.switchMode)

Expand Down Expand Up @@ -522,6 +524,12 @@ local function getGigEVision()
end
Script.serveFunction("CSK_MultiRemoteCamera.getGigEVision", getGigEVision)

local function setImagePoolSize(size)
_G.logger:fine(nameOfModule .. ": Set image pool size = " .. tostring(size))
multiRemoteCamera_Instances[selectedInstance].parameters.imagePoolSize = size
end
Script.serveFunction('CSK_MultiRemoteCamera.setImagePoolSize', setImagePoolSize)

local function setSwitchMode (status)
for i = 1, #multiRemoteCamera_Instances do
multiRemoteCamera_Instances[i].parameters.switchMode = status
Expand Down Expand Up @@ -957,6 +965,14 @@ local function getStatusModuleActive()
end
Script.serveFunction('CSK_MultiRemoteCamera.getStatusModuleActive', getStatusModuleActive)

local function stopFlowConfigRelevantProvider(instance)
if multiRemoteCamera_Instances[instance].parameters.acquisitionMode == 'FIXED_FREQUENCY' then
setSelectedInstance(instance)
stopCamera()
end
end
Script.serveFunction('CSK_MultiRemoteCamera.stopFlowConfigRelevantProvider', stopFlowConfigRelevantProvider)

local function clearFlowConfigRelevantConfiguration()
-- Nothing to do so far
end
Expand Down Expand Up @@ -1007,6 +1023,9 @@ local function loadParameters()
if data then
_G.logger:info(nameOfModule .. ": Loaded parameters from CSK_PersistentData module.")
multiRemoteCamera_Instances[selectedInstance].parameters = helperFuncs.convertContainer2Table(data)

multiRemoteCamera_Instances[selectedInstance].parameters = helperFuncs.checkParameters(multiRemoteCamera_Instances[selectedInstance].parameters, helperFuncs.defaultParameters)

multiRemoteCamera_Instances[selectedInstance]:setNewConfig()
updateImageProcessingParameter()
pageCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,45 +87,12 @@ function multiRemoteCamera.create(cameraNo)
self.triggerFunction = nil -- Internally used function to SW trigger the camera

self.parameters = {}
self.parameters.flowConfigPriority = CSK_FlowConfig ~= nil or false -- Status if FlowConfig should have priority for FlowConfig relevant configurations
self.parameters = require('Sensors/MultiRemoteCamera/MultiRemoteCamera_Parameters') -- Load default parameters

-- Instance specific parameters
self.parameters.cameraNo = cameraNo -- Instance no of this camera
self.parameters.camSum = cameraNo -- Amount of all cameras
self.parameters.switchMode = false -- Is camera connected via switch to SIM?
-- gigEvision or false -- GigE Vision camera?
if _G.availableAPIs.GigEVision == true then
self.parameters.gigEvision = true
else
self.parameters.gigEvision = false
end
self.parameters.cameraIP = '192.168.1.10' .. tostring(cameraNo-1) -- IP of camera
self.parameters.shutterTime = 20000 -- Shutter time to use
self.parameters.gain = 1.0 -- Gain
self.parameters.framerate = 1 -- Frame rate in "FIXED_FREQUENCY" mode
self.parameters.acquisitionMode = 'SOFTWARE_TRIGGER' -- 'FIXED_FREQUENCY' / 'SOFTWARE_TRIGGER' / 'HARDWARE_TRIGGER'
self.parameters.swTriggerEvent = '' -- Opt. event to trigger camera in SW mode
self.parameters.hardwareTriggerDelay = 0 -- Opt. delay for HW trigger
self.parameters.triggerDelayBlockName = nil -- Name of specific delay bock within cFlow
self.parameters.colorMode = 'MONO8' --'COLOR8' / 'MONO8' / 'RAW8'
self.parameters.xStartFOV = 0 -- Field of view xStart
self.parameters.xEndFOV = 100 -- Field of view xEnd
self.parameters.yStartFOV = 0 -- Field of view yStart
self.parameters.yEndFOV = 100 -- Field of view yEnd
self.parameters.processingFile = 'CSK_MultiRemoteCamera_ImageProcessing' -- Script to use for processing in thread
self.parameters.monitorCamera = false -- Opt. monitor camera status in "CameraOverview" UI
self.parameters.customGigEVisionConfig = {} -- Custom GigEVision setting, content are 3 tables ".parameter", ".type", ".value"
self.parameters.cameraModel = "PicoMidiCam2" -- 'a2A1920-51gcBAS', 'CustomConfig'

-- Image processing parameters
self.parameters.processingMode = "BOTH" -- 'SCRIPT', 'APP', 'BOTH' --> see "setProcessingMode"
self.parameters.maxImageQueueSize = 5 -- max. size of image queue
self.parameters.savingImagePath = '/public/' -- path of images to save (SD or public)
self.parameters.imageFilePrefix = 'Image_' -- prefix for images to be saved
self.parameters.saveAllImages = false -- Save all incoming images
self.parameters.tempSaveImage = false -- Save latest image to opt. save it later
self.parameters.resizeFactor = 1.0 -- factor to resize the incoming image, 0.1 - 1.0
self.parameters.imageSaveFormat = 'bmp' -- bmp / jpg / png
self.parameters.imageSaveJpgFormatCompression = 90
self.parameters.imageSavePngFormatCompression = 6

Script.serveEvent("CSK_MultiRemoteCamera.OnRegisterCamera" .. tostring(cameraNo), "MultiRemoteCamera_OnRegisterCamera" .. tostring(cameraNo), 'handle:1:Image.Provider.RemoteCamera')
Script.serveEvent("CSK_MultiRemoteCamera.OnDeregisterCamera" .. tostring(cameraNo), "MultiRemoteCamera_OnDeregisterCamera" .. tostring(cameraNo), 'handle:1:Image.Provider.RemoteCamera')
Expand Down Expand Up @@ -201,6 +168,7 @@ end
function multiRemoteCamera:connectCamera()

self.CameraProvider = Image.Provider.RemoteCamera.create()
Image.Provider.RemoteCamera.setImagePoolSize(self.CameraProvider, self.parameters.imagePoolSize)

if self.parameters.gigEvision then
self.CameraProvider:setType('GIGE_VISIONCAM')
Expand Down Expand Up @@ -265,7 +233,9 @@ end

--- Function to stop the camera
function multiRemoteCamera:stopCamera()
self.CameraProvider:stop()
if self.CameraProvider then
self.CameraProvider:stop()
end
end

--- Function to set new camera config
Expand All @@ -280,7 +250,7 @@ function multiRemoteCamera:setNewConfig()
_G.logger:fine(nameOfModule .. ": GigEVision Config")
_G.logger:fine(nameOfModule .. ": Camera-Model: " .. self.parameters.cameraModel)
_G.logger:fine(nameOfModule .. ": Mode = " .. self.parameters.acquisitionMode)

if self.parameters.cameraModel ~= "CustomConfig" then
self.customCameraActive = false
_G.logger:fine(nameOfModule .. ": Camera-Model: " .. self.parameters.cameraModel)
Expand Down
Loading