Ejemplo n.º 1
0
        /**********************************************************************************************//**
        * Constructor.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   list        The list.
        * \param   network     The network.
        * \param   Editable    (Optional) True if editable.
        *
        **************************************************************************************************/

        public ListInput(object list, BaseNetwork network, bool Editable = true)
        {
            this.network       = network;
            listOfAttributes   = list.GetType().GenericTypeArguments[0].Equals(typeof(Attribute));
            this.list          = list;
            listForResetToInit = TypesUtility.CreateListFromString(list.GetType().ToString());
            TypesUtility.CopyList(list, listForResetToInit);
            listForResetToSaved = TypesUtility.CreateListFromString(list.GetType().ToString());
            TypesUtility.CopyList(list, listForResetToSaved);
            InitializeComponent();
            if (!listOfAttributes)
            {
                Button_Edit.Visibility = System.Windows.Visibility.Collapsed;
                ComboBox_Replace_SelectValue.Visibility = System.Windows.Visibility.Collapsed;
                ComboBox_SelectValue.Visibility         = System.Windows.Visibility.Collapsed;
                ComboBox_SelectCategory.Visibility      = System.Windows.Visibility.Collapsed;
                ComboBox_SelectType.Visibility          = System.Windows.Visibility.Collapsed;
            }
            else
            {
                InitComboBoxes();
            }
            this.Title = "Editting list of type " + list.GetType().GenericTypeArguments[0].ToString();
            FillListBox(list, IndexCreatingOperation.Start);
            editable = Editable;
        }
Ejemplo n.º 2
0
        private void StartServer()
        {
            playWindow.NetworkEnabled = true;
            strokeLock      = true;
            endGameLock     = false;
            playWindow.Text = "Chess - Server";
            networkGame     = true;

            playWindow.Show();

            try
            {
                network = new NetworkServer();
                RegisterNetEventHandlers();

                ((NetworkServer)network).StartServer();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Server Error");
                Debug.NewMessage(this.ToString() + e.Message);
            }

            Debug.NewMessage(this.ToString() + " serve initalizated...");
        }
Ejemplo n.º 3
0
    public IEnumerator Login_()
    {
        string address = "http://kbssj1.cafe24.com/Universal/Main/UserLogin.php";

        WWWForm cFrom = new WWWForm();

        BaseNetwork.Base(ref cFrom);

        cFrom.AddField("id", ID_InputField.text);
        cFrom.AddField("password", PASSWORD_InputField.text);

        WWW wwwUrl = new WWW(address, cFrom);

        yield return(wwwUrl);

        if (wwwUrl.text.Equals("UserLoginFail"))
        {
            message.ShowInfoText("아이디 및 비밀번호가 틀렸습니다.");
        }
        else
        {
            GameInformation.id = ID_InputField.text;
            SceneManager.LoadScene("Lobby");
        }
    }
Ejemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            BaseInformationReader baseInformation = new BaseInformationReader();

            NetworkBase         = new BaseNetwork();
            LocalPlayerDatabase = new LocalDatabase();
        }
Ejemplo n.º 5
0
        /**********************************************************************************************//**
        * Adjust for other elements breakpoints.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   parametersList  List of parameters.
        * \param   network         The network.
        *
        **************************************************************************************************/

        private void AdjustForOtherElementsBreakpoints(AttributeList parametersList, BaseNetwork network)
        {
            // If the breakpoint is on other elements it has 4 parameters
            // 1. List of processors
            // 2. List of channels
            // 3. message handling mode
            // 4. breakpoint
            // The first 2 elements stayes and the other parameters are stored in member variables
            // Save the network in member
            // If the list of the channels is empty add -1 to the list - this will cause the evaluation method
            //    to evaluate with channel = null.
            // The -1 is inserted in a new list in order not effect the original list

            Operators o = or[brp.ork.Operator];

            if (o == Operators.OperationsOnOtherElements)
            {
                breakpointForOtherElements = ((Attribute)parametersList[3]).Value;
                messageHandlingForOtherElementOperation = ((Attribute)parametersList[2]).Value;
                networkForOtherElementOperation         = network;
                parametersList.RemoveAt(3);
                parametersList.RemoveAt(2);
                if (((Attribute)parametersList[1]).Value.Count == 0)
                {
                    parametersList[1] = new Attribute()
                    {
                        Value = new List <int>()
                        {
                            -1
                        }
                    };
                }
            }
        }
