//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public BaseMessage(BaseNetwork network, dynamic messageType, AttributeDictionary fields, BaseChannel channel, string messageName = "" , int round, int logicalClock):base(true) /// /// \brief Constructor. /// /// \par Description. /// Create a message from : /// -# The messageType /// -# Fields for the algorithm specific fields in attribute dictionary. /// -# The sending parameters from the channel /// -# The message name /// -# The parameters for the header : round, logical clock /// /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 14/03/2017 /// /// \param network (BaseNetwork) - The network. /// \param messageType (dynamic) - Type of the message. /// \param fields (AttributeDictionary) - The fields. /// \param channel (BaseChannel) - The channel. /// \param messageName (Optional) (string) - Name of the message. /// \param round (Optional) (int) - The round. /// \param logicalClock (Optional) (int) - The logical clock. //////////////////////////////////////////////////////////////////////////////////////////////////// public BaseMessage(BaseNetwork network, dynamic messageType, AttributeDictionary fields, BaseChannel channel, string messageName = "", int round = 0, int logicalClock = 0) : base(true) { this.network = network; pa.Add(bm.pak.MessageType, new Attribute { Value = messageType }); try { pa.Add(bm.pak.SourceProcess, new Attribute { Value = channel.ea[bc.eak.SourceProcess] }); pa.Add(bm.pak.SourcePort, new Attribute { Value = channel.or[bc.ork.SourcePort], IncludedInShortDescription = false, IncludeInEqualsTo = false }); pa.Add(bm.pak.DestProcess, new Attribute { Value = channel.ea[bc.eak.DestProcess] }); pa.Add(bm.pak.DestPort, new Attribute { Value = channel.or[bc.ork.DestPort], IncludedInShortDescription = false, IncludeInEqualsTo = false }); } catch { pa.Add(bm.pak.SourceProcess, new Attribute { Value = 0 }); pa.Add(bm.pak.SourcePort, new Attribute { Value = 0, IncludedInShortDescription = false, IncludeInEqualsTo = false }); pa.Add(bm.pak.DestProcess, new Attribute { Value = 0 }); pa.Add(bm.pak.DestPort, new Attribute { Value = 0, IncludedInShortDescription = false, IncludeInEqualsTo = false }); } pa.Add(bm.pak.Round, new Attribute { Value = round }); pa.Add(bm.pak.LogicalClock, new Attribute { Value = logicalClock }); if (messageName == "") { messageName = TypesUtility.GetKeyToString(messageType); } or.Add(bm.ork.Name, new Attribute { Value = messageName }); op.Add(bm.opk.Breakpoints, new Attribute { Value = new Breakpoint(Breakpoint.HostingElementTypes.Message), Editable = false, IncludedInShortDescription = false }); or.Add(bm.ork.PositionInProcessQ, new Attribute { Value = 0, IncludedInShortDescription = false }); if (fields != null) { foreach (var entry in fields) { AddField(entry.Key, entry.Value); } } }