@litmusio/miravo-cli-windows-x64 0.0.0-stage → 0.15.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +199 -0
- package/NOTICE +9 -0
- package/README.md +6 -2
- package/THIRD_PARTY_LICENSES.txt +15289 -0
- package/THIRD_PARTY_NOTICES.md +995 -0
- package/console-dist/assets/AnimatePresence-DWGUB15i.js +9 -0
- package/console-dist/assets/activity-DruTYzT1.js +1 -0
- package/console-dist/assets/api-13R-Szmo.js +57 -0
- package/console-dist/assets/arrow-up-right-DOENs04V.js +1 -0
- package/console-dist/assets/asset-detail-D142l0Fv.js +1 -0
- package/console-dist/assets/asset-detail-actions-Cf9kIXus.js +1 -0
- package/console-dist/assets/backup-power-B2I59W_p.js +1 -0
- package/console-dist/assets/badge-CdRB4Nd_.js +1 -0
- package/console-dist/assets/boiler-s_q0j7rz.js +1 -0
- package/console-dist/assets/by-path-BVKB6Tic.js +1 -0
- package/console-dist/assets/check-BTUv4z-H.js +1 -0
- package/console-dist/assets/chevron-down-CqA_2_CH.js +1 -0
- package/console-dist/assets/chevron-right-CVrgKBLR.js +1 -0
- package/console-dist/assets/chiller-r7DzAhJq.js +1 -0
- package/console-dist/assets/chunk-6KYCQHYJ-ga3Yekab.js +3 -0
- package/console-dist/assets/circle-x-BRkh0A1P.js +1 -0
- package/console-dist/assets/commercial-building-YWHjdNWm.js +1 -0
- package/console-dist/assets/compressor-ChZLMC94.js +1 -0
- package/console-dist/assets/console-panel-CnTkf-Zr.js +1 -0
- package/console-dist/assets/dialog-BYkdndf9.js +1 -0
- package/console-dist/assets/district-heating-DaU-3LzU.js +1 -0
- package/console-dist/assets/dom-BxZbg3NX.js +1 -0
- package/console-dist/assets/download-CvjDP5mu.js +1 -0
- package/console-dist/assets/fira-code-cyrillic-ext-wght-normal-DhYMMuQd.woff2 +0 -0
- package/console-dist/assets/fira-code-cyrillic-wght-normal-Y3u8pIsh.woff2 +0 -0
- package/console-dist/assets/fira-code-greek-ext-wght-normal-wWus70Ix.woff2 +0 -0
- package/console-dist/assets/fira-code-greek-wght-normal-B2SviObF.woff2 +0 -0
- package/console-dist/assets/fira-code-latin-ext-wght-normal-Dvfvaomy.woff2 +0 -0
- package/console-dist/assets/fira-code-latin-wght-normal-CHoedHDv.woff2 +0 -0
- package/console-dist/assets/fira-code-symbols2-wght-normal-CE6EOz_n.woff2 +0 -0
- package/console-dist/assets/floor-page-CiAcIxAW.js +1 -0
- package/console-dist/assets/floor-page-E-0txA4z.css +1 -0
- package/console-dist/assets/format-YLUJ7AXt.js +1 -0
- package/console-dist/assets/genset-C6_EUoFo.js +1 -0
- package/console-dist/assets/index-Cf8qRbyA.js +15 -0
- package/console-dist/assets/index-eZjXAdLh.css +2 -0
- package/console-dist/assets/loader-circle-w3T2fxvn.js +1 -0
- package/console-dist/assets/login-DP7gR4IQ.js +136 -0
- package/console-dist/assets/not-found-DeZnLH0i.js +1 -0
- package/console-dist/assets/pharma-cleanroom-DvWD_xsO.js +1 -0
- package/console-dist/assets/preload-helper-7y9sWmk5.js +1 -0
- package/console-dist/assets/react-DRt7cCXI.js +1 -0
- package/console-dist/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
- package/console-dist/assets/rtu-ByogcRPI.js +1 -0
- package/console-dist/assets/runtime-link-D88Db2wY.js +1 -0
- package/console-dist/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
- package/console-dist/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
- package/console-dist/assets/server-B0q1NVkV.js +1 -0
- package/console-dist/assets/shallow-mIK1Qu8X.js +1 -0
- package/console-dist/assets/smart-factory-gfMWfMWM.js +1 -0
- package/console-dist/assets/source-host-miravo-BW-SKMTe.js +1 -0
- package/console-dist/assets/stages-EYRT12Yp.js +1 -0
- package/console-dist/assets/status-DQYLUbXs.js +1 -0
- package/console-dist/assets/tank-Btg5piqB.js +1 -0
- package/console-dist/assets/tooltip-Dfmuq2yz.js +1 -0
- package/console-dist/assets/trash-2-BAh5-hxl.js +1 -0
- package/console-dist/assets/triangle-alert-3Ab-dBrN.js +1 -0
- package/console-dist/assets/use-engine-command-mutation-BXSIzBAw.js +1 -0
- package/console-dist/assets/use-transition-navigate-COPPNZaw.js +2 -0
- package/console-dist/assets/useQuery-BbehJ-ez.js +1 -0
- package/console-dist/assets/utils-D6wrZy-b.js +1 -0
- package/console-dist/assets/validation-6JNiaZvb.js +1 -0
- package/console-dist/assets/vendor-charts-Bquh2dWE.js +56 -0
- package/console-dist/assets/vendor-table-5YnGQUhO.js +4 -0
- package/console-dist/assets/vendor-ui-BGeFlRLR.js +1 -0
- package/console-dist/assets/water-treatment-BkzNjsHx.js +1 -0
- package/console-dist/icon.png +0 -0
- package/console-dist/index.html +53 -0
- package/console-dist/miravo-logo.webp +0 -0
- package/licenses/EPL-2.0.txt +80 -0
- package/licenses/GCC-exception-3.1.txt +33 -0
- package/licenses/GPL-2.0-only.txt +117 -0
- package/licenses/GPL-3.0-only.txt +232 -0
- package/licenses/LGPL-2.1-only.txt +176 -0
- package/licenses/MPL-2.0.txt +373 -0
- package/licenses/OFL-1.1.txt +93 -0
- package/licenses/overrides/@headlessui+vue@1.7.23.txt +24 -0
- package/licenses/overrides/@next+env@16.4.6.txt +24 -0
- package/licenses/overrides/@radix-ui+react-compose-refs@1.1.2.txt +24 -0
- package/licenses/overrides/@radix-ui+react-context@1.1.2.txt +24 -0
- package/licenses/overrides/@radix-ui+react-direction@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-id@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-callback-ref@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-escape-keydown@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-layout-effect@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-rect@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+react-use-size@1.1.1.txt +24 -0
- package/licenses/overrides/@radix-ui+rect@1.1.1.txt +24 -0
- package/licenses/overrides/@replit+codemirror-css-color-picker@6.3.0.txt +6 -0
- package/licenses/overrides/@scalar+openapi-types@0.8.0.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.10.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.7.txt +24 -0
- package/licenses/overrides/@scalar+openapi-types@0.9.9.txt +24 -0
- package/licenses/overrides/@scalar+postman-to-openapi@0.7.1.txt +24 -0
- package/licenses/overrides/@scalar+schemas@0.19.0.txt +24 -0
- package/licenses/overrides/@scalar+workspace-store@0.46.3.txt +24 -0
- package/licenses/overrides/@scalar+workspace-store@0.75.0.txt +24 -0
- package/licenses/overrides/assert-plus@1.0.0.txt +24 -0
- package/licenses/overrides/client-only@0.0.1.txt +24 -0
- package/licenses/overrides/embla-carousel-react@8.6.0.txt +24 -0
- package/licenses/overrides/embla-carousel-reactive-utils@8.6.0.txt +24 -0
- package/licenses/overrides/embla-carousel@8.6.0.txt +24 -0
- package/licenses/overrides/fastdom@1.0.12.txt +12 -0
- package/licenses/overrides/precond@0.2.3.txt +22 -0
- package/licenses/overrides/react-remove-scroll-bar@2.3.8.txt +24 -0
- package/licenses/overrides/strictdom@1.0.1.txt +12 -0
- package/licenses/overrides/victory-vendor@36.9.2.txt +33 -0
- package/licenses/runtime/Bun-1.4.3-LICENSE.md +85 -0
- package/licenses/runtime/ICU-78.1-LICENSE.txt +568 -0
- package/licenses/runtime/bun-components/boringssl.txt +238 -0
- package/licenses/runtime/bun-components/brotli.txt +19 -0
- package/licenses/runtime/bun-components/c-ares.txt +24 -0
- package/licenses/runtime/bun-components/highway.txt +371 -0
- package/licenses/runtime/bun-components/libarchive.txt +65 -0
- package/licenses/runtime/bun-components/libbase64.txt +28 -0
- package/licenses/runtime/bun-components/libdeflate.txt +22 -0
- package/licenses/runtime/bun-components/libjpeg-turbo.txt +147 -0
- package/licenses/runtime/bun-components/libspng.txt +25 -0
- package/licenses/runtime/bun-components/libuv.txt +19 -0
- package/licenses/runtime/bun-components/libwebp.txt +30 -0
- package/licenses/runtime/bun-components/llvm.txt +311 -0
- package/licenses/runtime/bun-components/lol-html.txt +27 -0
- package/licenses/runtime/bun-components/ls-hpack.txt +21 -0
- package/licenses/runtime/bun-components/ls-qpack.txt +21 -0
- package/licenses/runtime/bun-components/lsquic-chrome.txt +32 -0
- package/licenses/runtime/bun-components/lsquic.txt +21 -0
- package/licenses/runtime/bun-components/mimalloc.txt +21 -0
- package/licenses/runtime/bun-components/picohttpparser.txt +24 -0
- package/licenses/runtime/bun-components/simdutf-apache.txt +201 -0
- package/licenses/runtime/bun-components/simdutf-mit.txt +18 -0
- package/licenses/runtime/bun-components/tigerbeetle.txt +177 -0
- package/licenses/runtime/bun-components/tinycc.txt +504 -0
- package/licenses/runtime/bun-components/typescript-go.txt +55 -0
- package/licenses/runtime/bun-components/usockets.txt +201 -0
- package/licenses/runtime/bun-components/uucode.txt +30 -0
- package/licenses/runtime/bun-components/uwebsockets.txt +201 -0
- package/licenses/runtime/bun-components/xxhash.txt +31 -0
- package/licenses/runtime/bun-components/zlib-ng.txt +19 -0
- package/licenses/runtime/bun-components/zstd-copying.txt +339 -0
- package/licenses/runtime/bun-components/zstd.txt +30 -0
- package/licenses/runtime/musl-1.2.6-COPYRIGHT.txt +193 -0
- package/miravo.exe +4 -0
- package/native/S7-NOTICES.txt +11 -0
- package/native/miravo-s7.node +0 -0
- package/native/s7-source/CMakeLists.txt +23 -0
- package/native/s7-source/NODE-SNAP7-LICENSE +24 -0
- package/native/s7-source/addon.cpp +124 -0
- package/native/s7-source/bridge.cpp +150 -0
- package/native/s7-source/node-api-headers/LICENSE +21 -0
- package/native/s7-source/node-api-headers/include/js_native_api.h +591 -0
- package/native/s7-source/node-api-headers/include/js_native_api_types.h +213 -0
- package/native/s7-source/node-api-headers/include/node_api.h +265 -0
- package/native/s7-source/node-api-headers/include/node_api_types.h +58 -0
- package/native/s7-source/node-api-windows.h +78 -0
- package/native/s7-source/snap7/HISTORY.txt +277 -0
- package/native/s7-source/snap7/gpl.txt +674 -0
- package/native/s7-source/snap7/lgpl-3.0.txt +165 -0
- package/native/s7-source/snap7/src/core/miravo_request_validation.h +72 -0
- package/native/s7-source/snap7/src/core/s7_client.cpp +503 -0
- package/native/s7-source/snap7/src/core/s7_client.h +104 -0
- package/native/s7-source/snap7/src/core/s7_firmware.h +1256 -0
- package/native/s7-source/snap7/src/core/s7_isotcp.cpp +541 -0
- package/native/s7-source/snap7/src/core/s7_isotcp.h +271 -0
- package/native/s7-source/snap7/src/core/s7_micro_client.cpp +3328 -0
- package/native/s7-source/snap7/src/core/s7_micro_client.h +364 -0
- package/native/s7-source/snap7/src/core/s7_partner.cpp +1178 -0
- package/native/s7-source/snap7/src/core/s7_partner.h +284 -0
- package/native/s7-source/snap7/src/core/s7_peer.cpp +121 -0
- package/native/s7-source/snap7/src/core/s7_peer.h +58 -0
- package/native/s7-source/snap7/src/core/s7_server.cpp +2161 -0
- package/native/s7-source/snap7/src/core/s7_server.h +261 -0
- package/native/s7-source/snap7/src/core/s7_text.cpp +788 -0
- package/native/s7-source/snap7/src/core/s7_text.h +49 -0
- package/native/s7-source/snap7/src/core/s7_types.h +1066 -0
- package/native/s7-source/snap7/src/lib/snap7.def +129 -0
- package/native/s7-source/snap7/src/lib/snap7_libmain.cpp +1196 -0
- package/native/s7-source/snap7/src/lib/snap7_libmain.h +201 -0
- package/native/s7-source/snap7/src/sys/snap_msgsock.cpp +958 -0
- package/native/s7-source/snap7/src/sys/snap_msgsock.h +339 -0
- package/native/s7-source/snap7/src/sys/snap_platform.h +152 -0
- package/native/s7-source/snap7/src/sys/snap_sysutils.cpp +73 -0
- package/native/s7-source/snap7/src/sys/snap_sysutils.h +39 -0
- package/native/s7-source/snap7/src/sys/snap_tcpsrvr.cpp +487 -0
- package/native/s7-source/snap7/src/sys/snap_tcpsrvr.h +247 -0
- package/native/s7-source/snap7/src/sys/snap_threads.cpp +162 -0
- package/native/s7-source/snap7/src/sys/snap_threads.h +45 -0
- package/native/s7-source/snap7/src/sys/sol_threads.h +208 -0
- package/native/s7-source/snap7/src/sys/unix_threads.h +228 -0
- package/native/s7-source/snap7/src/sys/win_threads.h +159 -0
- package/nodesets/.ignore +1 -0
- package/nodesets/1.02/FTNIR.NodeSet2.xml +819 -0
- package/nodesets/1.02/Opc.Ua.Adi.NodeSet2.xml +8301 -0
- package/nodesets/1.02/Opc.Ua.Di.NodeSet2.xml +1785 -0
- package/nodesets/Opc.ISA95.NodeSet2.xml +3589 -0
- package/nodesets/Opc.Ua.AMB.NodeSet2.xml +1395 -0
- package/nodesets/Opc.Ua.Adi.NodeSet2.xml +8301 -0
- package/nodesets/Opc.Ua.Adi.Types.xsd +104 -0
- package/nodesets/Opc.Ua.AutoID.NodeSet2.xml +6062 -0
- package/nodesets/Opc.Ua.CNC.NodeSet.xml +15875 -0
- package/nodesets/Opc.Ua.CommercialKitchenEquipment.NodeSet2.xml +12096 -0
- package/nodesets/Opc.Ua.Di.NodeSet2.xml +6042 -0
- package/nodesets/Opc.Ua.Di.Types.xsd +161 -0
- package/nodesets/Opc.Ua.Eumabois.Nodeset2.xml +2483 -0
- package/nodesets/Opc.Ua.Gds.NodeSet2.xml +8282 -0
- package/nodesets/Opc.Ua.Glass.NodeSet2.xml +5100 -0
- package/nodesets/Opc.Ua.IA.NodeSet2.xml +1782 -0
- package/nodesets/Opc.Ua.IOLink.NodeSet2.xml +4374 -0
- package/nodesets/Opc.Ua.IOLinkIODD.NodeSet2.xml +139 -0
- package/nodesets/Opc.Ua.IRDI.NodeSet2.xml +2243 -0
- package/nodesets/Opc.Ua.Ijt.Base.NodeSet2.xml +19459 -0
- package/nodesets/Opc.Ua.Ijt.Tightening.NodeSet2.xml +883 -0
- package/nodesets/Opc.Ua.LADS.NodeSet2.xml +7086 -0
- package/nodesets/Opc.Ua.MachineTool.NodeSet2.xml +7884 -0
- package/nodesets/Opc.Ua.MachineVision.NodeSet2.xml +17324 -0
- package/nodesets/Opc.Ua.Machinery.Jobs.Nodeset2.xml +1249 -0
- package/nodesets/Opc.Ua.Machinery.NodeSet2.xml +2099 -0
- package/nodesets/Opc.Ua.Machinery.ProcessValues.NodeSet2.xml +1858 -0
- package/nodesets/Opc.Ua.Machinery_Result.NodeSet2.xml +2640 -0
- package/nodesets/Opc.Ua.MetalForming.NodeSet2.xml +1577 -0
- package/nodesets/Opc.Ua.NodeSet2.xml +81975 -0
- package/nodesets/Opc.Ua.PADIM.NodeSet2.xml +14131 -0
- package/nodesets/Opc.Ua.PackML.NodeSet2.xml +3030 -0
- package/nodesets/Opc.Ua.Robotics.NodeSet2.xml +7409 -0
- package/nodesets/Opc.Ua.Scales.NodeSet2.xml +15817 -0
- package/nodesets/Opc.Ua.Types.bsd +3499 -0
- package/nodesets/Opc.Ua.Weihenstephan.NodeSet2.xml +821 -0
- package/nodesets/Opc.Ua.Woodworking.NodeSet2.xml +17831 -0
- package/nodesets/UANodeSet.xsd +497 -0
- package/nodesets/opc.ua.isa95-jobcontrol.nodeset2.xml +4594 -0
- package/package.json +34 -4
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#ifndef s7_partner_h
|
|
27
|
+
#define s7_partner_h
|
|
28
|
+
//---------------------------------------------------------------------------
|
|
29
|
+
#include "snap_threads.h"
|
|
30
|
+
#include "s7_peer.h"
|
|
31
|
+
//---------------------------------------------------------------------------
|
|
32
|
+
using namespace std;
|
|
33
|
+
//---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
#define MaxPartners 256
|
|
36
|
+
#define MaxAdapters 256
|
|
37
|
+
#define csTimeout 1500 // Connection server destruction timeout
|
|
38
|
+
|
|
39
|
+
const int par_stopped = 0; // stopped
|
|
40
|
+
const int par_connecting = 1; // running and active connecting
|
|
41
|
+
const int par_waiting = 2; // running and waiting for a connection
|
|
42
|
+
const int par_linked = 3; // running and connected
|
|
43
|
+
const int par_sending = 4; // sending data
|
|
44
|
+
const int par_receiving = 5; // receiving data
|
|
45
|
+
const int par_binderror = 6; // error starting passive partner
|
|
46
|
+
|
|
47
|
+
const longword errParMask = 0xFFF00000;
|
|
48
|
+
const longword errParBase = 0x000FFFFF;
|
|
49
|
+
|
|
50
|
+
const longword errParAddressInUse = 0x00200000;
|
|
51
|
+
const longword errParNoRoom = 0x00300000;
|
|
52
|
+
const longword errServerNoRoom = 0x00400000;
|
|
53
|
+
const longword errParInvalidParams = 0x00500000;
|
|
54
|
+
const longword errParNotLinked = 0x00600000;
|
|
55
|
+
const longword errParBusy = 0x00700000;
|
|
56
|
+
const longword errParFrameTimeout = 0x00800000;
|
|
57
|
+
const longword errParInvalidPDU = 0x00900000;
|
|
58
|
+
const longword errParSendTimeout = 0x00A00000;
|
|
59
|
+
const longword errParRecvTimeout = 0x00B00000;
|
|
60
|
+
const longword errParSendRefused = 0x00C00000;
|
|
61
|
+
const longword errParNegotiatingPDU = 0x00D00000;
|
|
62
|
+
const longword errParSendingBlock = 0x00E00000;
|
|
63
|
+
const longword errParRecvingBlock = 0x00F00000;
|
|
64
|
+
const longword errParBindError = 0x01000000;
|
|
65
|
+
const longword errParDestroying = 0x01100000;
|
|
66
|
+
const longword errParInvalidParamNumber = 0x01200000; // Invalid param (par_get/set_param)
|
|
67
|
+
const longword errParCannotChangeParam = 0x01300000; // Cannot change because running
|
|
68
|
+
const longword errParBufferTooSmall = 0x01400000; // Raised by LabVIEW wrapper
|
|
69
|
+
|
|
70
|
+
class TSnap7Partner;
|
|
71
|
+
typedef TSnap7Partner *PSnap7Partner;
|
|
72
|
+
|
|
73
|
+
class TConnectionServer;
|
|
74
|
+
typedef TConnectionServer *PConnectionServer;
|
|
75
|
+
|
|
76
|
+
//------------------------------------------------------------------------------
|
|
77
|
+
// CONNECTION SERVERS MANAGER
|
|
78
|
+
//------------------------------------------------------------------------------
|
|
79
|
+
class TServersManager
|
|
80
|
+
{
|
|
81
|
+
private:
|
|
82
|
+
PConnectionServer Servers[MaxAdapters];
|
|
83
|
+
TSnapCriticalSection *cs;
|
|
84
|
+
void Lock();
|
|
85
|
+
void Unlock();
|
|
86
|
+
int CreateServer(longword BindAddress, PConnectionServer &Server);
|
|
87
|
+
void AddServer(PConnectionServer Server);
|
|
88
|
+
public:
|
|
89
|
+
int ServersCount;
|
|
90
|
+
TServersManager();
|
|
91
|
+
~TServersManager();
|
|
92
|
+
|
|
93
|
+
int GetServer(longword BindAddress, PConnectionServer &Server);
|
|
94
|
+
void RemovePartner(PConnectionServer Server, PSnap7Partner Partner);
|
|
95
|
+
|
|
96
|
+
};
|
|
97
|
+
typedef TServersManager *PServersManager;
|
|
98
|
+
|
|
99
|
+
//------------------------------------------------------------------------------
|
|
100
|
+
// CONNECTION SERVER (Don't inherit from TcpSrv to avoid dependence)
|
|
101
|
+
//------------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
class TConnListenerThread : public TSnapThread
|
|
104
|
+
{
|
|
105
|
+
private:
|
|
106
|
+
TMsgSocket *FListener;
|
|
107
|
+
TConnectionServer *FServer;
|
|
108
|
+
public:
|
|
109
|
+
TConnListenerThread(TMsgSocket *Listener, TConnectionServer *Server)
|
|
110
|
+
{
|
|
111
|
+
FServer=Server;
|
|
112
|
+
FListener=Listener;
|
|
113
|
+
FreeOnTerminate=false;
|
|
114
|
+
};
|
|
115
|
+
void Execute();
|
|
116
|
+
};
|
|
117
|
+
typedef TConnListenerThread *PConnListenerThread;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class TConnectionServer
|
|
121
|
+
{
|
|
122
|
+
private:
|
|
123
|
+
TSnapCriticalSection *cs;
|
|
124
|
+
bool FRunning;
|
|
125
|
+
// Bind Address
|
|
126
|
+
char FLocalAddress[16];
|
|
127
|
+
// Server listener
|
|
128
|
+
PConnListenerThread ServerThread;
|
|
129
|
+
// Socket listener
|
|
130
|
+
PMsgSocket SockListener;
|
|
131
|
+
// Finds a partner bound to the address
|
|
132
|
+
PSnap7Partner FindPartner(longword Address);
|
|
133
|
+
// Locks the Partner list
|
|
134
|
+
void Lock();
|
|
135
|
+
// Unlocks the Partner list
|
|
136
|
+
void Unlock();
|
|
137
|
+
protected:
|
|
138
|
+
// Workers list
|
|
139
|
+
PSnap7Partner Partners[MaxPartners];
|
|
140
|
+
bool Destroying;
|
|
141
|
+
void Incoming(socket_t Sock);
|
|
142
|
+
int Start();
|
|
143
|
+
int FirstFree();
|
|
144
|
+
public:
|
|
145
|
+
int PartnersCount;
|
|
146
|
+
longword LocalBind;
|
|
147
|
+
TConnectionServer();
|
|
148
|
+
~TConnectionServer();
|
|
149
|
+
|
|
150
|
+
int StartTo(const char *Address);
|
|
151
|
+
void Stop();
|
|
152
|
+
int RegisterPartner(PSnap7Partner Partner);
|
|
153
|
+
void RemovePartner(PSnap7Partner Partner);
|
|
154
|
+
friend class TConnListenerThread;
|
|
155
|
+
};
|
|
156
|
+
typedef TConnectionServer * PConnectionServer;
|
|
157
|
+
|
|
158
|
+
//------------------------------------------------------------------------------
|
|
159
|
+
// PARTNER THREAD
|
|
160
|
+
//------------------------------------------------------------------------------
|
|
161
|
+
class TPartnerThread : public TSnapThread
|
|
162
|
+
{
|
|
163
|
+
private:
|
|
164
|
+
TSnap7Partner *FPartner;
|
|
165
|
+
longword FRecoveryTime;
|
|
166
|
+
longword FKaElapsed;
|
|
167
|
+
protected:
|
|
168
|
+
void Execute();
|
|
169
|
+
public:
|
|
170
|
+
TPartnerThread(TSnap7Partner *Partner, longword RecoveryTime)
|
|
171
|
+
{
|
|
172
|
+
FPartner = Partner;
|
|
173
|
+
FRecoveryTime =RecoveryTime;
|
|
174
|
+
FreeOnTerminate =false;
|
|
175
|
+
};
|
|
176
|
+
~TPartnerThread(){};
|
|
177
|
+
};
|
|
178
|
+
typedef TPartnerThread *PPartnerThread;
|
|
179
|
+
//------------------------------------------------------------------------------
|
|
180
|
+
// S7 PARTNER
|
|
181
|
+
//------------------------------------------------------------------------------
|
|
182
|
+
|
|
183
|
+
typedef struct{
|
|
184
|
+
bool First;
|
|
185
|
+
bool Done;
|
|
186
|
+
uintptr_t Offset;
|
|
187
|
+
longword TotalLength;
|
|
188
|
+
longword In_R_ID;
|
|
189
|
+
longword Elapsed;
|
|
190
|
+
byte Seq_Out;
|
|
191
|
+
}TRecvStatus;
|
|
192
|
+
|
|
193
|
+
typedef struct{
|
|
194
|
+
bool Done;
|
|
195
|
+
int Size;
|
|
196
|
+
int Result;
|
|
197
|
+
longword R_ID;
|
|
198
|
+
longword Count;
|
|
199
|
+
}TRecvLast;
|
|
200
|
+
|
|
201
|
+
extern "C" {
|
|
202
|
+
typedef void (S7API *pfn_ParBRecvCallBack)(void * usrPtr, int opResult, longword R_ID, void *pdata, int Size);
|
|
203
|
+
typedef void (S7API *pfn_ParBSendCompletion)(void * usrPtr, int opResult);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
class TSnap7Partner : public TSnap7Peer
|
|
207
|
+
{
|
|
208
|
+
private:
|
|
209
|
+
PS7ReqHeader PDUH_in;
|
|
210
|
+
void *FRecvUsrPtr;
|
|
211
|
+
void *FSendUsrPtr;
|
|
212
|
+
PSnapEvent SendEvt;
|
|
213
|
+
PSnapEvent RecvEvt;
|
|
214
|
+
PConnectionServer FServer;
|
|
215
|
+
PPartnerThread FWorkerThread;
|
|
216
|
+
bool FSendPending;
|
|
217
|
+
bool FRecvPending;
|
|
218
|
+
TRecvStatus FRecvStatus;
|
|
219
|
+
TRecvLast FRecvLast;
|
|
220
|
+
TPendingBuffer TxBuffer;
|
|
221
|
+
TPendingBuffer RxBuffer;
|
|
222
|
+
longword FSendElapsed;
|
|
223
|
+
bool BindError;
|
|
224
|
+
byte NextByte;
|
|
225
|
+
pfn_ParBRecvCallBack OnBRecv;
|
|
226
|
+
pfn_ParBSendCompletion OnBSend;
|
|
227
|
+
void ClearRecv();
|
|
228
|
+
byte GetNextByte();
|
|
229
|
+
void CloseWorker();
|
|
230
|
+
bool BlockSend();
|
|
231
|
+
bool PickData();
|
|
232
|
+
bool BlockRecv();
|
|
233
|
+
bool ConnectionConfirm();
|
|
234
|
+
protected:
|
|
235
|
+
bool Stopping;
|
|
236
|
+
bool Execute();
|
|
237
|
+
void Disconnect();
|
|
238
|
+
bool ConnectToPeer();
|
|
239
|
+
bool PerformFunctionNegotiate();
|
|
240
|
+
public:
|
|
241
|
+
bool Active;
|
|
242
|
+
bool Running;
|
|
243
|
+
longword PeerAddress;
|
|
244
|
+
longword SrcAddress;
|
|
245
|
+
int BRecvTimeout;
|
|
246
|
+
int BSendTimeout;
|
|
247
|
+
longword SendTime;
|
|
248
|
+
longword RecvTime;
|
|
249
|
+
longword RecoveryTime;
|
|
250
|
+
longword KeepAliveTime;
|
|
251
|
+
longword BytesSent;
|
|
252
|
+
longword BytesRecv;
|
|
253
|
+
longword SendErrors;
|
|
254
|
+
longword RecvErrors;
|
|
255
|
+
// The partner is linked when the init sequence is terminated
|
|
256
|
+
//(TCP connection + ISO connection + PDU Length negotiation)
|
|
257
|
+
bool Linked;
|
|
258
|
+
TSnap7Partner(bool CreateActive);
|
|
259
|
+
~TSnap7Partner();
|
|
260
|
+
// Control
|
|
261
|
+
int Start();
|
|
262
|
+
int StartTo(const char *LocAddress, const char *RemAddress, word LocTsap, word RemTsap);
|
|
263
|
+
int Stop();
|
|
264
|
+
int Status();
|
|
265
|
+
int GetParam(int ParamNumber, void * pValue);
|
|
266
|
+
int SetParam(int ParamNumber, void * pValue);
|
|
267
|
+
// Block send
|
|
268
|
+
int BSend(longword R_ID, void *pUsrData, int Size);
|
|
269
|
+
int AsBSend(longword R_ID, void *pUsrData, int Size);
|
|
270
|
+
bool CheckAsBSendCompletion(int &opResult);
|
|
271
|
+
int WaitAsBSendCompletion(longword Timeout);
|
|
272
|
+
int SetSendCallback(pfn_ParBSendCompletion pCompletion, void *usrPtr);
|
|
273
|
+
// Block recv
|
|
274
|
+
int BRecv(longword &R_ID, void *pData, int &Size, longword Timeout);
|
|
275
|
+
bool CheckAsBRecvCompletion(int &opResult, longword &R_ID,
|
|
276
|
+
void *pData, int &Size);
|
|
277
|
+
int SetRecvCallback(pfn_ParBRecvCallBack pCompletion, void *usrPtr);
|
|
278
|
+
|
|
279
|
+
friend class TConnectionServer;
|
|
280
|
+
friend class TPartnerThread;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
#endif // s7_partner_h
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#include "s7_peer.h"
|
|
27
|
+
//---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
TSnap7Peer::TSnap7Peer()
|
|
30
|
+
{
|
|
31
|
+
PDUH_out=PS7ReqHeader(&PDU.Payload);
|
|
32
|
+
PDURequest=480; // Our request, FPDULength will contain the CPU answer
|
|
33
|
+
LastError=0;
|
|
34
|
+
Destroying = false;
|
|
35
|
+
}
|
|
36
|
+
//---------------------------------------------------------------------------
|
|
37
|
+
TSnap7Peer::~TSnap7Peer()
|
|
38
|
+
{
|
|
39
|
+
Destroying = true;
|
|
40
|
+
}
|
|
41
|
+
//---------------------------------------------------------------------------
|
|
42
|
+
int TSnap7Peer::SetError(int Error)
|
|
43
|
+
{
|
|
44
|
+
if (Error==0)
|
|
45
|
+
ClrError();
|
|
46
|
+
else
|
|
47
|
+
LastError=Error | LastIsoError | LastTcpError;
|
|
48
|
+
return Error;
|
|
49
|
+
}
|
|
50
|
+
//---------------------------------------------------------------------------
|
|
51
|
+
void TSnap7Peer::ClrError()
|
|
52
|
+
{
|
|
53
|
+
LastError=0;
|
|
54
|
+
LastIsoError=0;
|
|
55
|
+
LastTcpError=0;
|
|
56
|
+
}
|
|
57
|
+
//---------------------------------------------------------------------------
|
|
58
|
+
word TSnap7Peer::GetNextWord()
|
|
59
|
+
{
|
|
60
|
+
if (cntword==0xFFFF)
|
|
61
|
+
cntword=0;
|
|
62
|
+
return cntword++;
|
|
63
|
+
}
|
|
64
|
+
//---------------------------------------------------------------------------
|
|
65
|
+
int TSnap7Peer::NegotiatePDULength( )
|
|
66
|
+
{
|
|
67
|
+
int Result, IsoSize = 0;
|
|
68
|
+
PReqFunNegotiateParams ReqNegotiate;
|
|
69
|
+
PResFunNegotiateParams ResNegotiate;
|
|
70
|
+
PS7ResHeader23 Answer;
|
|
71
|
+
ClrError();
|
|
72
|
+
// Setup Pointers
|
|
73
|
+
ReqNegotiate = PReqFunNegotiateParams(pbyte(PDUH_out) + sizeof(TS7ReqHeader));
|
|
74
|
+
// Header
|
|
75
|
+
PDUH_out->P = 0x32; // Always $32
|
|
76
|
+
PDUH_out->PDUType = PduType_request; // $01
|
|
77
|
+
PDUH_out->AB_EX = 0x0000; // Always $0000
|
|
78
|
+
PDUH_out->Sequence = GetNextWord(); // AutoInc
|
|
79
|
+
PDUH_out->ParLen = SwapWord(sizeof(TReqFunNegotiateParams)); // 8 bytes
|
|
80
|
+
PDUH_out->DataLen = 0x0000;
|
|
81
|
+
// Params
|
|
82
|
+
ReqNegotiate->FunNegotiate = pduNegotiate;
|
|
83
|
+
ReqNegotiate->Unknown = 0x00;
|
|
84
|
+
ReqNegotiate->ParallelJobs_1 = 0x0100;
|
|
85
|
+
ReqNegotiate->ParallelJobs_2 = 0x0100;
|
|
86
|
+
ReqNegotiate->PDULength = SwapWord(PDURequest);
|
|
87
|
+
IsoSize = sizeof( TS7ReqHeader ) + sizeof( TReqFunNegotiateParams );
|
|
88
|
+
Result = isoExchangeBuffer(NULL, IsoSize);
|
|
89
|
+
if ((Result == 0) && (IsoSize == int(sizeof(TS7ResHeader23) + sizeof(TResFunNegotiateParams))))
|
|
90
|
+
{
|
|
91
|
+
// Setup pointers
|
|
92
|
+
Answer = PS7ResHeader23(&PDU.Payload);
|
|
93
|
+
ResNegotiate = PResFunNegotiateParams(pbyte(Answer) + sizeof(TS7ResHeader23));
|
|
94
|
+
if ( Answer->Error != 0 )
|
|
95
|
+
Result = SetError(errNegotiatingPDU);
|
|
96
|
+
if ( Result == 0 )
|
|
97
|
+
PDULength = SwapWord(ResNegotiate->PDULength);
|
|
98
|
+
}
|
|
99
|
+
return Result;
|
|
100
|
+
}
|
|
101
|
+
//---------------------------------------------------------------------------
|
|
102
|
+
void TSnap7Peer::PeerDisconnect( )
|
|
103
|
+
{
|
|
104
|
+
ClrError();
|
|
105
|
+
isoDisconnect(true);
|
|
106
|
+
}
|
|
107
|
+
//---------------------------------------------------------------------------
|
|
108
|
+
int TSnap7Peer::PeerConnect( )
|
|
109
|
+
{
|
|
110
|
+
int Result;
|
|
111
|
+
|
|
112
|
+
ClrError();
|
|
113
|
+
Result = isoConnect();
|
|
114
|
+
if (Result == 0)
|
|
115
|
+
{
|
|
116
|
+
Result = NegotiatePDULength();
|
|
117
|
+
if (Result != 0)
|
|
118
|
+
PeerDisconnect();
|
|
119
|
+
}
|
|
120
|
+
return Result;
|
|
121
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*=============================================================================|
|
|
2
|
+
| PROJECT SNAP7 1.3.0 |
|
|
3
|
+
|==============================================================================|
|
|
4
|
+
| Copyright (C) 2013, 2015 Davide Nardella |
|
|
5
|
+
| All rights reserved. |
|
|
6
|
+
|==============================================================================|
|
|
7
|
+
| SNAP7 is free software: you can redistribute it and/or modify |
|
|
8
|
+
| it under the terms of the Lesser GNU General Public License as published by |
|
|
9
|
+
| the Free Software Foundation, either version 3 of the License, or |
|
|
10
|
+
| (at your option) any later version. |
|
|
11
|
+
| |
|
|
12
|
+
| It means that you can distribute your commercial software linked with |
|
|
13
|
+
| SNAP7 without the requirement to distribute the source code of your |
|
|
14
|
+
| application and without the requirement that your application be itself |
|
|
15
|
+
| distributed under LGPL. |
|
|
16
|
+
| |
|
|
17
|
+
| SNAP7 is distributed in the hope that it will be useful, |
|
|
18
|
+
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
19
|
+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
20
|
+
| Lesser GNU General Public License for more details. |
|
|
21
|
+
| |
|
|
22
|
+
| You should have received a copy of the GNU General Public License and a |
|
|
23
|
+
| copy of Lesser GNU General Public License along with Snap7. |
|
|
24
|
+
| If not, see http://www.gnu.org/licenses/ |
|
|
25
|
+
|=============================================================================*/
|
|
26
|
+
#ifndef s7_peer_h
|
|
27
|
+
#define s7_peer_h
|
|
28
|
+
//---------------------------------------------------------------------------
|
|
29
|
+
#include "s7_types.h"
|
|
30
|
+
#include "s7_isotcp.h"
|
|
31
|
+
//---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
const longword errPeerMask = 0xFFF00000;
|
|
34
|
+
const longword errPeerBase = 0x000FFFFF;
|
|
35
|
+
const longword errNegotiatingPDU = 0x00100000;
|
|
36
|
+
|
|
37
|
+
class TSnap7Peer: public TIsoTcpSocket
|
|
38
|
+
{
|
|
39
|
+
private:
|
|
40
|
+
word cntword;
|
|
41
|
+
protected:
|
|
42
|
+
bool Destroying;
|
|
43
|
+
PS7ReqHeader PDUH_out;
|
|
44
|
+
word GetNextWord();
|
|
45
|
+
int SetError(int Error);
|
|
46
|
+
int NegotiatePDULength();
|
|
47
|
+
void ClrError();
|
|
48
|
+
public:
|
|
49
|
+
int LastError;
|
|
50
|
+
int PDULength;
|
|
51
|
+
int PDURequest;
|
|
52
|
+
TSnap7Peer();
|
|
53
|
+
~TSnap7Peer();
|
|
54
|
+
void PeerDisconnect();
|
|
55
|
+
int PeerConnect();
|
|
56
|
+
};
|
|
57
|
+
//---------------------------------------------------------------------------
|
|
58
|
+
#endif
|