Commit 7c3dee84 authored by Ivan Tyagov's avatar Ivan Tyagov Committed by Ivan Tyagov

Initial import of oi-sensor from OSIE project repository.

parent 805c4dd2
[instance-profile]
filename = instance.cfg.in
md5sum = f190737372572aca2b726aa06fcf7345
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"description": "Parameters to instantiate an Optical Inspection OPCUA sensor",
"type": "object",
"configuration": {
"headless": {
"description": "Run in a headless (without a X server).",
"type": "int",
"default": "1"
},
"camera": {
"description": "The index of the camera USB device represented as /dev/videoX.",
"type": "string",
"default": ""
},
"mode": {
"description": "The mode of operation of sensor. 0 - with camera support, 1 - no camera support (virtual mode).",
"type": "int",
"default": "0"
}
}
}
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"description": "Values returned by oi-sensors's instantiation.",
"additionalProperties": false,
"properties": {},
"type": "object"
}
[buildout]
parts =
promises
directory
oi-sensor-service
eggs-directory = {{ buildout["eggs-directory"] }}
develop-eggs-directory = {{ buildout["develop-eggs-directory"] }}
offline = true
[check-port-listening-promise]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/${:_buildout_section_name_}
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
etc = ${:home}/etc
var = ${:home}/var
script = ${:etc}/run/
service = ${:etc}/service
promise = ${:etc}/promise/
log = ${:var}/log
bin = ${:home}/bin
[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
configuration.camera = 0
configuration.headless = 1
configuration.mode = 0
configuration.port = 4840
[oi-sensor-service]
recipe = slapos.cookbook:wrapper
command-line = {{ interpreter_location }}/py {{ osie_repository_location }}/oi-sensor/oi-sensor.py --headless ${instance-parameter:configuration.headless} --camera ${instance-parameter:configuration.camera} --mode ${instance-parameter:configuration.mode} --port ${instance-parameter:configuration.port}
wrapper-path = ${directory:service}/oi-sensor-service
output = $${:wrapper-path}
[oi-sensor-service-listen-promise-ipv4]
<= check-port-listening-promise
hostname = 0.0.0.0
port = ${instance-parameter:configuration.port}
[promises]
recipe =
instance-promises =
${oi-sensor-service-listen-promise-ipv4:path}
[buildout]
allow-picked-versions = true
extends =
buildout.hash.cfg
../../stack/monitor/buildout.cfg
../../stack/slapos.cfg
../../component/python3/buildout.cfg
../../component/git/buildout.cfg
../../component/numpy/buildout.cfg
../../component/zlib/buildout.cfg
parts =
interpreter
slapos-cookbook
osie-repository
instance-profile
[opencv-python]
recipe = zc.recipe.egg:custom
egg = opencv-python-headless
rpath =
${zlib:location}/lib/
library-dirs =
${:rpath}
[interpreter]
recipe = zc.recipe.egg:scripts
interpreter = py
eggs =
${python-cffi:egg}
asyncua
${opencv-python:egg}
pyopenssl
${numpy:egg}
[osie-repository]
recipe = slapos.recipe.build:gitclone
git-executable = ${git:location}/bin/git
repository = https://lab.nexedi.com/nexedi/osie.git
revision = 02b7b07
[versions]
# XXX: using a wheel / binary code might be considered unsafe
# ideally we can compile this package in future.
cryptography = 42.0.8:whl
PyYAML = 6.0.1
aiosqlite = 0.20.0
aiofiles = 24.1.0
pyOpenSSL = 24.1.0
opencv-python-headless = 4.10.0.84
[instance-profile]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in
rendered = ${buildout:directory}/instance.cfg
context =
section buildout buildout
key interpreter_location buildout:bin-directory
key osie_repository_location osie-repository:location
{
"name": "OSIE coupler",
"description": "Coupler is an open source thin C client application supporting OPC UA protocol and used in conjunction with beremiz-ide / beremiz-runtime to control industrial processes on the shop field.",
"serialisation": "xml",
"software-type": {
"default": {
"title": "Default",
"software-type": "default",
"description": "Default",
"request": "instance-input-schema.json",
"response": "instance-output-schema.json"
}
}
}
Tests for oi-sensor software release
##############################################################################
#
# Copyright (c) 2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from setuptools import setup, find_packages
version = '0.0.1.dev0'
name = 'slapos.test.oi-sensor'
with open("README.md") as f:
long_description = f.read()
setup(
name=name,
version=version,
description="Test for SlapOS' oi-sensor",
long_description=long_description,
long_description_content_type='text/markdown',
maintainer="Nexedi",
maintainer_email="info@nexedi.com",
url="https://lab.nexedi.com/nexedi/slapos",
packages=find_packages(),
install_requires=[
'slapos.core',
'slapos.libnetworkcache',
'erp5.util',
'psutil',
],
zip_safe=True,
test_suite='test',
)
##############################################################################
# coding: utf-8
#
# Copyright (c) 2022 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
import psutil
from slapos.testing.testcase import installSoftwareUrlList, makeModuleSetUpAndTestCaseClass
oi_sensor_software_release_url = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', 'software.cfg'))
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath(oi_sensor_software_release_url),
# skip software checks
skip_software_check = True)
class OISensorTestCase(SlapOSInstanceTestCase):
@classmethod
def getInstanceParameterDict(cls):
return {'headless': 1, 'mode':1, 'port': 4840}
def test_process(self):
with self.slap.instance_supervisor_rpc as supervisor:
process_names = [process['name']
for process in supervisor.getAllProcessInfo()]
self.assertIn('oi-sensor-service-on-watch', process_names)
def check_connection(self, ip, port):
for connection in psutil.net_connections(kind='tcp4'):
if connection.laddr.ip == ip and connection.laddr.port == port and connection.status == 'LISTEN':
return True
return False
def test_opc_ua(self):
self.assertTrue(self.check_connection('0.0.0.0', 4840))
...@@ -267,6 +267,11 @@ setup = ${slapos-repository:location}/software/js-drone/test/ ...@@ -267,6 +267,11 @@ setup = ${slapos-repository:location}/software/js-drone/test/
egg = slapos.test.osie_coupler egg = slapos.test.osie_coupler
setup = ${slapos-repository:location}/software/osie-coupler/test/ setup = ${slapos-repository:location}/software/osie-coupler/test/
[slapos.test.oi-sensor-setup]
<= setup-develop-egg
egg = slapos.test.oi_sensor
setup = ${slapos-repository:location}/software/oi-sensor/test/
[slapos.core-repository] [slapos.core-repository]
<= git-clone-repository <= git-clone-repository
repository = https://lab.nexedi.com/nexedi/slapos.core.git repository = https://lab.nexedi.com/nexedi/slapos.core.git
...@@ -378,6 +383,7 @@ eggs += ...@@ -378,6 +383,7 @@ eggs +=
${slapos.test.nginx-push-stream-setup:egg} ${slapos.test.nginx-push-stream-setup:egg}
${slapos.test.ors-amarisoft-setup:egg} ${slapos.test.ors-amarisoft-setup:egg}
${slapos.test.osie-coupler-setup:egg} ${slapos.test.osie-coupler-setup:egg}
${slapos.test.oi-sensor-setup:egg}
${slapos.test.peertube-setup:egg} ${slapos.test.peertube-setup:egg}
${slapos.test.plantuml-setup:egg} ${slapos.test.plantuml-setup:egg}
${slapos.test.powerdns-setup:egg} ${slapos.test.powerdns-setup:egg}
...@@ -473,6 +479,7 @@ tests = ...@@ -473,6 +479,7 @@ tests =
nginx-push-stream ${slapos.test.nginx-push-stream-setup:setup} nginx-push-stream ${slapos.test.nginx-push-stream-setup:setup}
ors-amarisoft ${slapos.test.ors-amarisoft-setup:setup} ors-amarisoft ${slapos.test.ors-amarisoft-setup:setup}
osie-coupler ${slapos.test.osie-coupler-setup:setup} osie-coupler ${slapos.test.osie-coupler-setup:setup}
oi-sensor ${slapos.test.oi-sensor-setup:setup}
peertube ${slapos.test.peertube-setup:setup} peertube ${slapos.test.peertube-setup:setup}
plantuml ${slapos.test.plantuml-setup:setup} plantuml ${slapos.test.plantuml-setup:setup}
powerdns ${slapos.test.powerdns-setup:setup} powerdns ${slapos.test.powerdns-setup:setup}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment