Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SZLDatasets erweitert #51

Merged
merged 1 commit into from
Apr 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions LibNoDaveConnectionLibrary/Communication/PLCConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,9 @@ public SZLData PLCGetSZL(Int16 SZLNummer, Int16 Index)
case 1:
datsets.Add(EndianessMarshaler.BytesToStruct<xy32_1Dataset>(objBuffer));
break;
case 8:
datsets.Add(EndianessMarshaler.BytesToStruct<xy32_8Dataset>(objBuffer));
break;
default:
{
DefaultSZLDataset tmp = new DefaultSZLDataset();
Expand Down
9 changes: 8 additions & 1 deletion LibNoDaveConnectionLibrary/Communication/PLCTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,14 @@ internal virtual void _putControlValueIntoBuffer(byte[] buff, int startpos, obje
break;
case TagDataType.Bool:
bool tmp1 = false;
tmp1 = Convert.ToBoolean(ctlValue);
try
{
tmp1 = Convert.ToBoolean(ctlValue);
}
catch (Exception)
{
tmp1 = Convert.ToBoolean(Convert.ToInt32(ctlValue));
}
buff[startpos] = Convert.ToByte(tmp1);
break;
case TagDataType.Byte:
Expand Down
152 changes: 152 additions & 0 deletions LibNoDaveConnectionLibrary/Communication/S7_xxx/SZLDatasets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,158 @@ public byte[] res
}
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public class xy32_8Dataset : SZLDataset
{
[Endian(Endianness.BigEndian)]
private ushort _index;
public UInt16 Index
{
get { return _index; }
set { _index = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _zykl;
public UInt16 zykl
{
get { return _zykl; }
set { _zykl = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _korr;
public UInt16 korr
{
get { return _korr; }
set { _korr = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_0;
public UInt16 clock_0
{
get { return _clock_0; }
set { _clock_0 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_1;
public UInt16 clock_1
{
get { return _clock_1; }
set { _clock_1 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_2;
public UInt16 clock_2
{
get { return _clock_2; }
set { _clock_2 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_3;
public UInt16 clock_3
{
get { return _clock_3; }
set { _clock_3 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_4;
public UInt16 clock_4
{
get { return _clock_4; }
set { _clock_4 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_5;
public UInt16 clock_5
{
get { return _clock_5; }
set { _clock_5 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_6;
public UInt16 clock_6
{
get { return _clock_6; }
set { _clock_6 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _clock_7;
public UInt16 clock_7
{
get { return _clock_7; }
set { _clock_7 = value; }
}

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private ushort[] _time;
public UInt16[] time
{
get { return _time; }
set { _time = value; }
}

private byte _bszl_0;
public byte bszl_0
{
get { return _bszl_0; }
set { _bszl_0 = value; }
}

private byte _bszl_1;
public byte bszl_1
{
get { return _bszl_1; }
set { _bszl_1 = value; }
}

private byte _bszü_0;
public byte bszü_0
{
get { return _bszü_0; }
set { _bszü_0 = value; }
}

//reserviert
private byte _bszü_1;
public byte bszü_1
{
get { return _bszü_1; }
set { _bszü_1 = value; }
}

[Endian(Endianness.BigEndian)]
private ushort _status;
public UInt16 status
{
get { return _status; }
set { _status = value; }
}

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
private byte[] _res;
public byte[] res
{
get { return _res; }
set { _res = value; }
}

private byte _status_valid;
public byte status_valid
{
get { return _status_valid; }
set { _status_valid = value; }
}
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public class xy71Dataset : SZLDataset
{
Expand Down
2 changes: 1 addition & 1 deletion LibNoDaveConnectionLibrary/General/EndianAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class EndianessMarshaler
{
public static void RespectEndianness(Type type, byte[] data)
{
foreach (FieldInfo f in type.GetFields()) //BindingFlags.Instance | BindingFlags.NonPublic))
foreach (FieldInfo f in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) //BindingFlags.Instance | BindingFlags.NonPublic))
{
if (f.IsDefined(typeof(EndianAttribute), false))
{
Expand Down
2 changes: 1 addition & 1 deletion ToolBoxLibUnitTests/PDUWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void addVarToWriteRequest(int area, int DBnum, int start, int bytes, byte

public void addNCKToReadRequest(int area, int unit, int column, int line, int module, int linecount)
{
Requests.Add("NCK");
Requests.Add("Read NCK");
}

public void addNCKToWriteRequest(int area, int unit, int column, int line, int module, int linecount, int bytes, byte[] buffer)
Expand Down