Ejemplo n.º 6
0
    public IEnumerator MakeID_()
    {
        string address = "http://kbssj1.cafe24.com/Universal/CreateUser/createUser.php";

        WWWForm cFrom = new WWWForm();

        BaseNetwork.Base(ref cFrom);

        cFrom.AddField("id", ID_InputField.text);
        cFrom.AddField("password", PASSWORD_InputField.text);

        WWW wwwUrl = new WWW(address, cFrom);

        yield return(wwwUrl);

        if (wwwUrl.text.Equals("UserCreateSuccess"))
        {
            message.ShowInfoText("아이디 생성이 완료되었습니다.");
            mainControl.Close_CreateID_Screen();
            mainControl.Open_Login_Screen();
        }
        else
        {
            message.ShowInfoText("아이디 생성이 실패했습니다.");
        }
    }
Ejemplo n.º 7
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static bool CheckIfProcessExists(BaseNetwork network, NetworkElement networkElement, Attribute parentAttribute, Attribute attribute, string newValue, out string errorMessage, ElementWindow inputWindow = null)
        ///
        /// \brief Determine if process exists.
        ///
        /// \par Description.
        ///      -  This method is activated by the GUI after a value in one of the target processors
        ///         for the message was changed.
        ///      -  The method checks whether there is a process with id equals to the new value in the network
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 09/05/2018
        ///
        /// \param       network          (BaseNetwork) - The network.
        /// \param       networkElement   (NetworkElement) - The network element.
        /// \param       parentAttribute  (Attribute) - The parent attribute.
        /// \param       attribute        (Attribute) - The attribute.
        /// \param       newValue         (string) - The new value.
        /// \param [out] errorMessage    (out string) - Message describing the error.
        /// \param       inputWindow     (Optional)  (ElementWindow) - The input window.
        ///
        /// \return True if it succeeds, false if it fails.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static bool CheckIfProcessExists(BaseNetwork network,
                                                NetworkElement networkElement,
                                                Attribute parentAttribute,
                                                Attribute attribute,
                                                string newValue,
                                                out string errorMessage,
                                                ElementWindow inputWindow = null)
        {
            errorMessage = "";
            try
            {
                errorMessage = "The value has to be int";
                int id = int.Parse(newValue);

                errorMessage = "There is no processor with id :" + newValue;
                network.Processes.First(p => p.ea[ne.eak.Id] == id);

                errorMessage = "";
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
    public IEnumerator Check_()
    {
        string address = "http://kbssj1.cafe24.com/Universal/CreateUser/idOverlapcheck.php";

        WWWForm cFrom = new WWWForm();

        BaseNetwork.Base(ref cFrom);

        cFrom.AddField("id", ID_InputField.text);

        WWW wwwUrl = new WWW(address, cFrom);

        //yield return new WaitForSeconds(TimeSpeed);
        yield return(wwwUrl);

        if (wwwUrl.text.Equals("idable"))
        {
            isIdOverlapCheck = true;
            message.ShowInfoText("아이디 사용이 가능합니다.");
        }
        else
        {
            message.ShowInfoText("아이디가 존재합니다.");
        }
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static bool EventTriggerChanged(BaseNetwork network, NetworkElement networkElement, Attribute parentAttribute, Attribute attribute, string newValue, out string errorMessage, ElementWindow inputWindow = null)
        ///
        /// \brief Event trigger changed.
        ///
        /// \par Description.
        ///      -  This method is activated by the GUI when the Trigger was changed
        ///      -  The purpose of this method is to disable all the other fields if the
        ///         Event is initialize and enable all the fields otherwise
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 09/05/2018
        ///
        /// \param       network          (BaseNetwork) - The network.
        /// \param       networkElement   (NetworkElement) - The network element.
        /// \param       parentAttribute  (Attribute) - The parent attribute.
        /// \param       attribute        (Attribute) - The attribute.
        /// \param       newValue         (string) - The new value.
        /// \param [out] errorMessage    (out string) - Message describing the error.
        /// \param       inputWindow     (Optional)  (ElementWindow) - The input window.
        ///
        /// \return True if it succeeds, false if it fails.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static bool EventTriggerChanged(BaseNetwork network, NetworkElement networkElement, Attribute parentAttribute, Attribute attribute, string newValue, out string errorMessage, ElementWindow inputWindow = null)
        {
            // Get All the childes of the parent attribute
            List <ElementWindow.ControlsAttributeLink> links = inputWindow.controlsAttributeLinks.Values.Where(l => l.parentAttribute == parentAttribute &&
                                                                                                               l.attribute != attribute).ToList();

            if (newValue == "Initialize")
            {
                foreach (ElementWindow.ControlsAttributeLink link in links)
                {
                    link.newValueControl.IsEnabled             = false;
                    ((Control)link.newValueControl).Background = Brushes.LightGray;
                    string defaultValue = "";
                    inputWindow.ChangeValue(defaultValue, link.attribute);
                }
            }
            else
            {
                string prevValue = inputWindow.controlsAttributeLinks.Values.First(l => l.attribute == attribute).existingNewValue;
                if (prevValue == "Initialize")
                {
                    foreach (ElementWindow.ControlsAttributeLink link in links)
                    {
                        link.newValueControl.IsEnabled             = true;
                        ((Control)link.newValueControl).Background = Brushes.White;
                        inputWindow.ChangeValue(link.existingValueTextBox.Text, link.attribute);
                    }
                }
            }
            errorMessage = "";
            return(true);
        }
Ejemplo n.º 10
0
    protected override void OnPEStart()
    {
        BindAction(EPacketType.PT_InRoom_InitData, RPC_S2C_InitData);
        BindAction(EPacketType.PT_InRoom_TeamChange, RPC_S2C_TeamChange);
        BindAction(EPacketType.PT_InRoom_StatusChange, RPC_S2C_RoomStatusChanged);
        BindAction(EPacketType.PT_InRoom_StartLogin, RPC_S2C_StartLogin);
        BindAction(EPacketType.PT_InRoom_Message, RPC_Message);
        BindAction(EPacketType.PT_InRoom_Ping, RPC_Ping);
        BindAction(EPacketType.PT_InRoom_KickPlayer, RPC_S2C_KickPlayer);
        BindAction(EPacketType.PT_Common_RandomTownData, RPC_S2C_RandomTownData);
        BindAction(EPacketType.PT_InGame_GrassInfo, RPC_S2C_GrassInfo);
        BindAction(EPacketType.PT_InGame_TreeInfo, RPC_S2C_TreeInfo);

        if (IsOwner)
        {
            if (Pathea.PeGameMgr.IsMultiCustom || Pathea.PeGameMgr.IsMultiStory)
            {
                LSubTerrSL.OnLSubTerrSLInitEvent += CacheDelTree;
            }
            else
            {
                RSubTerrSL.OnRSubTerrSLInitEvent += CacheDelTree;
            }

            GrassDataSL.OnGrassDataInitEvent += CacheDelGrass;

            _mainPlayer = this;
            RequestUGC();
        }

        RequestInitData();
    }
Ejemplo n.º 11
0
 void ShowMenu(int index)
 {
     mFriendWnd.mOptionMenu.Clear();
     if (mFriendWnd.mTabState == UIFriendWnd.TabState.state_Friend)
     {
         mFriendWnd.mOptionMenu.AddOption("ChatTo", ChatTo);
         if (BaseNetwork.IsInRoom())
         {
             mFriendWnd.mOptionMenu.AddOption("Invite", Invite);
         }
         mFriendWnd.mOptionMenu.AddOption("Delete", FriendRemove);
     }
     else if (mFriendWnd.mTabState == UIFriendWnd.TabState.state_Palyer)
     {
         if (mBaseNetWorkList[index].SteamID.m_SteamID == mMyData._SteamID.m_SteamID)
         {
             return;
         }
         if (BaseNetwork.IsInRoom())
         {
             mFriendWnd.mOptionMenu.AddOption("Add Friend", AddFriend);
         }
     }
     mFriendWnd.mOptionMenu.Show();
     mCurrentIndex = index;
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public EchoMessage(BaseNetwork network, object messageType, AttributeDictionary fields, BaseChannel channel, string messageName, int round, int logicalClock):base(network, messageType, fields, channel, messageName, round, logicalClock)
        ///
        /// \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  (string) - Name of the message.
        /// \param round        (int) - The round.
        /// \param logicalClock (int) - The logical clock.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public EchoMessage(BaseNetwork network,
                           object messageType,
                           AttributeDictionary fields,
                           BaseChannel channel,
                           string messageName,
                           int round, int logicalClock) : base(network, messageType, fields, channel, messageName, round, logicalClock)
        {
        }
Ejemplo n.º 13
0
        public NetworkReceiver(BaseNetwork baseNetwork)
        {
            m_UnityServer = UnityServer.Instance;
            m_BaseNetwork = baseNetwork;

            m_LoginHandler    = new LoginHandler();
            m_MovementHandler = new MovementHandler();
        }
Ejemplo n.º 14
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public ChandyLamport_NewStyleMessage(BaseNetwork network, object messageType, AttributeDictionary fields, BaseChannel channel, string messageName, int round = 0, int logicalClock = 0):base(network, messageType, fields, channel, messageName, round, logicalClock)
        ///
        /// \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   (object) - Type of the message.
        /// \param fields        (AttributeDictionary) - The fields.
        /// \param channel       (BaseChannel) - The channel.
        /// \param messageName   (string) - Name of the message.
        /// \param round        (Optional)  (int) - The round.
        /// \param logicalClock (Optional)  (int) - The logical clock.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public ChandyLamport_NewStyleMessage(BaseNetwork network,
                                             object messageType,
                                             AttributeDictionary fields,
                                             BaseChannel channel,
                                             string messageName,
                                             int round = 0, int logicalClock = 0) : base(network, messageType, fields, channel, messageName, round, logicalClock)
        {
        }
Ejemplo n.º 15
0
        /*
         * The possible parameters are:
         * key - in this case find the attribute
         * if the attribute found is a list
         *  if only one value from the list is requested
         *      return the value according to an index
         *  else return the list
         * else (the value is not a list) return the value
         */

        /**********************************************************************************************//**
        * Evaluate parameter.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \exception   EvaluationException Thrown when an Evaluation error condition occurs.
        *
        * \param   evaluationMode  The evaluation mode.
        * \param   network         The network.
        * \param   process         The process.
        * \param   channel         The channel.
        * \param   message         The message.
        * \param   parameter       The parameter.
        *
        * \return  An Attribute.
        *  .
        **************************************************************************************************/

        private Attribute EvaluateParameter(EvaluationMode evaluationMode, BaseNetwork network, BaseProcess process, BaseChannel channel, BaseMessage message, Attribute parameter)
        {
            if (parameter.Value.GetType().IsEnum)
            {
                if (!NetworkElementExist(network, process, channel, message))
                {
                    return(new Attribute()
                    {
                        Value = false
                    });
                }
                Attribute attribute = FindAttribute(network, process, channel, message, parameter.Value);
                if (attribute == null)
                {
                    string typeOfHostingElementStr = TypesUtility.GetKeyToString(or[brp.ork.HostingElementType]);
                    throw new EvaluationException("Could not find attribute " + TypesUtility.GetKeyToString(parameter.Value) + " In element of type " + typeOfHostingElementStr);
                }
                else
                {
                    if (Attribute.GetValueCategory(attribute) == Attribute.AttributeCategory.ListOfAttributes)
                    {
                        if (or[brp.ork.ListParameterOneOrAll] == ListParameterOneOrAll.One)
                        {
                            object[] elements       = TypesUtility.InvokeMethodOfList(attribute.Value, "ToArray", new object[0], true);
                            int      requestedIndex = or[brp.ork.IndexInList];
                            if (elements.Count() <= requestedIndex)
                            {
                                throw new EvaluationException("The index requested : " + requestedIndex.ToString() + " is larger or equal to the number of elements in the list : " + elements.Count());
                            }
                            else
                            {
                                if (Attribute.GetValueCategory(attribute) == Attribute.AttributeCategory.ListOfAttributes)
                                {
                                    return((Attribute)elements[requestedIndex]);
                                }
                                else
                                {
                                    return(new Attribute()
                                    {
                                        Value = elements[requestedIndex]
                                    });
                                }
                            }
                        }
                    }
                    return(attribute);
                }
            }
            if (parameter.Value.GetType().Equals(typeof(Breakpoint)))
            {
                return(new Attribute()
                {
                    Value = parameter.Value.Evaluate(evaluationMode, network, process, channel, message)
                });
            }
            return(parameter);
        }
Ejemplo n.º 16
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public BaseMessage GenerateMessage(BaseNetwork network, string messageString, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a message.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network        (BaseNetwork) - The network.
        /// \param messageString  (string) - The message string.
        /// \param subject       (Optional)  (string) - The subject.
        /// \param algorithm     (Optional)  (string) - The algorithm.
        ///
        /// \return The message.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public BaseMessage GenerateMessage(BaseNetwork network, string messageString, string subject = null, string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseMessage)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Message",
                       new object[] { network, messageString }));
        }
