├── .idea
├── .gitignore
├── vcs.xml
├── modules.xml
├── misc.xml
├── dgiot_dtu.iml
└── compiler.xml
├── DD-All.ico
├── renovate.json
├── lib
├── CodeLib.dll
├── Spire.Doc.dll
├── Spire.Pdf.dll
├── Spire.License.dll
├── PLCComHelperProj.dll
├── System.Data.SQLite.dll
├── System.Data.SQLite.EF6.dll
└── System.Data.SQLite.Linq.dll
├── Resources
└── bridge.jpg
├── component
├── Opc
│ ├── cfg.ini
│ ├── App.xaml
│ ├── Model
│ │ ├── Item.cs
│ │ ├── HostCollection.cs
│ │ ├── GroupEntity.cs
│ │ ├── Thing.cs
│ │ ├── Header.cs
│ │ └── OpcDaService.cs
│ ├── Protocol
│ │ ├── StartMonitoringItemsRsp.cs
│ │ ├── StopMonitoringItemsReq.cs
│ │ ├── ReadItemsRsp.cs
│ │ ├── StartMonitoringItemsReq.cs
│ │ ├── ReadItemsReq.cs
│ │ ├── Command.cs
│ │ └── WriteNodesValuesReq.cs
│ ├── packages.config
│ ├── IOPCDa.cs
│ ├── app.config
│ ├── OPCUAHelper.cs
│ ├── app.manifest
│ ├── log4net.config
│ ├── OPCDAHelper.cs
│ ├── Da.csproj
│ └── View
│ │ └── OPCDAViewHelper.cs
├── Plc
│ └── PLCHelper.cs
├── BACnet
│ ├── BACnetHelper.cs
│ ├── BacProperty.cs
│ └── BacDevice.cs
├── Sqlserver
│ └── SqlServerHelper.cs
├── Http
│ └── HttpClientHelper.cs
├── Udp
│ ├── UDPClientHelper.cs
│ └── UDPServerHelper.cs
├── Printer
│ ├── PrinterHelper.cs
│ ├── Knova.cs
│ ├── PdfPrinter.cs
│ └── BarCodePrinter.cs
├── sqlite
│ ├── ManagerInfoDal.cs
│ └── SqliteHelper.cs
├── SerialPort
│ └── SerialPortHelper.cs
├── Mqtt
│ └── MqttServerHelper.cs
└── Tcp
│ ├── TcpClientHelper.cs
│ └── TcpServerHelper.cs
├── .gitignore
├── .github
├── ISSUE_TEMPLATE.md
├── weekly-digest.yml
├── ISSUE_TEMPLATE
│ ├── support-needed.md
│ ├── feature-request.md
│ └── bug-report.md
├── workflows
│ ├── docker.yml
│ ├── accurics.yaml
│ ├── release.yml
│ ├── gitee-repos-mirror.yml
│ ├── dotnet.yml
│ ├── build_slim_packages.yaml
│ └── .gitlint
└── PULL_REQUEST_TEMPLATE.md
├── app.config
├── FodyWeavers.xml
├── dgiot_dtu.csproj.user
├── Properties
├── Settings.settings
├── Settings.Designer.cs
├── AssemblyInfo.cs
├── Resources.Designer.cs
└── Resources.resx
├── opcda.txt
├── stylecop.json
├── Program.cs
├── dgiot_dtu.sln
├── utils
├── ConfigHelper.cs
├── TimerHelper.cs
├── FileHelper.cs
├── IPScanHelper.cs
├── LogHelper.cs
├── JsonArray.cs
└── TreeViewHelper.cs
├── .editorconfig
├── README-JP.md
├── README.md
├── README-RU.md
├── syscfg.xml
├── README-CN.md
├── packages.config
├── FodyWeavers.xsd
└── LICENSE
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/DD-All.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/DD-All.ico
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "config:base"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/lib/CodeLib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/CodeLib.dll
--------------------------------------------------------------------------------
/lib/Spire.Doc.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/Spire.Doc.dll
--------------------------------------------------------------------------------
/lib/Spire.Pdf.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/Spire.Pdf.dll
--------------------------------------------------------------------------------
/Resources/bridge.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/Resources/bridge.jpg
--------------------------------------------------------------------------------
/component/Opc/cfg.ini:
--------------------------------------------------------------------------------
1 | [scan]
2 | networkSegments=192.168.1.4
3 | whitelist=SunFull.X2OPC.1
--------------------------------------------------------------------------------
/lib/Spire.License.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/Spire.License.dll
--------------------------------------------------------------------------------
/component/Plc/PLCHelper.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/component/Plc/PLCHelper.cs
--------------------------------------------------------------------------------
/lib/PLCComHelperProj.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/PLCComHelperProj.dll
--------------------------------------------------------------------------------
/lib/System.Data.SQLite.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/System.Data.SQLite.dll
--------------------------------------------------------------------------------
/lib/System.Data.SQLite.EF6.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/System.Data.SQLite.EF6.dll
--------------------------------------------------------------------------------
/lib/System.Data.SQLite.Linq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/lib/System.Data.SQLite.Linq.dll
--------------------------------------------------------------------------------
/component/BACnet/BACnetHelper.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dgiot/dgiot_dtu/HEAD/component/BACnet/BACnetHelper.cs
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .eunit
2 | test-data/
3 | !deps/.placeholder
4 | _build/
5 | www/
6 | obj/
7 | bin/
8 | packages/
9 | .vs/
10 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | #### Environment
2 |
3 | - OS:
4 | - Erlang/OTP:
5 | - EMQ:
6 |
7 | #### Description
8 |
9 | *A description of the issue*
10 |
11 |
--------------------------------------------------------------------------------
/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/dgiot_dtu.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ShowAllFiles
5 |
6 |
--------------------------------------------------------------------------------
/.github/weekly-digest.yml:
--------------------------------------------------------------------------------
1 | # Configuration for weekly-digest - https://github.com/apps/weekly-digest
2 | publishDay: monday
3 | canPublishIssues: true
4 | canPublishPullRequests: true
5 | canPublishContributors: true
6 | canPublishStargazers: true
7 | canPublishCommits: true
8 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/opcda.txt:
--------------------------------------------------------------------------------
1 | GCU331_YJ.SX_PZ96_U_55
2 | GCU331_YJ.SX_PZ96_I_55
3 | GCU331_YJ.SX_PZ96_P_55
4 | GCU331_YJ.SX_PZ96_U_160
5 | GCU331_YJ.SX_PZ96_I_160
6 | GCU331_YJ.SX_PZ96_P_160
7 | GCU331_YJ.p_L_1
8 | GCU331_YJ.p_L_2
9 | GCU331_YJ.p_Q_2
10 | GCU331_YJ.Q_Q_DN65
11 | GCU331_YJ.Q_Q_DN100
12 | GCU331_YJ.Q_Q_DN125
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/support-needed.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Support Needed
3 | about: Asking a question about usages, docs or anything you're insterested in
4 | title: ''
5 | labels: Support
6 | assignees: h7ml
7 |
8 | ---
9 |
10 | **Please describe your problem in detail, if necessary, you can upload the log file through the attachment**:
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: Feature
6 | assignees: h7ml
7 |
8 | ---
9 |
10 |
11 |
12 | **What would you like to be added/modified**:
13 |
14 | **Why is this needed**:
15 |
--------------------------------------------------------------------------------
/component/Opc/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/dgiot_dtu.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/component/Opc/Model/Item.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | public class Item
8 | {
9 | public string ItemId { get; set; }
10 |
11 | public object Data { get; set; }
12 |
13 | public string Type { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/StartMonitoringItemsRsp.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | public class StartMonitoringItemsRsp
8 | {
9 | public string ServiceId { get; set; }
10 |
11 | public string GroupId { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/StopMonitoringItemsReq.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | public class StopMonitoringItemsReq
8 | {
9 | public string ServiceId { get; set; }
10 |
11 | public string Id { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/component/Opc/Model/HostCollection.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Da
8 | {
9 | internal class HostCollection
10 | {
11 | public string Host { get; set; }
12 |
13 | public List ServiceIds { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/component/Opc/Model/GroupEntity.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 | using System.Windows.Forms;
7 |
8 | namespace Da
9 | {
10 | internal class GroupEntity
11 | {
12 | public string Host { get; set; }
13 |
14 | public string ProgId { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/docker.yml:
--------------------------------------------------------------------------------
1 | name: Continuos Integration with Github
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*'
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@master
12 | - name: Publish to Docker Repository
13 | uses: elgohr/Publish-Docker-Github-Action@master
14 | with:
15 | name: ispeakcode/docker-githubaction
16 | username: ${{ secrets.DOCKER_USERNAME }}
17 | password: ${{ secrets.DOCKER_PASSWORD }}
18 |
--------------------------------------------------------------------------------
/component/Opc/Model/Thing.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Da
8 | {
9 | internal class Thing
10 | {
11 | public string Device { get; set; }
12 |
13 | public string Proctol { get; set; }
14 |
15 | public string Group { get; set; }
16 |
17 | public List- Items { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/ReadItemsRsp.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Da
8 | {
9 | public class ReadItemsRsp
10 | {
11 | public string ServiceId { get; set; }
12 |
13 | public string GroupId { get; set; }
14 |
15 | public string StrMd5 { get; set; }
16 |
17 | public List
- ItemValues { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.github/workflows/accurics.yaml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches:
4 | - master
5 | workflow_dispatch:
6 | jobs:
7 | accurics-scan:
8 | runs-on: ubuntu-latest
9 | name: accurics-scan
10 | steps:
11 | - name: Checkout repository
12 | uses: actions/checkout@v2
13 | - name: Accurics Scan
14 | id: accurics-scan
15 | uses: docker://accurics/terrascan-action:latest
16 | with:
17 | only_warn: true
18 | verbose: true
19 | webhook_url: https://app.accurics.com/v1/api/terrascan
20 | webhook_token: a20de3ab-f00e-4e1a-a37f-dbceafe4150e
--------------------------------------------------------------------------------
/component/Opc/Model/Header.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | public struct Header
8 | {
9 | public int Id;
10 | public int Cmd;
11 | public int ErrorCode;
12 | public int ContentSize;
13 |
14 | public Header(int id, int cmd, int errorcode, int payloadLength)
15 | {
16 | Id = id;
17 | Cmd = cmd;
18 | ErrorCode = errorcode;
19 | ContentSize = payloadLength;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/component/Opc/Model/OpcDaService.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | using System;
8 | using System.Collections.Generic;
9 | using TitaniumAS.Opc.Client.Da;
10 |
11 | public class OpcDaService
12 | {
13 | public string Host { get; set; }
14 |
15 | public string ServiceId { get; set; }
16 |
17 | public OpcDaServer Service { get; set; }
18 |
19 | public Dictionary OpcDaGroupS;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | // ACTION REQUIRED: This file was automatically added to your project, but it
3 | // will not take effect until additional steps are taken to enable it. See the
4 | // following page for additional information:
5 | //
6 | // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md
7 |
8 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
9 | "settings": {
10 | "documentationRules": {
11 | "companyName": "PlaceholderCompany"
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 |
2 | # https://github.com/actions/create-release
3 | name: Create Release
4 |
5 | on:
6 | push:
7 | tags:
8 | - 'v*'
9 |
10 | jobs:
11 | build:
12 | name: Create Release
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 | - name: Checkout code
17 | uses: actions/checkout@master
18 |
19 | - name: Create Release
20 | id: create_release
21 | uses: actions/create-release@latest
22 | env:
23 | GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
24 | with:
25 | tag_name: ${{ github.ref }}
26 | release_name: ${{ github.ref }}
27 | draft: false
28 | prerelease: false
29 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Windows.Forms;
9 |
10 | internal static class Program
11 | {
12 | ///
13 | /// The main entry point for the application.
14 | ///
15 | [STAThread]
16 | private static void Main()
17 | {
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 |
21 | Application.Run(new MainForm());
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.github/workflows/gitee-repos-mirror.yml:
--------------------------------------------------------------------------------
1 | name: Gitee repos mirror periodic job
2 |
3 | on:
4 | push:
5 | watch:
6 | types: started
7 | schedule:
8 | - cron: "0 23 * * *"
9 |
10 | jobs:
11 | build:
12 |
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 |
17 | - name: Mirror the Github organization repos to Gitee.
18 | uses: Yikun/hub-mirror-action@v1.0
19 | with:
20 | src: github/dgiot
21 | dst: gitee/dgiiot
22 | dst_key: ${{ secrets.PRIVATE_KEY }}
23 | dst_token: ${{ secrets.TOKEN }}
24 | account_type: org
25 | timeout: '1h'
26 | debug: true
27 | force_update: true
28 | black_list: "issue-generator,dgiot-dashboard"
29 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/StartMonitoringItemsReq.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Da
8 | {
9 | public class StartMonitoringItemsReq
10 | {
11 | public string ServiceId { get; set; }
12 |
13 | public string StrMd5 { get; set; }
14 |
15 | public List Items { get; set; }
16 |
17 | public StartMonitoringItemsReq(string serviceProgId, List items, string strmd5)
18 | {
19 | ServiceId = serviceProgId;
20 | Items = items;
21 | StrMd5 = strmd5;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: Support
6 | assignees: h7ml
7 |
8 | ---
9 |
10 |
11 |
12 |
13 | **Environment**:
14 |
15 | - dgiot version (e.g. `dgiot_ctl status`):
16 | - Hardware configuration (e.g. `lscpu`):
17 | - OS (e.g. `cat /etc/os-release`):
18 | - Kernel (e.g. `uname -a`):
19 | - Erlang/OTP version (in case you build emqx from source code):
20 | - Others:
21 |
22 | **What happened and what you expected to happen**:
23 |
24 | **How to reproduce it (as minimally and precisely as possible)**:
25 |
26 | **Anything else we need to know?**:
27 |
--------------------------------------------------------------------------------
/component/BACnet/BacProperty.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System.IO.BACnet;
8 |
9 | public class BacProperty
10 | {
11 | #region ObjectId
12 |
13 | public BacnetObjectId ObjectId { get; set; }
14 |
15 | #endregion
16 |
17 | #region PROP_DESCRIPTION 描述
18 |
19 | public string PROP_DESCRIPTION { get; set; }
20 |
21 | #endregion
22 |
23 | #region PROP_OBJECT_NAME 点名
24 |
25 | public string PROP_OBJECT_NAME { get; set; }
26 |
27 | #endregion
28 |
29 | public object PROP_PRESENT_VALUE { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/component/Opc/Protocol/ReadItemsReq.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | using System.Collections.Generic;
8 |
9 | public class ReadItemsReq
10 | {
11 | public string ServiceId { get; set; }
12 |
13 | public string GroupId { get; set; }
14 |
15 | public string StrMd5 { get; set; }
16 |
17 | public List Items { get; set; }
18 |
19 | public ReadItemsReq(string serviceProgId, List items, string groupId, string strmd5)
20 | {
21 | ServiceId = serviceProgId;
22 | GroupId = groupId;
23 | StrMd5 = strmd5;
24 | Items = items;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 | Fixes
3 |
4 | **If your build fails** due to your commit message not passing the build checks, please review the guidelines here: https://github.com/emqx/emqx/blob/master/CONTRIBUTING.md.
5 |
6 | ## PR Checklist
7 | Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
8 |
9 | - [ ] Tests for the changes have been added (for bug fixes / features)
10 | - [ ] Docs have been added / updated (for bug fixes / features)
11 | - [ ] In case of non-backward compatible changes, reviewer should check this item as a write-off, and add details in **Backward Compatibility** section
12 |
13 | ## Backward Compatibility
14 |
15 | ## More information
16 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/Command.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Da
6 | {
7 | public enum Command
8 | {
9 | Get_Nodes_Req = 0x400000, //
10 | Get_Nodes_Rsp = 0x400001,
11 |
12 | Start_Monitor_Nodes_Req = 0x400002,
13 | Start_Monitor_Nodes_Rsp = 0x400003,
14 |
15 | Stop_Monitor_Nodes_Req = 0x400004,
16 | Stop_Monitor_Nodes_Rsp = 0x400005,
17 |
18 | Read_Nodes_Values_Req = 0x400006,
19 | Read_Nodes_Values_Rsp = 0x400007,
20 |
21 | Write_Nodes_Values_Req = 0x400008,
22 | Write_Nodes_Values_Rsp = 0x400009,
23 |
24 | Notify_Nodes_Values_Ex = 0x400999,
25 | }
26 |
27 | public enum MonitorItemType
28 | {
29 | Initial,
30 | Add,
31 | Remove,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/component/Opc/Protocol/WriteNodesValuesReq.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Da
8 | {
9 | internal class WriteNodesValuesReq
10 | {
11 | public string ServiceId { get; set; }
12 |
13 | public string GroupId { get; set; }
14 |
15 | public string StrMd5 { get; set; }
16 |
17 | public Dictionary ItemValuePairs { get; set; }
18 |
19 | public WriteNodesValuesReq(string serviceProgId, Dictionary items, string groupId, string strmd5)
20 | {
21 | ServiceId = serviceProgId;
22 | GroupId = groupId;
23 | StrMd5 = strmd5;
24 | ItemValuePairs = items;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/component/Sqlserver/SqlServerHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Configuration;
6 |
7 | namespace Dgiot_dtu
8 | {
9 | public class SqlServerHelper
10 | {
11 | private SqlServerHelper()
12 | {
13 | }
14 |
15 | private static SqlServerHelper instance;
16 |
17 | public static SqlServerHelper GetInstance()
18 | {
19 | if (instance == null)
20 | {
21 | instance = new SqlServerHelper();
22 | }
23 |
24 | return instance;
25 | }
26 |
27 | public static void Start(KeyValueConfigurationCollection config)
28 | {
29 | Config(config);
30 | }
31 |
32 | public static void Stop()
33 | {
34 | }
35 |
36 | public static void Config(KeyValueConfigurationCollection config)
37 | {
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/component/Opc/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Dgiot_dtu.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/component/Opc/IOPCDa.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Windows.Forms;
8 | using TitaniumAS.Opc.Client.Da;
9 |
10 | namespace Da
11 | {
12 | public interface IOPCDa
13 | {
14 | List ScanOPCDa(string host, bool isClean = true);
15 |
16 | string StartMonitoringItems(string host, string serviceProgId, TreeNode groupNode, int interval, int count);
17 |
18 | void SetItemsValueChangedCallBack(IItemsValueChangedCallBack callBack);
19 |
20 | void StopMonitoringItems(string groupKey);
21 |
22 | List
- ReadItemsValues(string host, string serviceProgId, string groupKey);
23 |
24 | void WriteValues(string host, string serviceProgId, string groupKey, Dictionary itemValuePairs);
25 | }
26 |
27 | public interface IItemsValueChangedCallBack
28 | {
29 | void ValueChangedCallBack(OpcDaGroup opcGroup, OpcDaItemValue[] values);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/component/BACnet/BacDevice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System.Collections.Generic;
8 | using System.IO.BACnet;
9 |
10 | public class BacDevice
11 | {
12 | #region Address
13 |
14 | public BacnetAddress Address { get; set; }
15 |
16 | #endregion
17 |
18 | #region DeviceId
19 |
20 | public uint DeviceId { get; set; }
21 |
22 | public List Properties { get; set; }
23 |
24 | #endregion
25 |
26 | public BacDevice(BacnetAddress adr, uint deviceId)
27 | {
28 | this.Address = adr;
29 | this.DeviceId = deviceId;
30 | }
31 |
32 | public BacnetAddress GetAddr(uint deviceId)
33 | {
34 | if (this.DeviceId == deviceId)
35 | {
36 | return Address;
37 | }
38 | else
39 | {
40 | return null;
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | name: sync
2 |
3 | on:
4 | push:
5 | branches: [t]
6 | # schedule:
7 | # - cron: '0 21 * * *'
8 | workflow_dispatch:
9 |
10 | jobs:
11 | sync:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Sync to Gitee page
15 | uses: wearerequired/git-mirror-action@master
16 | env:
17 | # 在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
18 | SSH_PRIVATE_KEY: ${{ secrets.GITEE_PRIVATE_KEY }}
19 | with:
20 | # GitHub 源仓库地址
21 | source-repo: git@github.com:dgiot/dgiot_dtu.git
22 | # Gitee 目标仓库地址
23 | destination-repo: git@gitee.com:dgiot_dtu/dgiot_dtu.git
24 |
25 | # 绕过手机验证码:https://github.com/yanglbme/gitee-pages-action/issues/6#issuecomment-664812675
26 | - name: Build Gitee Pages
27 | uses: yanglbme/gitee-pages-action@main
28 | with:
29 | # Gitee 用户名
30 | gitee-username: ${{ secrets.GITEE_USERNAME }}
31 | # Gitee 密码
32 | gitee-password: ${{ secrets.GITEE_PASSWORD }}
33 | # Gitee 仓库
34 | gitee-repo: dgiot-dashboard/dgiot-dashboard
35 | # 要部署的分支
36 | branch: cdn-pages
37 |
38 |
--------------------------------------------------------------------------------
/dgiot_dtu.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31229.75
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dgiot_dtu", "dgiot_dtu.csproj", "{5C46A923-4066-4CE8-89F2-3BAC47BF83ED}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BA722DFE-0FC7-4F15-8372-23B76A694135}"
9 | ProjectSection(SolutionItems) = preProject
10 | .editorconfig = .editorconfig
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|x86 = Debug|x86
16 | Release|x86 = Release|x86
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {5C46A923-4066-4CE8-89F2-3BAC47BF83ED}.Debug|x86.ActiveCfg = Debug|x86
20 | {5C46A923-4066-4CE8-89F2-3BAC47BF83ED}.Debug|x86.Build.0 = Debug|x86
21 | {5C46A923-4066-4CE8-89F2-3BAC47BF83ED}.Release|x86.ActiveCfg = Release|x86
22 | {5C46A923-4066-4CE8-89F2-3BAC47BF83ED}.Release|x86.Build.0 = Release|x86
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {A9147353-3F42-4577-8EA2-2AE2B8715DBA}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/component/Http/HttpClientHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | // https://github.com/titanium-as/TitaniumAS.Opc.Client
6 | // https://github.com/chkr1011/MQTTnet
7 | namespace Dgiot_dtu
8 | {
9 | public class HttpClientHelper
10 | {
11 | private HttpClientHelper()
12 | {
13 | }
14 |
15 | private static HttpClientHelper instance;
16 | private static MainForm mainform = null;
17 | private static bool bIsRunning = false;
18 | private static bool bIsCheck = false;
19 |
20 | public static HttpClientHelper GetInstance()
21 | {
22 | if (instance == null)
23 | {
24 | instance = new HttpClientHelper();
25 | }
26 |
27 | return instance;
28 | }
29 |
30 | public static void Start(bool bIsRunning, MainForm mainform)
31 | {
32 | HttpClientHelper.bIsRunning = bIsRunning;
33 | HttpClientHelper.mainform = mainform;
34 | }
35 |
36 | public static void Stop()
37 | {
38 | HttpClientHelper.bIsRunning = false;
39 | }
40 |
41 | public static void Check(bool isCheck, MainForm mainform)
42 | {
43 | HttpClientHelper.bIsCheck = isCheck;
44 | HttpClientHelper.mainform = mainform;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/utils/ConfigHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Configuration;
6 |
7 | namespace Dgiot_dtu
8 | {
9 | public class ConfigHelper
10 | {
11 | private ConfigHelper()
12 | {
13 | }
14 |
15 | private static ConfigHelper instance;
16 | private static Configuration config;
17 |
18 | public static ConfigHelper GetInstance()
19 | {
20 | if (instance == null)
21 | {
22 | instance = new ConfigHelper();
23 | }
24 |
25 | return instance;
26 | }
27 |
28 | public static void Init(Configuration config)
29 | {
30 | ConfigHelper.config = config;
31 | }
32 |
33 | public static bool Check(string key)
34 | {
35 | return config.AppSettings.Settings[key] != null;
36 | }
37 |
38 | public static void SetConfig(string key, string value)
39 | {
40 | if (config.AppSettings.Settings[key] == null)
41 | {
42 | config.AppSettings.Settings.Add(key, value);
43 | }
44 | else
45 | {
46 | config.AppSettings.Settings[key].Value = value;
47 | }
48 | }
49 |
50 | public static string GetConfig(string key)
51 | {
52 | if (Check(key))
53 | {
54 | return config.AppSettings.Settings[key].Value;
55 | }
56 |
57 | return "";
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Reflection;
6 | using System.Runtime.InteropServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("dgiot_dtu")]
12 | [assembly: AssemblyDescription("dgiot_dtu")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("dgiot Ltd")]
15 | [assembly: AssemblyProduct("dgiot_dtu")]
16 | [assembly: AssemblyCopyright("Copyright © dgiot Ltd 2021")]
17 | [assembly: AssemblyTrademark("")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("790e8dc9-9e65-4d33-8e58-1208a764e66a")]
27 |
28 | // Version information for an assembly consists of the following four values:
29 | //
30 | // Major Version
31 | // Minor Version
32 | // Build Number
33 | // Revision
34 | //
35 | // You can specify all the values or you can default the Build and Revision Numbers
36 | // by using the '*' as shown below:
37 | // [assembly: AssemblyVersion("1.0.*")]
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
40 |
--------------------------------------------------------------------------------
/component/Opc/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # SA1204: Static elements must appear before instance elements
4 | dotnet_diagnostic.SA1204.severity = none
5 |
6 | # SA1201: Elements must appear in the correct order
7 | dotnet_diagnostic.SA1201.severity = silent
8 |
9 | # SA1101: Prefix local calls with this
10 | dotnet_diagnostic.SA1101.severity = silent
11 |
12 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.ReadabilityRules'
13 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.ReadabilityRules.severity = silent
14 |
15 | # SA1202: Elements must be ordered by access
16 | dotnet_diagnostic.SA1202.severity = silent
17 |
18 | # SA1614: Element parameter documentation must have text
19 | dotnet_diagnostic.SA1614.severity = silent
20 |
21 | # SA1403: File may only contain a single namespace
22 | dotnet_diagnostic.SA1403.severity = silent
23 |
24 | # SA1200: Using directives must be placed correctly
25 | dotnet_diagnostic.SA1200.severity = silent
26 |
27 | # SA1625: Element documentation must not be copied and pasted
28 | dotnet_diagnostic.SA1625.severity = silent
29 |
30 | # SA1401: Fields must be private
31 | dotnet_diagnostic.SA1401.severity = silent
32 |
33 | # SA1652: Enable XML documentation output
34 | dotnet_diagnostic.SA1652.severity = silent
35 |
36 | # SA1611: Element parameters must be documented
37 | dotnet_diagnostic.SA1611.severity = silent
38 |
39 | # SA1009: Closing parenthesis must be spaced correctly
40 | dotnet_diagnostic.SA1009.severity = silent
41 |
42 | # SA1214: Readonly fields must appear before non-readonly fields
43 | dotnet_diagnostic.SA1214.severity = none
44 |
45 | # SA1604: Element documentation must have summary
46 | dotnet_diagnostic.SA1604.severity = none
47 |
48 | # CS0252: 可能非有意的引用比较;左侧需要强制转换
49 | dotnet_diagnostic.CS0252.severity = none
50 |
51 | # Default severity for all analyzer diagnostics
52 | dotnet_analyzer_diagnostic.severity = none
53 |
--------------------------------------------------------------------------------
/README-JP.md:
--------------------------------------------------------------------------------
1 | # dgiot_dtu
2 |
3 | [dgiot_dtu](http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/dgiot4.0/dgiot_dtu.zip) は、dgiot産業用IoT全体ソリューションのエッジ側にあるデスクトップユーティリティです。
4 | +複数のdgiot_dtumqtt / tcp / udp階層メソッドを介して企業イントラネットにデプロイでき、企業イントラネットとクラウドサーバー間の通信チャネルを開きます
5 | +企業イントラネットのシリアルポート/ PLC / OPC / BACNet / UI / Access / SqlServerなどの古い産業用システムからのデータをクラウドdgiotサービスに統合します
6 | + OPC / OPC / BACNet / UI / Access / SqlServerなどの自動スキャンツールを実現し、リモートの構築および運用と保守サービスを実現します
7 | +クラウドdgiotサーバーのチャネルと協力して、自動データ収集、プロトコル分析、データストレージ、および表示機能を実現します
8 |
9 | # インタラクティブプロセス
10 |
11 | 
12 |
13 | # インターフェースプレビュー
14 |
15 | 
16 |
17 | # 動作環境
18 | dgiot_dtuは、[.net4.5](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/dotNetFx45.rar)の動作環境に依存します。
19 | window7以下の環境に.net4.5をインストールする必要があります
20 |
21 | # コンパイラ環境
22 | dgiot_dtuは、[vc2019](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/visualstudio2019.zip)を使用してコンパイルおよびデバッグします。
23 |
24 |
25 | # テスト環境
26 |
27 | ## OPCシミュレーションテスト
28 | + [opcserver](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulation.zip)
29 |
30 | + [opcclient](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulationV_1.5.zip)
31 |
32 | ##シリアルポートシミュレーションテスト
33 |
34 | + [仮想メーター](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/%E8%99%9A%E6%8B%9F%E7%94%B5%E8%A1%A8%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
35 | + [仮想modbus](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/Modbus%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5/modbus%20slave%E9%85%8D%E7%BD%AE)
36 |
37 | ## Bacnetシミュレーションテスト
38 |
39 | ## PLCシミュレーションテスト
40 |
41 | ##制御シミュレーションテスト
42 |
43 | ##模擬テストにアクセスする
44 |
45 | ## SqlSeverシミュレーションテスト
46 |
47 | ## mqttブリッジテスト
48 |
49 | ## tcpブリッジテスト
50 |
51 | ## udpブリッジテスト
52 |
--------------------------------------------------------------------------------
/utils/TimerHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Threading;
8 |
9 | namespace Dgiot_dtu
10 | {
11 | public class TimerHelper
12 | {
13 | private TimerHelper()
14 | {
15 | }
16 |
17 | private static TimerHelper instance;
18 | private static Dictionary timers = new Dictionary { };
19 |
20 | public static TimerHelper GetInstance()
21 | {
22 | if (instance == null)
23 | {
24 | instance = new TimerHelper();
25 | }
26 |
27 | return instance;
28 | }
29 |
30 | public static void Start(string key, object state = null, int period = 1000, int dueTime = Timeout.Infinite )
31 | {
32 | if (timers.ContainsKey(key))
33 | {
34 | try
35 | {
36 | timers[key].Change(0, 1000);
37 | }
38 | catch
39 | {
40 | }
41 | }
42 |
43 | TimerCallback callback = new TimerCallback(ReadValue);
44 |
45 | Timer timer = new Timer(callback, state, dueTime, period);
46 | timer.InitializeLifetimeService();
47 | timers.Add(key, timer);
48 | }
49 |
50 | public static void Stop(string key)
51 | {
52 | if (timers.ContainsKey(key))
53 | {
54 | try
55 | {
56 | timers[key].Change(0, 1000);
57 | }
58 | catch
59 | {
60 | }
61 | }
62 | }
63 |
64 | public static void ReadValue(object state)
65 | {
66 | LogHelper.Log("GetState " + state.ToString());
67 | GC.Collect();
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # dgiot_dtu
2 |
3 | [dgiot_dtu](http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/dgiot4.0/dgiot_dtu.zip) is a desktop utility on the edge side of the dgiot industrial IoT overall solution
4 | + Can be deployed on the corporate intranet, through multiple dgiot_dtu mqtt/tcp/udp hierarchical methods, open up the communication channel between the corporate intranet and the cloud server
5 | + Converge data from old industrial systems such as serial port/PLC/OPC/BACNet/UI/Access/SqlServer in the corporate intranet into the cloud dgiot service
6 | + Realize automatic scanning tools for OPC/OPC/BACNet/UI/Access/SqlServer, etc. to realize remote construction and operation and maintenance services
7 | + Cooperate with the channel in the cloud dgiot server to realize automatic data collection, protocol analysis, data storage and display functions
8 |
9 | # Interactive process
10 |
11 | 
12 |
13 | # Interface preview
14 |
15 | 
16 |
17 | # Operating environment
18 | dgiot_dtu depends on [.net4.5](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/dotnetfx45.zip) operating environment,
19 | Need to install .net4.5 in the environment of window7 and below
20 |
21 | # Compiler Environment
22 | dgiot_dtu compile and debug with [vc2019](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/visualstudio2019.zip)
23 |
24 |
25 | # test environment
26 |
27 | ## OPC simulation test
28 | + [opcserver](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulation.zip)
29 |
30 | + [opcclient](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulationV_1.5.zip)
31 |
32 | ## Serial port simulation test
33 |
34 | + [Virtual Meter](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/%E8%99%9A%E6%8B%9F%E7%94%B5%E8%A1%A8%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
35 | + [Virtual modbus](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/Modbus%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5/modbus%20slave%E9%85%8D%E7%BD%AE)
36 |
37 | ## Bacnet simulation test
38 |
39 | ## PLC simulation test
40 |
41 | ## Control simulation test
42 |
43 | ## Access mock test
44 |
45 | ## SqlSever simulation test
46 |
47 | ## mqtt bridge test
48 |
49 | ## tcp bridge test
50 |
51 | ## udp bridge test
52 |
--------------------------------------------------------------------------------
/README-RU.md:
--------------------------------------------------------------------------------
1 | # dgiot_dtu
2 |
3 | [dgiot_dtu](http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/dgiot4.0/dgiot_dtu.zip) - это настольная утилита на периферии общего решения dgiot Industrial IoT.
4 | + Может быть развернут в корпоративной интрасети с помощью нескольких иерархических методов dgiot_dtu mqtt / tcp / udp, открывая канал связи между корпоративной интрасетью и облачным сервером
5 | + Преобразование данных из старых промышленных систем, таких как последовательный порт / PLC / OPC / BACNet / UI / Access / SqlServer в корпоративной интрасети, в облачную службу dgiot
6 | + Реализовать инструменты автоматического сканирования для OPC / OPC / BACNet / UI / Access / SqlServer и т. Д. Для реализации удаленного строительства, эксплуатации и обслуживания
7 | + Сотрудничать с каналом в облачном сервере dgiot для реализации автоматического сбора данных, анализа протокола, хранения данных и функций отображения
8 |
9 | # Интерактивный процесс
10 |
11 | 
12 |
13 | # Предварительный просмотр интерфейса
14 |
15 | 
16 |
17 | # Рабочая среда
18 | dgiot_dtu зависит от операционной среды [.net4.5](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/dotNetFx45.rar),
19 | Необходимо установить .net4.5 в среде window7 и ниже
20 |
21 | # Среда компилятора
22 | dgiot_dtu компилируется и отлаживается с помощью [vc2019] (https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/visualstudio2019.zip)
23 |
24 |
25 | # тестовая среда
26 |
27 | ## Тест моделирования OPC
28 | + [opcserver](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulation.zip)
29 |
30 | + [opcclient](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulationV_1.5.zip)
31 |
32 | ## Тест имитации последовательного порта
33 |
34 | + [Виртуальный счетчик](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/%E8%99%9A%E6%8B%9F%E7%94%B5%E8%A1%A8%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
35 | + [Виртуальный Modbus](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/Modbus%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5/modbus%20slave%E9%85%8D%E7%BD%AE)
36 |
37 | ## Тест имитации бакнета
38 |
39 | ## Тест моделирования ПЛК
40 |
41 | ## Тест имитации управления
42 |
43 | ## Пробный тест доступа
44 |
45 | ## Тест моделирования SqlSever
46 |
47 | ## Тест моста mqtt
48 |
49 | ## тест моста tcp
50 |
51 | ## тест моста udp
52 |
--------------------------------------------------------------------------------
/syscfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/README-CN.md:
--------------------------------------------------------------------------------
1 | # dgiot_dtu
2 |
3 | [dgiot_dtu.exe](https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_dtu.exe) 是dgiot工业物联网整体解决方案中边缘侧的桌面实用工具
4 | + 可以部署在企业内网,通过多个dgiot_dtu的mqtt/tcp/udp等级联的方式,打通企业内网与云端服务器的通讯通道
5 | + 将企业内网中的串口/PLC/OPC/BACNet/UI/Access/SqlServer等老的工业系统中的数据汇聚到云端dgiot服务中
6 | + 对OPC/OPC/BACNet/UI/Access/SqlServer等实现自动扫描工具,实现远程施工与运维服务
7 | + 与云端dgiot服务器中的通道配合实现数据自动采集、协议解析,数据存储和展示功能
8 |
9 | # 交互流程
10 |
11 | 
12 |
13 | # 界面预览
14 |
15 | 
16 |
17 | # 运行环境
18 | dgiot_dtu 依赖[.net4.5](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/dotNetFx45.rar)运行环境,
19 | 在window7及以下环境下需要安装.net4.5
20 |
21 | # 编译环境
22 | dgiot_dtu 用[vc2019](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/visualstudio2019.zip)编译调试
23 |
24 | # 数据映射
25 |
26 | | TreeNode | TAG | Text | Name | Level | Index | FullPath | Action |
27 | | -------- | ------ | ---- |----- | ----- | ----- | -------- | -------- |
28 | | OPCDA | Proctol | ItemId | Name | Type | {Id} | Path | API |
29 |
30 |
31 | ## 设备树Level映射到设备Type
32 | | TreeNode | Level0 | Level1 | Level2 | Level3 | Level4 | Level5 | Level6 |
33 | | -------- | ------- | ------- | ------- | ------- | ------- | ------ | ------- |
34 | | OPCDA | OPCDA | HOST | Service | Device | Group |Item | Property|
35 |
36 |
37 | # 测试环境
38 |
39 | ## OPC模拟测试
40 | + [opcserver](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulation.zip)
41 |
42 | + [opcclient](https://dgiot-dev-1306147891.cos.ap-nanjing.myqcloud.com/dgiot_dtu/MatrikonOPCSimulationV_1.5.zip)
43 |
44 | [OPC设备通过dgiot_dtu接入dgiot物联网平台实战教程](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/OPC%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
45 |
46 | ## 串口模拟测试
47 |
48 | + [虚拟电表](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/%E8%99%9A%E6%8B%9F%E7%94%B5%E8%A1%A8%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
49 | + [虚拟modbus](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/Modbus%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5/modbus%20slave%E9%85%8D%E7%BD%AE)
50 |
51 | [DLT645虚拟电表通过dgiot_dtu接入dgiot物联网平台实战教程](https://gitee.com/dgiiot/dgiot/wikis/%E5%BF%AB%E9%80%9F%E6%8E%A5%E5%85%A5/%E8%99%9A%E6%8B%9F%E7%94%B5%E8%A1%A8%E6%8E%A5%E5%85%A5/%E6%A6%82%E8%BF%B0)
52 |
53 | ## Bacnet模拟测试
54 |
55 | ## PLC模拟测试
56 |
57 | ## Control模拟测试
58 |
59 | ## Access模拟测试
60 |
61 | ## SqlSever模拟测试
62 |
63 | ## mqtt桥接测试
64 |
65 | ## tcp桥接测试
66 |
67 | ## udp桥接测试
68 |
69 |
--------------------------------------------------------------------------------
/component/Opc/OPCUAHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Configuration;
9 | using System.IO;
10 | using System.Net;
11 | using System.Threading.Tasks;
12 | using Workstation.ServiceModel.Ua;
13 | using Workstation.ServiceModel.Ua.Channels;
14 |
15 | public class OPCUAHelper
16 | {
17 | private OPCUAHelper()
18 | {
19 | }
20 |
21 | private const string EndpointUrl = "opc.tcp://localhost:26543"; // the endpoint of the Workstation.NodeServer.
22 | private static ApplicationDescription localDescription;
23 | private static ICertificateStore certificateStore;
24 | private static OPCUAHelper instance;
25 | private static UaTcpSessionChannel channel;
26 |
27 | public static OPCUAHelper GetInstance()
28 | {
29 | if (instance == null)
30 | {
31 | instance = new OPCUAHelper();
32 | }
33 |
34 | return instance;
35 | }
36 |
37 | public static void Start(KeyValueConfigurationCollection config)
38 | {
39 | Config(config);
40 | localDescription = new ApplicationDescription
41 | {
42 | ApplicationName = "Workstation.UaClient.UnitTests",
43 | ApplicationUri = $"urn:{Dns.GetHostName()}:Workstation.UaClient.UnitTests",
44 | ApplicationType = ApplicationType.Client
45 | };
46 |
47 | certificateStore = new DirectoryStore(
48 | Path.Combine(
49 | Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
50 | "Workstation.UaClient.UnitTests",
51 | "pki"));
52 |
53 | Task.Run(async () => { await ConnectAsync(); });
54 | }
55 |
56 | public static void Stop()
57 | {
58 | if (channel != null)
59 | {
60 | Task.Run(async () => { await CloseAsync(); });
61 | }
62 | }
63 |
64 | public static void Config(KeyValueConfigurationCollection config)
65 | {
66 | }
67 |
68 | private static async Task ConnectAsync()
69 | {
70 | channel = new UaTcpSessionChannel(
71 | localDescription,
72 | certificateStore,
73 | null,
74 | EndpointUrl);
75 |
76 | await channel.OpenAsync();
77 | }
78 |
79 | private static async Task CloseAsync()
80 | {
81 | await channel.CloseAsync();
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/component/Opc/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
58 |
59 |
60 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/utils/FileHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System.Collections.Generic;
8 | using System.Configuration;
9 | using System.IO;
10 | using System.Windows.Forms;
11 |
12 | public class FileHelper
13 | {
14 | private FileHelper()
15 | {
16 | }
17 |
18 | private static FileHelper instance = null;
19 | private static OpenFileDialog openFileDialog = null;
20 |
21 | public static FileHelper GetInstance()
22 | {
23 | if (instance == null)
24 | {
25 | instance = new FileHelper();
26 | }
27 |
28 | return instance;
29 | }
30 |
31 | public static void Init(OpenFileDialog openFileDialog)
32 | {
33 | FileHelper.openFileDialog = openFileDialog;
34 | }
35 |
36 | public static void Config(KeyValueConfigurationCollection config)
37 | {
38 | }
39 |
40 | public static List OpenFile()
41 | {
42 | List files = new List();
43 | if (openFileDialog.ShowDialog() == DialogResult.OK)
44 | {
45 | string filename = openFileDialog.FileName;
46 | StreamReader sr = new StreamReader(filename);
47 | LogHelper.Log("filename " + filename);
48 | while (!sr.EndOfStream)
49 | {
50 | string line = sr.ReadLine();
51 | files.Add(line);
52 | LogHelper.Log("line " + line);
53 | }
54 |
55 | sr.Close();
56 | }
57 |
58 | return files;
59 | }
60 |
61 | ///
62 | /// 替换值
63 | ///
64 | /// txt等文件的路径
65 | /// 索引的字符串,定位到某一行
66 | /// 替换新值
67 | public static void ReplaceValue(string strFilePath, string strIndex, string newValue)
68 | {
69 | if (File.Exists(strFilePath))
70 | {
71 | string[] lines = System.IO.File.ReadAllLines(strFilePath);
72 | for (int i = 0; i < lines.Length; i++)
73 | {
74 | if (lines[i].Contains(strIndex))
75 | {
76 | string[] str = lines[i].Split('=');
77 | str[1] = newValue;
78 | lines[i] = str[0] + " = " + str[1];
79 | }
80 | }
81 | File.WriteAllLines(strFilePath, lines);
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/component/Udp/UDPClientHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Configuration;
9 | using System.Threading;
10 | using LiteNetLib;
11 |
12 | public class UDPClientHelper
13 | {
14 | private const bool V = false;
15 | private static UDPClientHelper instance;
16 | private static NetManager client = null;
17 | private static string server = "prod.iotn2n.com";
18 | private static int port = 9050;
19 | private static bool bIsCheck = false;
20 | private static bool bAutoReconnect = false;
21 |
22 | public static UDPClientHelper GetInstance()
23 | {
24 | if (instance == null)
25 | {
26 | instance = new UDPClientHelper();
27 | }
28 |
29 | return instance;
30 | }
31 |
32 | public static void Start()
33 | {
34 | Config();
35 |
36 | if (bIsCheck)
37 | {
38 | if (client == null)
39 | {
40 | EventBasedNetListener listener = new EventBasedNetListener();
41 | client = new NetManager(listener);
42 | client.Start();
43 | client.Connect(server /* host ip or name */, port /* port */, "SomeConnectionKey" /* text key or NetDataWriter */);
44 | listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) =>
45 | {
46 | Console.WriteLine("We got: {0}", dataReader.GetString(100 /* max length of string */));
47 | dataReader.Recycle();
48 | };
49 | }
50 |
51 | while (!Console.KeyAvailable)
52 | {
53 | client.PollEvents();
54 | Thread.Sleep(15);
55 | }
56 | }
57 | }
58 |
59 | public static void Stop()
60 | {
61 | if (client != null)
62 | {
63 | if (client.IsRunning)
64 | {
65 | client.Stop();
66 | }
67 | }
68 | }
69 |
70 | public static void Config()
71 | {
72 | server = ConfigHelper.GetConfig("DgiotSever");
73 | port = int.Parse(ConfigHelper.GetConfig("DgiotPort"));
74 | bIsCheck = DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClientIsCheck"));
75 | bAutoReconnect = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked"));
76 | }
77 |
78 | public static void Write(byte[] data, int offset, int len)
79 | {
80 | if (bIsCheck)
81 | {
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace dgiot_dtu.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dgiot_dtu.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性,对
51 | /// 使用此强类型资源类的所有资源查找执行重写。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Bitmap bridge {
67 | get {
68 | object obj = ResourceManager.GetObject("bridge", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/utils/IPScanHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Diagnostics;
10 | using System.IO;
11 | using System.Management;
12 | using System.Net;
13 | using System.Net.NetworkInformation;
14 | using System.Net.Sockets;
15 | using System.Runtime.InteropServices;
16 | using System.Security.Cryptography;
17 | using System.Text;
18 | using System.Threading;
19 |
20 | public class IPScanHelper
21 | {
22 | private static IPScanHelper instance = null;
23 | private IPScanHelper()
24 | {
25 | }
26 | public static IPScanHelper GetInstance()
27 | {
28 | if (instance == null)
29 | {
30 | instance = new IPScanHelper();
31 | }
32 |
33 | return instance;
34 | }
35 |
36 | public static void IPScan()
37 | {
38 | var host = Dns.GetHostEntry(Dns.GetHostName());
39 | List localIps = new List();
40 | foreach (var ip in host.AddressList)
41 | {
42 | if (ip.AddressFamily == AddressFamily.InterNetwork)
43 | {
44 | using (Ping p = new Ping())
45 | {
46 | PingReply pingReply = p.Send(ip, 100);
47 | if (pingReply.Status == IPStatus.Success)
48 | {
49 | PingIP(ip);
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
56 |
57 | private static void PingIP(IPAddress ipa)
58 | {
59 | byte[] ipByte = ipa.GetAddressBytes();
60 | string ipComm = ipByte[0] + "." + ipByte[1] + "." + ipByte[2] + ".";
61 | string pingIP = "";
62 |
63 | for (int lastByte = 0; lastByte <= 255; lastByte++)
64 | {
65 | Ping ping = new Ping();
66 | ping.PingCompleted += new PingCompletedEventHandler(PingComplete);
67 | pingIP = ipComm + lastByte;
68 | ping.SendAsync(pingIP, 2000, null);
69 | }
70 | }
71 |
72 | [DllImport(@"iphlpapi.dll", ExactSpelling = true)]
73 | private static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);
74 | private static void PingComplete(object sender, PingCompletedEventArgs e)
75 | {
76 | if (e.Reply.Status == IPStatus.Success)
77 | {
78 | IPAddress ip = e.Reply.Address;
79 | // this.listBox.Items.Add("IP:" + ip.ToString());
80 | byte[] b = new byte[6];
81 | int len = b.Length;
82 | int r = SendARP(BitConverter.ToInt32(ip.GetAddressBytes(), 0), 0, b, ref len);
83 | string mac = BitConverter.ToString(b, 0, 6);
84 | // this.listBox.Items.Add("Mac:" + mac);
85 | LogHelper.Log(mac + " " + ip.ToString());
86 | }
87 | }
88 |
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/utils/LogHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System.Collections.Generic;
6 | using System.Configuration;
7 |
8 | namespace Dgiot_dtu
9 | {
10 | public class LogHelper
11 | {
12 | private LogHelper()
13 | {
14 | }
15 |
16 | public enum Level
17 | {
18 | DEBUG,
19 | INFO,
20 | NOTICE,
21 | WARN,
22 | ERROR,
23 | CRITICAL,
24 | ALERT,
25 | }
26 |
27 | private static List levelstring = new List
28 | {
29 | "DEBUG",
30 | "INFO",
31 | "NOTICE",
32 | "WARN",
33 | "ERROR",
34 | "CRITICAL",
35 | "ALERT"
36 | };
37 |
38 | private static bool bDisplayHex = false;
39 | private static int loglevel = (int)Level.DEBUG;
40 | private static LogHelper instance;
41 | private static string login = string.Empty;
42 | private static MainForm mainform = null;
43 |
44 | public static LogHelper GetInstance()
45 | {
46 | if (instance == null)
47 | {
48 | instance = new LogHelper();
49 | }
50 |
51 | return instance;
52 | }
53 |
54 | public static void Init(MainForm mainform, int level = 0)
55 | {
56 | LogHelper.mainform = mainform;
57 | loglevel = level;
58 | }
59 |
60 | public static List Levels()
61 | {
62 | return levelstring;
63 | }
64 |
65 | public static void SetLevel(int level = 0)
66 | {
67 | loglevel = level;
68 | }
69 |
70 | public static void Log(string text, int level = 0)
71 | {
72 | if (level >= loglevel)
73 | {
74 | mainform.Log(text);
75 | }
76 | }
77 |
78 | public static void Config()
79 | {
80 | bDisplayHex = DgiotHelper.StrTobool(ConfigHelper.GetConfig("DisplayHex"));
81 | }
82 |
83 | public static string Logdata(byte[] data, int offset, int len)
84 | {
85 | var line = bDisplayHex ? DgiotHelper.ToHexString(data, offset, len) : System.Text.Encoding.ASCII.GetString(data, offset, len);
86 | if (line.EndsWith("\r\n"))
87 | {
88 | line = line.Substring(0, line.Length - 2);
89 | }
90 |
91 | return line;
92 | }
93 |
94 | public static byte[] Payload(char[] data)
95 | {
96 | byte[] payload = System.Text.Encoding.UTF8.GetBytes(data);
97 | if (bDisplayHex)
98 | {
99 | byte[] hexPayload = DgiotHelper.ToHexBinary(payload);
100 | return hexPayload;
101 | }
102 | else
103 | {
104 | return payload;
105 | }
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/component/Opc/log4net.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/component/Printer/PrinterHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Configuration;
9 | using LitJson;
10 | using Spire.License;
11 | using Spire.Pdf;
12 | using dgiot_dtu.component.Printer;
13 | using System.Drawing.Printing;
14 | using static System.Drawing.Printing.PrinterSettings;
15 | using System.Text;
16 |
17 | internal partial class PrinterHelper
18 | {
19 | private static PrinterHelper instance = null;
20 | private static bool bIsRunning = false;
21 | private static PdfPrinter pdfPriner = null;
22 | private static BarCodePrinter barCodePriner = null;
23 | private static JsonData json = new JsonData();
24 | private static string productId = string.Empty;
25 | private static string devAddr = string.Empty;
26 |
27 | public static PrinterHelper GetInstance()
28 | {
29 | if (instance == null)
30 | {
31 | instance = new PrinterHelper();
32 | pdfPriner = new PdfPrinter();
33 | }
34 | return instance;
35 | }
36 |
37 | public static void Start(KeyValueConfigurationCollection config, bool bIsRunning)
38 | {
39 | Config(config);
40 | PrinterHelper.bIsRunning = bIsRunning;
41 | }
42 |
43 | public static void Stop()
44 | {
45 | PrinterHelper.bIsRunning = false;
46 | }
47 |
48 | public static void Config(KeyValueConfigurationCollection config)
49 | {
50 | }
51 |
52 | public static JsonData GetJson()
53 | {
54 | return json;
55 | }
56 |
57 | private static void SetJson(JsonData jsonData)
58 | {
59 | json.Clear();
60 | json = jsonData;
61 | }
62 |
63 | public static void PrintBarCode(JsonData jsonData)
64 | {
65 | SetJson(jsonData);
66 | barCodePriner = new BarCodePrinter();
67 | barCodePriner.doPrint();
68 | }
69 |
70 | public static void PrintPdf(JsonData jsonData)
71 | {
72 | SetJson(jsonData);
73 | pdfPriner.Print();
74 | GetPrinter();
75 | }
76 |
77 | public static void GetPrinter()
78 | {
79 | productId = ConfigHelper.GetConfig("MqttUserName");
80 | devAddr = ConfigHelper.GetConfig("DtuAddr");
81 | //sDefault = sys.print_machine;//获取设置的默认打印机
82 | JsonObject Printers = new JsonObject();
83 |
84 | foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
85 | {
86 | // LogHelper.Log("Printers: " + sPrint);
87 | Printers.Add(sPrint, sPrint);
88 | }
89 | StringCollection Printer = PrinterSettings.InstalledPrinters;
90 |
91 | string topic = "$dg/thing/" + productId + "/" + devAddr + "/firmware/report";
92 | MqttClientHelper.Publish(topic, Encoding.UTF8.GetBytes(Printers.ToString()));
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/component/Udp/UDPServerHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | namespace Dgiot_dtu
6 | {
7 | using System;
8 | using System.Configuration;
9 | using System.Threading;
10 |
11 | using LiteNetLib;
12 | using LiteNetLib.Utils;
13 |
14 | public class UDPServerHelper
15 | {
16 | private static UDPServerHelper instance;
17 | private static NetManager server = null;
18 | private static int port;
19 | private static bool bIsCheck = false;
20 |
21 | public static UDPServerHelper Instance
22 | {
23 | get
24 | {
25 | if (instance == null)
26 | {
27 | instance = new UDPServerHelper();
28 | }
29 |
30 | return instance;
31 | }
32 | }
33 |
34 | public static void Start()
35 | {
36 | Config();
37 | if (bIsCheck)
38 | {
39 | if (server == null)
40 | {
41 | EventBasedNetListener listener = new EventBasedNetListener();
42 | server = new NetManager(listener);
43 | server.Start(port /* port */);
44 | listener.ConnectionRequestEvent += request =>
45 | {
46 | if (server.ConnectedPeersCount < 10 /* max connections */)
47 | {
48 | request.AcceptIfKey("SomeConnectionKey");
49 | }
50 | else
51 | {
52 | request.Reject();
53 | }
54 | };
55 |
56 | listener.PeerConnectedEvent += peer =>
57 | {
58 | Console.WriteLine("We got connection: {0}", peer.EndPoint); // Show peer ip
59 | NetDataWriter writer = new NetDataWriter(); // Create writer class
60 | writer.Put("Hello client!"); // Put some string
61 | peer.Send(writer, DeliveryMethod.ReliableOrdered); // Send with reliability
62 | };
63 | }
64 |
65 | while (!Console.KeyAvailable)
66 | {
67 | server.PollEvents();
68 | Thread.Sleep(15);
69 | }
70 | }
71 | }
72 |
73 | public static void Stop()
74 | {
75 | if (server != null)
76 | {
77 | if (server.IsRunning)
78 | {
79 | server.Stop();
80 | }
81 | }
82 | }
83 |
84 | public static void Config()
85 | {
86 | port = int.Parse(ConfigHelper.GetConfig("DgiotPort"));
87 | if (DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClient_Checked")) && DgiotHelper.StrTobool(ConfigHelper.GetConfig("Bridge_Checked")))
88 | {
89 | bIsCheck = true;
90 | }
91 | else
92 | {
93 | bIsCheck = false;
94 | }
95 | }
96 |
97 | public static void Write(byte[] data, int offset, int len)
98 | {
99 | if (bIsCheck)
100 | {
101 | }
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/component/Printer/Knova.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) PlaceholderCompany. All rights reserved.
3 | //
4 |
5 | using System;
6 |
7 | namespace Dgiot_dtu
8 | {
9 | public class Knova
10 | {
11 | public string type { get; set; }
12 | public string text { get; set; }
13 | public string fontFamily { get; set; }
14 | public int fontSize { get; set; }
15 | public int x { get; set; }
16 | public int y { get; set; }
17 | public int width { get; set; }
18 | public int height { get; set; }
19 |
20 | //像素转为100之一英寸
21 | public static int pxToInch(int px)
22 | {
23 | return (int)(px * 100 / 96);
24 | }
25 |
26 | //英寸换算到厘米
27 | public decimal FromInchToCM(decimal inch)
28 | {
29 | return Math.Round((System.Convert.ToDecimal((inch / 100)) * System.Convert.ToDecimal(2.5400)), 2); //Math.Round取两位小数
30 | }
31 |
32 | // 毫米转换成百分之一英寸
33 | public static int GetInch(float mm)
34 | {
35 | return (int)(mm * 0.0393700787402 * 100);
36 | }
37 | }
38 |
39 | //pt 磅或者点数,是point简称 1磅=0.03527厘米=1/72英寸
40 | //inch英寸, 1英寸=2.54厘米=96像素(分辨率为96dpi)
41 | //px 像素, pixel的简称(本表参照显示器96dbi显示进行换算,像素不能出现小数点,一般是取小显示
42 | //---------------------------------------------------
43 | //|中文字号 | 英文字号(磅)| 毫米 | 像素 |
44 | //---------------------------------------------------
45 | //| 1英寸 | 72pt | 25.30mm | 95.6px |
46 | //---------------------------------------------------
47 | //| 大特号 | 63pt | 22.14mm | 83.7px |
48 | //---------------------------------------------------
49 | //| 特号 | 54pt | 18.97mm | 71.7px |
50 | //---------------------------------------------------
51 | //| 初号 | 42pt | 14.82mm | 56px |
52 | //---------------------------------------------------
53 | //| 小初 | 36pt | 12.70mm | 48px |
54 | //---------------------------------------------------
55 | //| 一号 | 26pt | 9.17mm | 34.7px |
56 | //---------------------------------------------------
57 | //| 小一 | 24pt | 8.47mm | 32px |
58 | //---------------------------------------------------
59 | //| 二号 | 22pt | 7.76mm | 29.3px |
60 | //---------------------------------------------------
61 | //| 小二 | 18pt | 6.35mm | 24px |
62 | //---------------------------------------------------
63 | //| 三号 | 16pt | 5.64mm | 21.3px |
64 | //---------------------------------------------------
65 | //| 小三 | 15pt | 5.29mm | 20px |
66 | //---------------------------------------------------
67 | //| 四号 | 14pt | 4.94mm | 18.7px |
68 | //---------------------------------------------------
69 | //| 小四 | 12pt | 4.23mm | 16px |
70 | //---------------------------------------------------
71 | //| 五号 | 10.5pt | 3.70mm | 14px |
72 | //---------------------------------------------------
73 | //| 小五 | 9pt | 3.18mm | 12px |
74 | //---------------------------------------------------
75 | //| 六号 | 7.5pt | 2.56mm | 10px |
76 | //---------------------------------------------------
77 | //| 小六 | 6.5pt | 2.29mm | 8.7px |
78 | //---------------------------------------------------
79 | //| 七号 | 5.5pt | 1.94mm | 7.3px |
80 | //---------------------------------------------------
81 | //| 八号 | 5pt | 1.76mm | 6.7px |
82 | //---------------------------------------------------
83 |
84 | }
--------------------------------------------------------------------------------
/utils/JsonArray.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) PlaceholderCompany. All rights reserved.
4 | //
5 | // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me)
6 | // https://github.com/facebook-csharp-sdk/simple-json
7 | //-----------------------------------------------------------------------
8 |
9 | // VERSION: 0.38.0
10 |
11 | // NOTE: uncomment the following line to make SimpleJson class internal.
12 | // #define SIMPLE_JSON_INTERNAL
13 |
14 | // NOTE: uncomment the following line to make JsonArray and JsonObject class internal.
15 | // #define SIMPLE_JSON_OBJARRAYINTERNAL
16 |
17 | // NOTE: uncomment the following line to enable dynamic support.
18 | // #define SIMPLE_JSON_DYNAMIC
19 |
20 | // NOTE: uncomment the following line to enable DataContract support.
21 | // #define SIMPLE_JSON_DATACONTRACT
22 |
23 | // NOTE: uncomment the following line to enable IReadOnlyCollection and IReadOnlyList support.
24 | // #define SIMPLE_JSON_READONLY_COLLECTIONS
25 |
26 | // NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke().
27 | // define if you are using .net framework <= 3.0 or < WP7.5
28 | // #define SIMPLE_JSON_NO_LINQ_EXPRESSION
29 |
30 | // NOTE: uncomment the following line if you are compiling under Window Metro style application/library.
31 | // usually already defined in properties
32 | // #define NETFX_CORE;
33 |
34 | // If you are targetting WinStore, WP8 and NET4.5+ PCL make sure to #define SIMPLE_JSON_TYPEINFO;
35 |
36 | // original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
37 | #if NETFX_CORE
38 | #define SIMPLE_JSON_TYPEINFO
39 | #endif
40 |
41 | using System;
42 | using System.CodeDom.Compiler;
43 | using System.Collections;
44 | using System.Collections.Generic;
45 | #if !SIMPLE_JSON_NO_LINQ_EXPRESSION
46 | using System.Linq.Expressions;
47 | #endif
48 | using System.ComponentModel;
49 | using System.Diagnostics.CodeAnalysis;
50 | #if SIMPLE_JSON_DYNAMIC
51 | using System.Dynamic;
52 | #endif
53 | using System.Globalization;
54 | using System.Reflection;
55 | using System.Runtime.Serialization;
56 | using System.Text;
57 | using Dgiot_dtu.Reflection;
58 |
59 | // ReSharper disable LoopCanBeConvertedToQuery
60 | // ReSharper disable RedundantExplicitArrayCreation
61 | // ReSharper disable SuggestUseVarKeywordEvident
62 | namespace Dgiot_dtu
63 | {
64 | ///
65 | /// Represents the json array.
66 | ///
67 | [GeneratedCode("simple-json", "1.0.0")]
68 | [EditorBrowsable(EditorBrowsableState.Never)]
69 | #if SIMPLE_JSON_OBJARRAYINTERNAL
70 | internal
71 | #else
72 | public
73 | #endif
74 | class JsonArray : List