Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 from nikvoronin/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
nikvoronin authored Jun 10, 2016
2 parents 1336889 + d5b3acc commit ae59c9a
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 341 deletions.
238 changes: 5 additions & 233 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,236 +1,8 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
###

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Bb]in/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# 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
# TODO: 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

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config

# Windows Store app package directory
AppPackages/
BundleArtifacts/

# 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
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# 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

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# 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

# FAKE - F# Make
.fake/
.vs
*.suo
*.user
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A .NET wrapper around Beckhoff's TwinCAT.Ads API library. Project is not affiliated with Beckhoff.
High-level interface for Beckhoff's TwinCAT.Ads API library. Project is not affiliated with Beckhoff.

Getting started
===============
Expand All @@ -15,7 +15,7 @@ With help of Ads.Remote.PLC.Router you can add new route record into the remote

Installation
------------
TwinCAT 2 or 3 must be installed.
TwinCAT 2 or 3 have to be installed.

Examples
===============
Expand Down Expand Up @@ -47,11 +47,12 @@ private void Plc_DeviceReady(object sender, AdsDevice e)
Create a copy of your PLC's variable then use it like an ordinary variable

```C#
Var<short> main_count = plc.Var<short>("MAIN.count");
Var<ushort> main_state = plc.Var<ushort>("MAIN.state");
Var<ushort> frm0 = plc.Var<ushort>("Inputs.Frm0InputToggle", 27907);
Var<ushort> devState = plc.Var<ushort>(0xF030, 0x5FE, 27907);
Var<short> g_Version = plc.Var<ushort>(".VERSION");
Var<short> main_count = plc.Var<short> ("MAIN.count");
Var<ushort> main_state = plc.Var<ushort>("MAIN.state");
Var<short> g_Version = plc.Var<ushort>(".VERSION");

Var<ushort> frm0 = plc.Var<ushort>("Inputs.Frm0InputToggle", 27907);
Var<ushort> devState = plc.Var<ushort>(0xF030, 0x5FE, 27907);

long framesTotal += frm0 / 2; // automatic type casting
MessageBox.Show(frm0); // cast into the string type without call of the ToString()
Expand Down
Binary file removed lib/TwinCAT.Ads.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions src/AdsRemote/Ads.Remote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\Release\</OutputPath>
<DefineConstants>
Expand All @@ -33,9 +33,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="TwinCAT.Ads, Version=4.0.15.0, Culture=neutral, PublicKeyToken=180016cd49e5e8c3, processorArchitecture=MSIL">
<Reference Include="TwinCAT.Ads, Version=4.1.16.0, Culture=neutral, PublicKeyToken=180016cd49e5e8c3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\TwinCAT.Ads.dll</HintPath>
<HintPath>C:\TwinCAT\AdsApi\.NET\v4.0.30319\TwinCAT.Ads.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
16 changes: 4 additions & 12 deletions src/AdsRemote/AmsRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ private static RemotePlcInfo ParseBroadcastSearchResponse(ResponseResult rr)
// TCat type
byte[] tcatType = rr.NextChunk(Segment.TCATTYPE_RUNTIME.Length);
if (tcatType[0] == Segment.TCATTYPE_RUNTIME[0])
{
if (tcatType[2] == Segment.TCATTYPE_RUNTIME[2])
device.IsRuntime = true;
}

// OS version
byte[] osVer = rr.NextChunk(Segment.L_OSVERSION);
Expand All @@ -239,7 +237,6 @@ private static RemotePlcInfo ParseBroadcastSearchResponse(ResponseResult rr)

int ci = tail.Length - 4;
for (int i = ci; i > 0; i -= 4)
{
if (tail[i + 0] == 3 &&
tail[i + 2] == 4)
{
Expand All @@ -250,7 +247,6 @@ private static RemotePlcInfo ParseBroadcastSearchResponse(ResponseResult rr)
device.TcVersion.Build = tail[i + 6] + tail[i + 7] * 256;
break;
}
}

// Comment
byte[] descMarker = rr.NextChunk(Segment.L_DESCRIPTIONMARKER);
Expand All @@ -259,40 +255,36 @@ private static RemotePlcInfo ParseBroadcastSearchResponse(ResponseResult rr)
if (descMarker[0] == 2)
{
if (isUnicode)
{
for (int i = 0; i < c; i += 2)
{
if (rr.Buffer[rr.Shift + i] == 0 &&
rr.Buffer[rr.Shift + i + 1] == 0)
break;
len += 2;
}
}
else
{
for (int i = 0; i < c; i++)
{
if (rr.Buffer[rr.Shift + i] == 0)
break;
len++;
}
}

if (len > 0)
{
byte[] description = rr.NextChunk(len);

if (isUnicode)
if (!isUnicode)
device.Comment = ASCIIEncoding.Default.GetString(description);
else
{
byte[] asciiBytes = Encoding.Convert(Encoding.Unicode, Encoding.ASCII, description);
char[] asciiChars = new char[Encoding.ASCII.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
Encoding.ASCII.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
device.Comment = new string(asciiChars);
}
else
device.Comment = ASCIIEncoding.Default.GetString(description);
}
}
} // if (descMarker[0] == 2)

return device;
}
Expand Down
2 changes: 1 addition & 1 deletion src/AdsRemote/Common/AdsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal AdsDevice(AmsNetId amsNetId, int port)

internal void SetActive(bool isActive)
{
this.isReady = isActive;
isReady = isActive;
}
}
}
2 changes: 0 additions & 2 deletions src/AdsRemote/Common/VarBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public void Dispose()
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
TryUnsubscribe();
}
}
}
}
Loading

0 comments on commit ae59c9a

Please sign in to comment.