Ejemplo n.º 17
0
 public void Start()
 {
     network = new MFNN(new int[] { 5, 20, actions.Length }, new ActivationType[] {
         ActivationType.NONE,
         ActivationType.ReLU,
         ActivationType.ReLU
     });
     controller = GetComponent <CarController>();
     car_camera = GetComponent <CarCamera>();
 }
Ejemplo n.º 18
0
        private void EndGame()
        {
            endGameLock = true;

            if (network != null)
            {
                network.Disconnect();
                network = null;
            }
        }
Ejemplo n.º 19
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static BaseChannel GenerateChannel(BaseNetwork network, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a channel.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network    (BaseNetwork) - The network.
        /// \param subject   (Optional)  (string) - The subject.
        /// \param algorithm (Optional)  (string) - The algorithm.
        ///
        /// \return The channel.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static BaseChannel GenerateChannel(BaseNetwork network, string subject = null, string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            BaseChannel channel = (BaseChannel)TypesUtility.CreateObjectFromTypeString(
                GenerateNamespace(subject, algorithm) + "." + algorithm + "Channel", new object[] { network });

            return(channel);
        }
Ejemplo n.º 20
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static BaseProcess GenerateProcess(BaseNetwork network, string subject = null, string algorithm = null)
        ///
        /// \brief Generates the process.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network    (BaseNetwork) - The network.
        /// \param subject   (Optional)  (string) - The subject.
        /// \param algorithm (Optional)  (string) - The algorithm.
        ///
        /// \return The process.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static BaseProcess GenerateProcess(BaseNetwork network, string subject = null, string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }

            BaseProcess process = (BaseProcess)TypesUtility.CreateObjectFromTypeString(
                GenerateNamespace() + "." + Config.Instance[Config.Keys.SelectedAlgorithm] + "Process", new object[] { network });

            return(process);
        }
