//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static Attribute EmptyMessageData() /// /// \brief Empty message data. /// /// \par Description. /// - This method is used to add an empty message to the list (with default values) /// - This method is used by the GUI to create an empty entry to the list /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \return An Attribute. //////////////////////////////////////////////////////////////////////////////////////////////////// public static Attribute EmptyMessageData() { AttributeDictionary messageData = new AttributeDictionary(); Type messageTypeEnum = ClassFactory.GenerateMessageTypeEnum(); dynamic type = Enum.ToObject(messageTypeEnum, 0); messageData.Add(Comps.Type, new Attribute { Value = type }); messageData.Add(Comps.Name, new Attribute { Value = "BaseMessage" }); messageData.Add(Comps.Fields, new Attribute { Value = new AttributeDictionary() }); messageData.Add(Comps.Targets, new Attribute { Value = new AttributeList(), ElementWindowPrmsMethod = IntListPrms }); return(new Attribute { Value = messageData, Editable = false }); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public void CreateCodeFile() /// /// \brief Creates code file. /// /// \par Description. /// The main method for creating the code file /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 18/03/2018 //////////////////////////////////////////////////////////////////////////////////////////////////// public void CreateCodeFile() { InitSyntaxHighlight(); // The header of the file string fileText = eol + "using System.Collections.Generic;"; fileText += eol + "using DistributedAlgorithms;"; fileText += eol + "using DistributedAlgorithms.Algorithms.Base.Base;"; // The NetworkElement partial class if (!CreateNetworkElementText(ref fileText)) { CustomizedMessageBox.Show("Base algorithm code building cancelled by the user", "BaseAlgorithmAccess", null); return; } // The base algorithm partial class NetworkElement[] networkElements = { new BaseMessage(), new BaseNetwork(), new BaseProcess(), new BaseChannel() }; classNames[0] = "Message"; string[] enumClasses = { "bm", "bn", "bp", "bc" }; fileText += eol + @"namespace DistributedAlgorithms.Algorithms." + "Base" + "." + "Base" + eol + "{"; for (classIdx = 0; classIdx < classNames.Count; classIdx++) { networkElements[classIdx].Init(0); if (!CreateBaseClassText(ref fileText, networkElements[classIdx], enumClasses[classIdx])) { CustomizedMessageBox.Show("Base algorithm code building cancelled by the user", "BaseAlgorithmAccess", null); return; } } fileText += eol + "}"; classNames[0] = "Process"; File.WriteAllText(ClassFactory.GenerateAlgorithmPath("Base", "Base") + "\\" + "Base" + "DefsAndInits" + ".cs", fileText); CustomizedMessageBox.Show("Base algorithm code building finished", "BaseAlgorithmAccess", null, Icons.Success); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public BaseNetwork Update(BaseNetwork existingNetwork) /// /// \brief Updates the given existingNetwork. /// /// \par Description. /// - Update an existing network after the code was changed. /// - The algorithm : /// - For each component of the network activate the Update method on it /// - The Update method starts ScanAndReport process that will cause the /// 2 instances to be cleverly merged /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 28/12/2017 /// /// \param existingNetwork (BaseNetwork) - The existing network. /// /// \return A BaseNetwork. //////////////////////////////////////////////////////////////////////////////////////////////////// public BaseNetwork Update(BaseNetwork existingNetwork) { BaseNetwork newNetwork = ClassFactory.GenerateNetwork(); Update(existingNetwork, newNetwork); foreach (BaseProcess existingProcess in existingNetwork.Processes) { BaseProcess newProcess = ClassFactory.GenerateProcess(newNetwork); Update(existingProcess, newProcess); newNetwork.Processes.Add(newProcess); } foreach (BaseChannel existingChannel in existingNetwork.Channels) { BaseChannel newChannel = ClassFactory.GenerateChannel(newNetwork, existingChannel.ea[ne.eak.Id], existingChannel.ea[bc.eak.SourceProcess], existingChannel.ea[bc.eak.DestProcess]); Update(existingChannel, newChannel); newNetwork.Channels.Add(newChannel); } return(newNetwork); }