Code Monkey home page Code Monkey logo

softplc's Introduction

SoftPlc Docker Image CI Docker Pulls

Software PLC controlled over Web API

How often did you need a PLC for testing, but you had none?

This project aim to end you pain with test against PLC!

How does it works

Use it from source code

Build and Start the software (don't forget to copy the native library you need)

cd SoftPlc
dotnet restore
dotnet build
cp native\win\snap7.dll bin\x64\Debug\net6.0\snap7.dll
dotnet bin\Debug\netcoreapp2.0\SoftPlc.dll --plcPort=102 --urls="http://localhost:8080/"

Use it with docker

Pull the actual docker image for your platform see available tags and run it with the correct port binding. (Brand new MOBY support is included! Just select latest-win1809 tag.)

docker run -p 8080:80 -p 8443:443 -p 102:102 --name softplc fbarresi/softplc:latest-linux

Now you have:

  • a Simulated PLC listening at port 102 (see ISO-over-TCP protocol)

    • by default, it starts without any data. If you need some preset data you can add -e DATA_PATH=/demodata to start with a single 2048 byte DataBlock. The data content is described here.
  • an API listening at http://localhost:8080/ (with Swagger included under http://localhost:8080/ ) in which you can add, read, modify and delete as many datablocks as you want

SoftPlc API

Do you also need a PLC Client in your application?

Check my other repository Sharp7 or Sharp7Reactive

Contribute

Whould you like to contribute? YES, Please! Just fork/star/watch this repo and submit a pull request!

Credits

This software uses Snap7 as PLC server implementation. For info please visit the official page: http://snap7.sourceforge.net

softplc's People

Contributors

broessl avatar fbarresi avatar peter-b- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

softplc's Issues

use docker run, but http://localhost:8080/ is not work.

docker run -p 8080:80 -p 8443:443 -p 102:102 --name softplc fbarresi/softplc:latest-linux
Initializing plc service...
plc server started on port 102!
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:8080
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app

but use browser to http://localhost:8080/ not work. can't see anything.

Possibility of config changes?

I tried to enumerate the plc through nmap s7-enumerate and I got this output

Starting Nmap 7.60 ( https://nmap.org ) at 2020-05-01 21:15 IST
Nmap scan report for 172.17.0.2
Host is up (0.000092s latency).

PORT STATE SERVICE
102/tcp open iso-tsap
| s7-enumerate:
| Module: 6ES7 315-2EH14-0AB0
| Basic Hardware: 6ES7 315-2EH14-0AB0
| Version: 3.2.6
| System Name: SNAP7-SERVER
| Module Type: CPU 315-2 PN/DP
| Serial Number: S C-C2UR28922012
|_ Copyright: Original Siemens Equipment
MAC Address: 02:42:AC:11:00:02 (Unknown)
Service Info: Device: specialized

Nmap done: 1 IP address (1 host up) scanned in 1.03 seconds

Is there a way to change attributes like serial no , module type , system name and also add plant identification?

Cant run on Macbook M1 Pro

Hello fbarresi,

when i try to run SoftPlc on Macbook Pro M1, i am getting below error. i have already move files from native folder to net6.0 folder.
if you have any suggestion it would be great.

PS /Users/xxxxx/VisualStudioProjects/_Custom/SoftPlc/SoftPlc> dotnet run bin\Debug\net6.0\SoftPlc.dll --plcPort=102 --urls="http://localhost:8080/"
Initializing plc service...
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'snap7' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libsnap7, 0x0001): tried: 'libsnap7' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibsnap7' (no such file), '/usr/lib/libsnap7' (no such file, not in dyld cache), 'libsnap7' (no such file), '/usr/local/lib/libsnap7' (no such file), '/usr/lib/libsnap7' (no such file, not in dyld cache)
at SoftPlc.S7Server.Srv_Create()
at SoftPlc.S7Server..ctor() in /Users/xxxxx/VisualStudioProjects/_Custom/SoftPlc/SoftPlc/Snap7/snap7.net.cs:line 1918
at SoftPlc.Services.PlcService..ctor(IConfiguration configuration) in /Users/xxxxx/VisualStudioProjects/_Custom/SoftPlc/SoftPlc/Services/PlcService.cs:line 23
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Program.

$(String[] args) in /Users/xxxxx/VisualStudioProjects/_Custom/SoftPlc/SoftPlc/Program.cs:line 48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.