Ejemplo n.º 21
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public BaseMessage GenerateMessage(BaseNetwork network, Permissions permissions = null, IValueHolder parent = null, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a message.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network      (BaseNetwork) - The network.
        /// \param permissions (Optional)  (Permissions) - The permissions.
        /// \param parent      (Optional)  (IValueHolder) - The parent.
        /// \param subject     (Optional)  (string) - The subject.
        /// \param algorithm   (Optional)  (string) - The algorithm.
        ///
        /// \return The message.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public BaseMessage GenerateMessage(BaseNetwork network,
                                           Permissions permissions = null,
                                           IValueHolder parent     = null,
                                           string subject          = null,
                                           string algorithm        = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseMessage)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Message",
                       new object[] { network, permissions, parent }));
        }
Ejemplo n.º 22
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static BaseChannel GenerateChannel(BaseNetwork network, int id, int sourceProcessId, int destProcessId, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a channel.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network          (BaseNetwork) - The network.
        /// \param id               (int) - The identifier.
        /// \param sourceProcessId  (int) - Identifier for the source process.
        /// \param destProcessId    (int) - Identifier for the destination process.
        /// \param subject         (Optional)  (string) - The subject.
        /// \param algorithm       (Optional)  (string) - The algorithm.
        ///
        /// \return The channel.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static BaseChannel GenerateChannel(BaseNetwork network,
                                                  int id,
                                                  int sourceProcessId,
                                                  int destProcessId,
                                                  string subject   = null,
                                                  string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseChannel)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Channel",
                       new object[] { network, id, sourceProcessId, destProcessId }));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public RunningHandeler(MainWindow mainWindow, BaseNetwork network, bool inDebugMode)
        ///
        /// \brief Constructor.
        ///
        /// \brief #### Algorithm.
        ///
        /// \brief #### Usage Notes.
        ///
        /// \author Main
        /// \date 24/01/2017
        ///
        /// \param mainWindow  The main window.
        /// \param network     The network.
        /// \param inDebugMode True to enable in debug mode, false to disable it.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public RunningHandeler(BaseNetwork network, bool inDebugMode)
        {
            this.network     = network;
            this.inDebugMode = inDebugMode;
            if (inDebugMode)
            {
                processesInStep = network.Processes;
            }
            for (int idx = 0; idx < network.Processes.Count; idx++)
            {
                vectorClock.Add(0);
            }
            Logger.Init();
            Logger.SetVectorClock(vectorClock);
        }
