Пример #1
0
        /// <summary>
        /// Handels a LayoutChangeCommand in this LayoutManager.
        /// Commands are only handled if Layouter is defined and isPowerwall is true!
        /// </summary>
        /// <param name="cmd">The incomming LayoutChangeCommand</param>
        private void IncommingLayoutChanges(LayoutChangeCommand cmd)
        {
            if (ConfigClass.IsPowerwall)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    switch (cmd.CommandType)
                    {
                    case LayoutCommand.MS_STATE_CHANGED:
                        CurrentLayout.SetState(cmd.ID, cmd.MSState());
                        break;

                    case LayoutCommand.OU_STATE_CHANGED:
                        CurrentLayout.SetState(cmd.ID, cmd.OUState());
                        break;

                    case LayoutCommand.MS_VALUE_CHANGED:
                        CurrentLayout.SetValue(cmd.ID, false, cmd.MSValue());
                        break;

                    case LayoutCommand.OU_VALUE_CHANGED:
                        CurrentLayout.SetValue(cmd.ID, true, cmd.OUValue());
                        break;

                    case LayoutCommand.PROPERTY_CHANGED:
                        CurrentLayout.SetProperty(cmd.Property().Key, cmd.Property().Value);
                        break;

                    case LayoutCommand.UPDATE_COMPLETE_LAYOUT:
                        CurrentLayout = cmd.GetLayout();
                        break;

                    case LayoutCommand.PRIORITY_LIST_CHANGED:
                        this.PluginPriority = cmd.GetPluginPriorityList();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("LayoutCommand is not known!");
                    }
                });
            }
            else
            {
                throw new ArgumentOutOfRangeException("We are no Powerwall or no Layouter is defined!");
            }
        }
Пример #2
0
        /// <summary>
        /// Sends a LayoutChangeCommand to the Powerwalls if this COmputer isOperatorPC.
        /// </summary>
        /// <param name="layoutChangeCommand">A Layout change command</param>
        private void SendLayoutChanges(LayoutChangeCommand layoutChangeCommand, bool sendFullLayout = false)
        {
            if (ConfigClass.IsOperator && tcpConnection != null)
            {
                if (sendFullLayout)
                {
                    var l = new LayoutChangeCommand(this.CurrentLayout);
                    tcpConnection.Send(l);
                    counterLayoutChanges = 0;
                }
                else
                {
                    counterLayoutChanges++;
                    tcpConnection.Send(layoutChangeCommand);

                    if (counterLayoutChanges > 10)
                    {
                        var l = new LayoutChangeCommand(this.CurrentLayout);
                        tcpConnection.Send(l);
                        counterLayoutChanges = 0;
                    }
                }
            }
        }