Agregada funcion de analizar la matriz de exportacion de tags. Creada un submenu para cargar los ultimos directorios ustilizados. Cambiado intercambio de datos para los Motores simulados a DINT

This commit is contained in:
Miguel 2025-02-14 14:04:29 +01:00
parent 5208ae54b3
commit 72256a214c
1 changed files with 38 additions and 7 deletions

View File

@ -85,9 +85,9 @@ namespace LibS7Adv
[property: JsonIgnore] [property: JsonIgnore]
public void ConnectButton() public void ConnectButton()
{ {
if (isConnected) if (isConnected)
Disconnect(); Disconnect();
else else
Connect(); Connect();
} }
@ -153,7 +153,7 @@ namespace LibS7Adv
return false; return false;
} }
if (sTag == null) if (sTag == null)
{ return false; } { return false; }
var tag = ParseTagAddress(sTag); var tag = ParseTagAddress(sTag);
if (tag.tagType == EDataType.Unknown) // Normal Tag? if (tag.tagType == EDataType.Unknown) // Normal Tag?
{ {
@ -243,7 +243,7 @@ namespace LibS7Adv
{ {
var val = Instance?.MarkerArea.ReadByte(tag.word_offset); var val = Instance?.MarkerArea.ReadByte(tag.word_offset);
if (Signed) if (Signed)
return val > 127 ? (val-256).ToString() : val.ToString(); return val > 127 ? (val - 256).ToString() : val.ToString();
return val.ToString(); return val.ToString();
} }
} }
@ -394,11 +394,42 @@ namespace LibS7Adv
} }
} }
public int? LeerTagDInt(string pTag)
{
try
{
stopwatch.Restart();
int? result = Instance?.ReadInt32(pTag);
stopwatch.Stop();
Debug.WriteLine($" LeerTagDInt took {stopwatch.Elapsed.TotalMilliseconds} ms");
return result;
}
catch (Exception ex)
{
PlcData.LastError = pTag + ":" + ex.Message;
return 0;
}
}
public void EscribirTagDInt(string pTag, int pValue)
{
try
{
stopwatch.Restart();
Instance?.WriteInt32(pTag, pValue);
stopwatch.Stop();
Debug.WriteLine($" EscribirTagDInt took {stopwatch.Elapsed.TotalMilliseconds} ms");
}
catch (Exception ex)
{
PlcData.LastError = pTag + ":" + ex.Message;
}
}
public static TagAddress ParseTagAddress(string tag) public static TagAddress ParseTagAddress(string tag)
{ {
TagAddress tagAddress = new TagAddress(); TagAddress tagAddress = new TagAddress();
if (tag==null) if (tag == null)
return null; return null;
if (tag.StartsWith("%")) if (tag.StartsWith("%"))
{ {