Ejemplo n.º 24
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public BaseMessage GenerateMessage(BaseNetwork network, dynamic messageType, AttributeDictionary fields, BaseChannel channel, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a message.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network      (BaseNetwork) - The network.
        /// \param messageType  (dynamic) - Type of the message.
        /// \param fields       (AttributeDictionary) - The fields.
        /// \param channel      (BaseChannel) - The channel.
        /// \param subject     (Optional)  (string) - The subject.
        /// \param algorithm   (Optional)  (string) - The algorithm.
        ///
        /// \return The message.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public BaseMessage GenerateMessage(BaseNetwork network,
                                           dynamic messageType,
                                           AttributeDictionary fields,
                                           BaseChannel channel,
                                           string subject   = null,
                                           string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseMessage)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Message",
                       new object[] { network, messageType, fields, channel }));
        }
Ejemplo n.º 25
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public BaseMessage GenerateMessage(BaseNetwork network, dynamic messageType, BaseChannel channel, string subject = null, string algorithm = null, int round = 0, int logicalClock = 0)
        ///
        /// \brief Generates a message.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network       (BaseNetwork) - The network.
        /// \param messageType   (dynamic) - Type of the message.
        /// \param channel       (BaseChannel) - The channel.
        /// \param subject      (Optional)  (string) - The subject.
        /// \param algorithm    (Optional)  (string) - The algorithm.
        /// \param round        (Optional)  (int) - The round.
        /// \param logicalClock (Optional)  (int) - The logical clock.
        ///
        /// \return The message.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public BaseMessage GenerateMessage(BaseNetwork network,
                                           dynamic messageType,
                                           BaseChannel channel,
                                           string subject   = null,
                                           string algorithm = null,
                                           int round        = 0, int logicalClock = 0)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseMessage)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Message",
                       new object[] { network, messageType, channel, round, logicalClock }));
        }
