From 4a7070ee6e4f4b61c0ceb017a333f6520fd26966 Mon Sep 17 00:00:00 2001 From: ahmed Date: Mon, 25 Aug 2025 03:39:37 +0300 Subject: [PATCH] Parsing --- Esiur/Data/Codec.cs | 2 + .../Net/IIP/DistributedConnectionProtocol.cs | 39 ++++++++++++++----- Esiur/Net/IIP/DistributedResource.cs | 2 +- Test/Program.cs | 2 +- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Esiur/Data/Codec.cs b/Esiur/Data/Codec.cs index 73f7c23..b493cc6 100644 --- a/Esiur/Data/Codec.cs +++ b/Esiur/Data/Codec.cs @@ -197,6 +197,8 @@ public static class Codec var tt = dataType.Value; + Console.WriteLine("Parsing " + tt.Class + " " + tt.Identifier); + if (tt.Class == TransmissionTypeClass.Fixed) { return (len, FixedAsyncParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence)); diff --git a/Esiur/Net/IIP/DistributedConnectionProtocol.cs b/Esiur/Net/IIP/DistributedConnectionProtocol.cs index f9e6667..15334b1 100644 --- a/Esiur/Net/IIP/DistributedConnectionProtocol.cs +++ b/Esiur/Net/IIP/DistributedConnectionProtocol.cs @@ -1692,23 +1692,30 @@ partial class DistributedConnection var rt = new AsyncReply(); - Query(path).Then(ar => - { + SendRequest(IIPPacketRequest.GetResourceIdByLink, path) + .Then(result => + { + rt.Trigger(result); + }).Error(ex => rt.TriggerError(ex)); - //if (filter != null) - // ar = ar?.Where(filter).ToArray(); + //Query(path).Then(ar => + //{ - // MISSING: should dispatch the unused resources. - if (ar?.Length > 0) - rt.Trigger(ar[0]); - else - rt.Trigger(null); - }).Error(ex => rt.TriggerError(ex)); + // //if (filter != null) + // // ar = ar?.Where(filter).ToArray(); + + // // MISSING: should dispatch the unused resources. + // if (ar?.Length > 0) + // rt.Trigger(ar[0]); + // else + // rt.Trigger(null); + //}).Error(ex => rt.TriggerError(ex)); return rt; } + public AsyncReply GetLinkTemplates(string link) { var reply = new AsyncReply(); @@ -1743,6 +1750,7 @@ partial class DistributedConnection /// DistributedResource public AsyncReply Fetch(uint id, uint[] requestSequence) { + DistributedResource resource = null; attachedResources[id]?.TryGetTarget(out resource); @@ -1758,22 +1766,30 @@ partial class DistributedConnection { if (resource != null && (requestSequence?.Contains(id) ?? false)) { + Console.WriteLine("Fetching DL " + id); + // dead lock avoidance for loop reference. return new AsyncReply(resource); } else if (resource != null && requestInfo.RequestSequence.Contains(id)) { + Console.WriteLine("Fetching DL2 " + id); + // dead lock avoidance for dependent reference. return new AsyncReply(resource); } else { + Console.WriteLine("Fetching DL3 " + id); + return requestInfo.Reply; } } else if (resource != null && !resource.DistributedResourceSuspended) { // @REVIEW: this should never happen + Console.WriteLine("Fetching DLWWW " + id); + Global.Log("DCON", LogType.Error, "Resource not moved to attached."); return new AsyncReply(resource); @@ -1783,6 +1799,7 @@ partial class DistributedConnection var reply = new AsyncReply(); resourceRequests.Add(id, new DistributedResourceAttachRequestInfo(reply, newSequence)); + Console.WriteLine("Fetching " + id); SendRequest(IIPPacketRequest.AttachResource, id) .Then((result) => @@ -1802,6 +1819,8 @@ partial class DistributedConnection var hops = (byte)args[3]; var pvData = (byte[])args[4]; + Console.WriteLine("Fetching CL " + id); + DistributedResource dr; TypeTemplate template = null; diff --git a/Esiur/Net/IIP/DistributedResource.cs b/Esiur/Net/IIP/DistributedResource.cs index 77a7048..d75c9e9 100644 --- a/Esiur/Net/IIP/DistributedResource.cs +++ b/Esiur/Net/IIP/DistributedResource.cs @@ -169,7 +169,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan } /// - /// Export all properties with ResourceProperty attributed as bytes array. + /// Export properties as byte array. /// /// internal PropertyValue[] _Serialize() diff --git a/Test/Program.cs b/Test/Program.cs index 567cea0..544ac0f 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -190,7 +190,7 @@ namespace Test var format = x.RequiredFormat; if (format == IIPAuthPacketIAuthFormat.Number) - return new AsyncReply(Convert.ToInt32(Console.ReadLine())); + return new AsyncReply(Convert.ToInt32(10)); else if (format == IIPAuthPacketIAuthFormat.Text) return new AsyncReply(Console.ReadLine().Trim());