Project Genesis

This commit is contained in:
mharb 2025-06-07 12:49:56 -04:00
commit f4c511f02d
11 changed files with 760 additions and 0 deletions

407
.gitignore vendored Normal file
View File

@ -0,0 +1,407 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Aa][Rr][Mm]64[Ee][Cc]/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.idb
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# AWS SAM Build and Temporary Artifacts folder
.aws-sam
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# csharp-modbus-automation (WIP NOT COMPLETE)
This repository provides configuration files and source code for automating and interfacing with Modbus-compatible hardware devices. The target development environment is Windows 10, utilizing Visual Studio 2022 with C# and .NET Core/.NET 8+. Each hardware model is organized into a dedicated subdirectory within the repository.
## Warning
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
`TL;DR: Not my problem`
## License
The `GPL V2` license applies to this project. All copyrights belong to their respective copyright holders and all trademarks belong to their trademark holders.
```
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.)

8
seaio-463/README.md Normal file
View File

@ -0,0 +1,8 @@
This documentation is a WIP; excuse our dust.
https://www.sealevel.com/seai-o-463e/
https://www.sealevelsoftware.com/documentation/seamax/win/_enumerations.html
https://www.sealevelsoftware.com/documentation/seamax/win/sea_i_o46x_registers.html
https://www.sealevelsoftware.com/documentation/seamax/win/mbbd_seaio_463.html
https://github.com/NModbus/NModbus
https://github.com/NModbus4/NModbus4

BIN
seaio-463/TestBench.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AnalysisLevel>latest</AnalysisLevel>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
<SignAssembly>True</SignAssembly>
<PlatformTarget>x64</PlatformTarget>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<PublishAot>True</PublishAot>
<PublishTrimmed>True</PublishTrimmed>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NModbus4" Version="2.1.0" />
<PackageReference Include="System.IO.Ports" Version="9.0.5" />
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36121.58
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModBusReadRegisters", "ModBusReadRegisters.csproj", "{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF8A7498-5545-4152-901A-4CA0548E03CB}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,61 @@
using Modbus.Device;
using System.Net.Sockets;
namespace ModbusReadRegisters
{
internal class Program
{
private const string IpAddress = "127.0.0.1"; // Replace with your Modbus device IP
private const int Port = 502; // Default Modbus TCP port
private const byte SlaveId = 1; // Modbus slave ID
private const ushort StartAddress = 0; // Starting address to read
private const ushort NumRegisters = 16; // Number of registers to read
private const ushort CoilStartAddress = 0; // Starting address to write coils
private static void Main(string[] args)
{
try
{
using (TcpClient client = new TcpClient(IpAddress, Port))
{
// Build a client, read registers, write to coils
ModbusIpMaster master = ModbusIpMaster.CreateIp(client);
ushort[] registers = ReadHoldingRegisters(master, SlaveId, StartAddress, NumRegisters);
DisplayRegisters(registers, StartAddress);
WriteCoilsBasedOnRegisters(master, registers, CoilStartAddress);
}
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}
}
// Fetch holding register values with modbus TCP
private static ushort[] ReadHoldingRegisters(ModbusIpMaster master, byte slaveId, ushort startAddress, ushort numRegisters)
{
return master.ReadHoldingRegisters(slaveId, startAddress, numRegisters);
}
// Print registers we found and their values
private static void DisplayRegisters(ushort[] registers, ushort startAddress)
{
Console.WriteLine($"Read {registers.Length} registers starting at address {startAddress}:");
for (int i = 0; i < registers.Length; i++)
{
Console.WriteLine($"Register {startAddress + i}: {registers[i]}");
}
}
// If a register is occupied, write 1 to coil
private static void WriteCoilsBasedOnRegisters(ModbusIpMaster master, ushort[] registers, ushort coilStartAddress)
{
for (int i = 0; i < registers.Length; i++)
{
bool coilValue = registers[i] > 0;
master.WriteSingleCoil((ushort)(coilStartAddress + i), coilValue);
Console.WriteLine($"Wrote {(coilValue ? 1 : 0)} to coil address {coilStartAddress + i}");
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AnalysisLevel>latest</AnalysisLevel>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
<SignAssembly>True</SignAssembly>
<PlatformTarget>x64</PlatformTarget>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<PublishAot>True</PublishAot>
<PublishTrimmed>True</PublishTrimmed>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<None Remove="1June2025.zip" />
<None Remove="Program.zip" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NModbus4.NetCore" Version="3.0.0" />
<PackageReference Include="System.IO.Ports" Version="9.0.5" />
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36121.58
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModBusReadRegisters", "ModBusReadRegisters.csproj", "{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF0378B-1F80-4DD4-A9CD-BE480FD44B35}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF8A7498-5545-4152-901A-4CA0548E03CB}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,123 @@
// This program connects to a Sealevel type 463E-OEM I/O processor https://www.sealevel.com/seai-o-463e-oem/
// Note: this program cannot be started until at least five seconds after powering up the I/O processor
// Note: if the program is interrupted and does not terminate normally, a power reset is required on the 463E
using Modbus.Device;
using System.Net.Sockets;
using static System.Console;
namespace ModbusReadRegisters
{
internal class ModbusProgram
{
private const string IPaddress = "10.10.10.110"; // Modbus device IP
private const int Port = 502; // Default Modbus TCP port
private const byte SlaveID = 247; // Modbus slave ID
private const ushort RegisterStartAddress = 0; // Starting address to read
private const ushort NumRegisters = 9; // Number of registers to read
private const ushort CoilStartAddress = 0; // Starting address to write coils
private static void Main(string[] args)
{
WriteLine("ModbusProgram begins here...\n\n");
try
{
using TcpClient client = new(IPaddress, Port);
// Build a client
ModbusIpMaster master = ModbusIpMaster.CreateIp(client);
WriteLine("CreateIp done\n");
// Read register values
ushort[] registers = master.ReadHoldingRegisters(SlaveID, RegisterStartAddress, NumRegisters);
WriteLine("ReadHoldingRegisters done\n");
DisplayRegisters(registers, RegisterStartAddress);
WriteLine("\nDisplayRegisters done\n");
// Set all channels as outputs
master.WriteSingleRegister(SlaveID, 2, 0);
WriteLine("WriteSingleRegister done.");
// Write to specific outputs
WriteIndividualCoils(master, registers, CoilStartAddress);
WriteLine("WriteIndividualCoils done\n");
// Write to groups of eight outputs at a time
WriteAllOutputs(SlaveID, master);
WriteLine("WriteAllOutputs done\n");
ShutDown(SlaveID, master);
}
catch (Exception ex)
{
WriteLine("An error occurred:\n\n" + ex.Message);
}
finally
{
WriteLine("\nModbusProgram ends here.\n");
_ = ReadKey(true);
}
}
// Print registers we found and their values
private static void DisplayRegisters(ushort[] registers, ushort startAddress)
{
WriteLine($"Read {registers.Length} registers starting at address {startAddress}:");
for (int i = 0; i < registers.Length; i++)
{
WriteLine($"Register {startAddress + i}: {registers[i]}");
}
}
// Exercise two racks, eight points at a time
private static void WriteAllOutputs(ushort slaveID, ModbusIpMaster master)
{
bool[] valueArrayON = [true, false, true, false, true, false, true, false];
bool[] valueArrayOFF = [false, true, false, true, false, true, false, true];
WriteLine("Writing to two boards at once:\n");
for (ushort j = 0; j < 4; j++)
{
for (ushort i = 0; i < 6; i++)
{
master.WriteMultipleCoils((byte)slaveID, (ushort)(i * 8), valueArrayON);
}
Thread.Sleep(150);
for (ushort i = 0; i < 6; i++)
{
master.WriteMultipleCoils((byte)slaveID, (ushort)(i * 8), valueArrayOFF);
}
}
}
// Execise individual outputs
private static void WriteIndividualCoils(ModbusIpMaster master, ushort[] registers, ushort coilStartAddress)
{
WriteLine("The value of 'coilStartAddress' is {0}", coilStartAddress);
for (int i = 0; i < registers.Length; i++)
{
WriteLine(registers[i]);
}
DisplayRegisters(registers, RegisterStartAddress);
for (ushort j = 0; j < 4; j++)
{
WriteLine("Turning the outputs ON.");
for (ushort i = 0; i < 48; i++)
{
master.WriteSingleCoil(SlaveID, i, true);
}
for (ushort i = 0; i < 48; i++)
{
master.WriteSingleCoil(SlaveID, i, false);
}
}
WriteLine("\nDone writing individual outputs!\n\n");
}
// Shut off all outputs
private static void ShutDown(ushort slaveID, ModbusIpMaster master)
{
bool[] valueArrayOFF = [false, false, false, false, false, false, false, false];
for (ushort i = 0; i < 6; i++)
{
master.WriteMultipleCoils((byte)slaveID, (ushort)(i * 8), valueArrayOFF);
}
}
}
}