Ejemplo n.º 26
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static bool CheckMembers(IValueHolder checkedValueHolder, BaseNetwork network, Permissions permissions, IValueHolder parent, int nestingLevel, string key, bool checkPermissions = true)
        ///
        /// \brief Check members.
        ///
        /// \par Description.
        ///      This is a method that recursively check the members of a tree under the IValueHolder
        ///
        /// \par Algorithm.
        ///      -# Check the members of the IValueHolder:
        ///         -#  The network (Has to be the same as the parent)
        ///         -#  The permissions (Has to be the same as the parent)
        ///         -#  The parent
        ///      -# Cal the CheckMembers of the IValueHolder to implement the recursive check
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 25/07/2017
        ///
        /// \param checkedValueHolder  (IValueHolder) - The checked value holder.
        /// \param network             (BaseNetwork) - The network.
        /// \param permissions          (Permissions) - The permissions.
        /// \param parent              (IValueHolder) - The parent.
        /// \param nestingLevel        (int) - The nesting level.
        /// \param key                 (string) - The key.
        /// \param checkPermissions    (Optional)  (bool) - true to check permissions.
        ///
        /// \return True if it succeeds, false if it fails.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        #region /// \name Check building of members

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static bool CheckMembers(this IValueHolder checkedValueHolder, BaseNetwork network, Permissions permissions, IValueHolder parent, int nestingLevel, string key, bool checkPermissions = true)
        ///
        /// \brief An IValueHolder extension method that check members.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 10/09/2017
        ///
        /// \param checkedValueHolder The checkedValueHolder to act on.
        /// \param network             (BaseNetwork) - The network.
        /// \param permissions          (Permissions) - The permissions.
        /// \param parent              (IValueHolder) - The parent.
        /// \param nestingLevel        (int) - The nesting level.
        /// \param key                 (string) - The key.
        /// \param checkPermissions    (Optional)  (bool) - true to check permissions.
        ///
        /// \return True if it succeeds, false if it fails.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static bool CheckMembers(this IValueHolder checkedValueHolder,
                                        BaseNetwork network,
                                        NetworkElement element,
                                        Permissions permissions,
                                        IValueHolder parent,
                                        int nestingLevel,
                                        string key,
                                        bool checkPermissions = true)
        {
            checkedValueHolder.GenerateCheckMessage(nestingLevel, key, " Start");
            if (checkedValueHolder.Network != network)
            {
                checkedValueHolder.GenerateCheckMessage(nestingLevel, key, "The network is not equal");
                return(false);
            }
            if (checkedValueHolder.Element != element)
            {
                checkedValueHolder.GenerateCheckMessage(nestingLevel, key, "The element is not equal");
                return(false);
            }
            if (checkPermissions)
            {
                if (!checkedValueHolder.Permissions.Equals(permissions))
                {
                    checkedValueHolder.GenerateCheckMessage(nestingLevel, key, "The permissions are not equal");
                    return(false);
                }
            }
            if (checkedValueHolder.Parent != parent)
            {
                checkedValueHolder.GenerateCheckMessage(nestingLevel, key, "The parent is wrong");
                return(false);
            }
            if (checkedValueHolder.CheckMembers(nestingLevel + 1))
            {
                checkedValueHolder.GenerateCheckMessage(nestingLevel, key, " End - True");
                return(true);
            }
            else
            {
                checkedValueHolder.GenerateCheckMessage(nestingLevel, key, " End - False");
                return(false);
            }
        }
Ejemplo n.º 27
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public BaseMessage GenerateMessage(BaseNetwork network, dynamic messageType, int sourceProcess, int sourcePort, int destProcess, int destPort, int round, int logicalClock, string subject = null, string algorithm = null)
        ///
        /// \brief Generates a message.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 19/11/2017
        ///
        /// \param network        (BaseNetwork) - The network.
        /// \param messageType    (dynamic) - Type of the message.
        /// \param sourceProcess  (int) - Source process.
        /// \param sourcePort     (int) - Source port.
        /// \param destProcess    (int) - Destination process.
        /// \param destPort       (int) - Destination port.
        /// \param round          (int) - The round.
        /// \param logicalClock   (int) - The logical clock.
        /// \param subject       (Optional)  (string) - The subject.
        /// \param algorithm     (Optional)  (string) - The algorithm.
        ///
        /// \return The message.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public BaseMessage GenerateMessage(BaseNetwork network,
                                           dynamic messageType,
                                           int sourceProcess,
                                           int sourcePort,
                                           int destProcess,
                                           int destPort,
                                           int round,
                                           int logicalClock,
                                           string subject   = null,
                                           string algorithm = null)
        {
            if (algorithm is null)
            {
                algorithm = Config.Instance[Config.Keys.SelectedAlgorithm];
            }
            return((BaseMessage)TypesUtility.CreateObjectFromTypeString(
                       GenerateNamespace(subject, algorithm) + "." + algorithm + "Message",
                       new object[] { network, messageType,
                                      sourceProcess, sourcePort, destProcess, destPort, round, logicalClock }));
        }
Ejemplo n.º 28
0
        /**********************************************************************************************//**
        * Searches for the first attribute.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \exception   EvaluationException Thrown when an Evaluation error condition occurs.
        *
        * \param   network The network.
        * \param   process The process.
        * \param   channel The channel.
        * \param   message The message.
        * \param   key     The key.
        *
        * \return  The found attribute.
        *  .
        **************************************************************************************************/

        private Attribute FindAttribute(BaseNetwork network, BaseProcess process, BaseChannel channel, BaseMessage message, dynamic key)
        {
            HostingElementTypes hostingElementType = or[brp.ork.HostingElementType];
            Attribute           attribute;

            switch (hostingElementType)
            {
            case HostingElementTypes.Network:
                if ((attribute = network.FindAttribute(TypesUtility.GetKeyToString(key))) != null)
                {
                    return(attribute);
                }
                break;

            case HostingElementTypes.Process:
                if ((attribute = process.FindAttribute(TypesUtility.GetKeyToString(key))) != null)
                {
                    return(attribute);
                }
                break;

            case HostingElementTypes.Channel:
                if ((attribute = channel.FindAttribute(TypesUtility.GetKeyToString(key))) != null)
                {
                    return(attribute);
                }
                break;

            case HostingElementTypes.Message:
                if ((attribute = message.FindAttribute(TypesUtility.GetKeyToString(key))) != null)
                {
                    return(attribute);
                }
                break;

            default:
                throw new EvaluationException("Unknown hots type : " + TypesUtility.GetKeyToString(hostingElementType));
            }
            throw new EvaluationException("There is no attribute " + TypesUtility.GetKeyToString(key) +
                                          " In " + TypesUtility.GetKeyToString(hostingElementType));
        }
Ejemplo n.º 29
0
        /**********************************************************************************************//**
        * Network element exist.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   network The network.
        * \param   process The process.
        * \param   channel The channel.
        * \param   message The message.
        *
        * \return  true if it succeeds, false if it fails.
        *  .
        **************************************************************************************************/

        private bool NetworkElementExist(BaseNetwork network, BaseProcess process, BaseChannel channel, BaseMessage message)
        {
            HostingElementTypes hostingElementType = or[brp.ork.HostingElementType];

            switch (hostingElementType)
            {
            case HostingElementTypes.Network:
                if (network == null)
                {
                    return(false);
                }
                break;

            case HostingElementTypes.Process:
                if (process == null)
                {
                    return(false);
                }
                break;

            case HostingElementTypes.Channel:
                if (channel == null)
                {
                    return(false);
                }
                break;

            case HostingElementTypes.Message:
                if (message == null)
                {
                    return(false);
                }
                break;

            default:
                return(false);
            }
            return(true);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn protected void Button_Breakpoints_Click(object sender, RoutedEventArgs e)
        ///
        /// \brief Event handler. Called by Button_Breakpoints for click events.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 04/07/2017
        ///
        /// \param sender (object) - Source of the event.
        /// \param e      (RoutedEventArgs) - Routed event information.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        protected void Button_Breakpoints_Click(object sender, RoutedEventArgs e)
        {
            BaseProcess           process      = (BaseProcess)networkElements[0];
            BaseNetwork           network      = process.Network;
            BaseChannel           channel      = null;
            BaseMessage           message      = null;
            AttributeList         messageQueue = process.or[bp.ork.MessageQ];
            List <NetworkElement> breakpoints  = new List <NetworkElement>();

            breakpoints.Add(network.op[bn.opk.Breakpoints]);
            breakpoints.Add(process.ea[bp.eak.Breakpoints]);
            if (messageQueue.Count > 0)
            {
                message = messageQueue[0];
                channel = process.IncommingChannels.First(c => c.ea[bc.eak.SourceProcess]
                                                          == message.GetHeaderField(bm.pak.SourceProcess));
                breakpoints.Add(channel.op[bn.opk.Breakpoints]);
                breakpoints.Add(message.ea[bp.eak.Breakpoints]);
            }
            //BreakpointWindow breakpointWindow = new BreakpointWindow(BreakpointWindow.ProgramStatus.Running, breakpoints, network, process, channel, message);
            //breakpointWindow.Show();
        }