public MonitoredSystem(string name, int id, string mac, string fqdn, MappingState state, DateTime?resetDate, ExtendedObservableCollection <Plugin> plugins,
                               string platform, bool isAvailable, int ouID, DateTime?lastUpdate)
            : base(id, name, fqdn)
        {
            Intialize();
            this.MAC             = mac;
            this.State           = state;
            this.ResetDate       = resetDate;
            this.Plugins         = plugins;
            this.CurrentPlatform = platform;
            this.IsAvailable     = isAvailable;
            this.OuID            = ouID;
            this.LastUpdate      = lastUpdate;
            MonitoredSystemState ms = LayoutManager.Instance.GetMSState(id);

            if (ms == null)
            {
                var l = (from p in DataModel.Instance.LevelDefinitions
                         orderby p.Level ascending
                         select p.LevelID).First();
                LayoutManager.Instance.SetMSState(ID, l);
            }
            else
            {
                foreach (var p in ms.ShownPlugins)
                {
                    LayoutManager.Instance.SetMSState(ID, ms.Level, p, true);
                }
            }
        }
        /// <summary>
        /// Gets the mapping state for an indicator-value from a specific monitored systems.
        /// </summary>
        /// <param name="monitoredSystemID">The ID of the system that aquired the value.</param>
        /// <param name="pluginName">The plugin that aquired the value.</param>
        /// <param name="indicator">The indicator that aquired the value.</param>
        /// <param name="value">The indicator-value itself.</param>
        /// <returns>The appropiate mapping state.</returns>
        public MappingState GetMetricValue(int monitoredSystemID, string pluginName, string indicator, string value)
        {
            MappingState state = MappingState.OK;

            #region Metric Statements

            string statementWarning;
            string statementCritical;

            this.GetMetric(monitoredSystemID, pluginName, indicator, out statementWarning, out statementCritical);

            #endregion

            // Is the state Warning?
            if (statementWarning != "" && RegExUtility.Match(value, statementWarning))
            {
                state = MappingState.Warning;
            }

            // Is the state Critical?
            if (statementCritical != "" && RegExUtility.Match(value, statementCritical))
            {
                state = MappingState.Critical;
            }

            return(state);
        }
Example #3
0
        public void editMap(string value)
        {
            value = value.ToLower();
            switch (value)
            {
            case COMMAND_NONE:
                this.mappingState = MappingState.None;
                break;

            case COMMAND_PLAYER_POSITION:
                this.mappingState = MappingState.PlayerStart;
                break;

            case COMMAND_DEVIL:
                this.mappingState = MappingState.Monster;
                this.type         = MonsterType.Devil;
                break;

            case COMMAND_YETI:
                this.mappingState = MappingState.Monster;
                this.type         = MonsterType.Yeti;
                break;

            /*case COMMAND_MONSTER:
             *      this.mappingState = MappingState.Monster;
             *      break;*/
            default:
                Console.WriteLine("Failed to recognize your command, try using the editMapHelp()");
                break;
            }
            Console.WriteLine("Mapping: " + this.mappingState.ToString());
        }
Example #4
0
    /// <summary>
    /// Checks for the undo button and jump back one action of go back to player mapping.
    /// </summary>
    /// <returns>true if the undo button was pressed; else false.</returns>
    bool UndoButton()
    {
        if (Input.GetAxisRaw("Cancel") == 1)
        {
            if (!buttonIsBeingHeld)
            {
                buttonIsBeingHeld = true;
                buttonToMap--;
                if (buttonToMap == -1)
                {
                    map = MappingState.PLAYER;
                    cursor.ShowAtWorld(
                        mainMenu.InputInfoDisplays[playerToMap].UndoKey(),
                        inputMethodTextSize.x,
                        inputMethodTextSize.y);
                }
                else
                {
                    inputManager.characterInputs[playerToMap].UnmapButton(buttonToMap);
                    cursor.ShowAtWorld(
                        mainMenu.InputInfoDisplays[playerToMap].UndoKey() + Vector3.left * 0.1f,
                        actionTextSize.x,
                        actionTextSize.y);
                }
                return(true);
            }
        }

        return(false);
    }
 public IndicatorValue(object value, DataType dataType, DateTime timestamp, MappingState mappingState)
 {
     this.Value        = value;
     this.DataType     = dataType;
     this.Timestamp    = timestamp;
     this.MappingState = mappingState;
 }
Example #6
0
        private void UpdateMappingState()
        {
            if (MappedNode != null)
            {
                MappingState = MappingState.Resolved;
                return;
            }

            switch (_unmappedFiles.Count)
            {
            case 0:
                MappingState = MappingState.Unmapped;
                return;

            case 1:
                if (_unmappedProjectOutputs.Count == 1)
                {
                    MappingState = MappingState.Unique;
                    return;
                }
                break;
            }

            MappingState = MappingState.Ambiguous;
        }
Example #7
0
 public void SetState(MappingState state)
 {
     this.parent.safeRepository.SetMappingState(
         this.mappingDataObject.MappingId,
         this.parent.operationExecutive.CurrentOperation,
         (int)state);
     this.mappingDataObject.State = state;
 }
        public MapEditor()
        {
            this.mappingState = MappingState.None;
#if WINDOWS
#if DEBUG
            ScriptManager.getInstance().registerObject(this, "editor");
#endif
#endif
        }
Example #9
0
 private void SetMappingState(IMapping <TEntity> mapping, MappingState state)
 {
     using (IOperationScope scope = this.operationExecutive.CreateOperation())
     {
         mapping.SetState(state);
         this.eventDispatcher.OrphanMappingProcessed(
             new OrphanMappingProcessedArgs(
                 this.operationExecutive.CurrentOperation.TimeStamp));
         scope.Complete();
     }
 }
 public WorkstationInfo(int ID, string name, MappingState state, string fqdn, bool isAvailable, Platform currentOS, string macAddress, int ouID, DateTime?lastUpdate)
 {
     this.ID          = ID;
     this.Name        = name;
     this.State       = state;
     this.FQDN        = fqdn;
     this.IsAvailable = isAvailable;
     this.CurrentOS   = currentOS.ToString();
     this.MacAddress  = macAddress;
     this.OuID        = ouID;
     this.LastUpdate  = lastUpdate;
 }
Example #11
0
        /// <summary>
        /// Updates the mapping state of a monitored system, if the mapping duration of this monitored system is out of date
        /// </summary>
        /// <param name="monitoredSystemID">MAC Adress of the monitored system to update</param>
        public void UpdateMappingState(string monitoredSystemMac)
        {
            try
            {
                using (var dataContext = DataContextFactory.CreateDataContext())
                {
                    var          monitoredSystem = PrecompiledQueries.GetMonitoredSystemByMAC(dataContext, monitoredSystemMac);
                    MappingState newState        = MappingState.Critical;

                    // Critical state
                    if (monitoredSystem.CriticalEnd != null)
                    {
                        if (monitoredSystem.CriticalEnd < DateTime.Now.Ticks)
                        {
                            newState = MappingState.Warning;
                        }
                    }
                    else
                    {
                        newState = MappingState.Warning;
                    }


                    // Warning state
                    if (monitoredSystem.WarningEnd != null)
                    {
                        if (monitoredSystem.WarningEnd < DateTime.Now.Ticks)
                        {
                            newState = MappingState.OK;
                        }
                    }
                    else
                    {
                        newState = MappingState.OK;
                    }


                    // Maintenance state
                    if (PrecompiledQueries.GetMonitoredSystemMaintenanceModeByID(dataContext, monitoredSystem.ID))
                    {
                        newState = MappingState.Maintenance;
                    }

                    monitoredSystem.Status = (byte)newState;
                    dataContext.SubmitChanges();
                }
            }
            catch (Exception e)
            {
                Logger.Instance.WriteEntry("ValueManager_UpdateMappingState: Can't update the mapping of workstation (MAC: " + monitoredSystemMac + "). " + e.StackTrace, LogType.Exception);
            }
        }
Example #12
0
 /// <summary>
 /// Loops over all available buttons to see if any one should be assigned.
 /// We assign the button to the current buttonToMap and increment.
 /// </summary>
 /// <returns>true if any button was assigned; else false.</returns>
 bool ButtonCheck()
 {
     // Loop over all buttons
     for (int i = 0; i < inputManager.allKeys.Length; i++)
     {
         // If one was pressed
         if (Input.GetKeyDown(inputManager.allKeys[i]))
         {
             // And it hasn't been assigned yet
             if (!inputManager.isButtonMapped(inputManager.allKeys[i]))
             {
                 // We map it, increment buttonToMap and update cursor
                 inputManager.characterInputs[playerToMap].MapButton(
                     buttonToMap,
                     inputManager.allKeys[i]
                     );
                 buttonToMap++;
                 if (buttonToMap == 4)
                 {
                     mainMenu.InputInfoDisplays[playerToMap].ShowNextKey();
                     playerToMap++;
                     map = MappingState.PLAYER;
                     if (playerToMap != GameManager.Instance.NumPlayers)
                     {
                         cursor.ShowAtWorld(
                             mainMenu.InputInfoDisplays[playerToMap].ShowNextKey(),
                             inputMethodTextSize.x,
                             inputMethodTextSize.y);
                     }
                     else
                     {
                         cursor.enabled = false;
                         mainMenu.SetTitleToReadyPrompt(
                             InputManager.Instance.characterInputs[0].inputMode == InputMode.GAMEPAD);
                     }
                 }
                 else
                 {
                     cursor.ShowAtWorld(
                         mainMenu.InputInfoDisplays[playerToMap].ShowNextKey() + Vector3.left * 0.1f,
                         actionTextSize.x,
                         actionTextSize.y);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
Example #13
0
 /// <summary>
 /// Checks if we pressed return and moves to buttonUI if that happened.
 /// </summary>
 /// <returns>true if we pressed return on the keyboard; false otherwise.</returns>
 bool PlayerCheckKeyboard()
 {
     if (Input.GetKeyDown(KeyCode.Return))
     {
         inputManager.characterInputs[playerToMap].MapPlayer(InputMode.KEYBOARD, -1);
         map         = MappingState.BUTTON;
         buttonToMap = 0;
         cursor.ShowAtWorld(
             mainMenu.InputInfoDisplays[playerToMap].ShowNextKey() + Vector3.left * 0.1f,
             actionTextSize.x,
             actionTextSize.y);
         return(true);
     }
     return(false);
 }
Example #14
0
 public MappingDataObject(
     Guid mappingId,
     EntityIdentifier sourceSystemEntityId,
     EntityIdentifier destinationSystemEntityId,
     string serializedEntityHash,
     MappingOrigin origin,
     MappingState state)
 {
     this.MappingId                 = mappingId;
     this.SourceSystemEntityId      = sourceSystemEntityId;
     this.DestinationSystemEntityId = destinationSystemEntityId;
     this.SerializedEntityHash      = serializedEntityHash;
     this.Origin = origin;
     this.State  = state;
 }
        public void editMap(string value)
        {
            value = value.ToLower();
            MappingState oldState = this.mappingState;

            switch (value)
            {
            case COMMAND_NONE:
                this.mappingState = MappingState.None;
                break;

            case COMMAND_PLAYER_POSITION:
                this.mappingState = MappingState.PlayerStart;
                break;

            case COMMAND_GUARD_POSITION:
                this.mappingState = MappingState.GuardPosition;
                break;

            case COMMAND_GUARD_ENTRY:
                this.mappingState = MappingState.GuardEntry;
                break;

            case COMMAND_TREASURE:
                this.mappingState = MappingState.Treasure;
                break;

            case COMMAND_WAY_POINTS:
                this.mappingState = MappingState.WayPoint;
                break;

            case COMMAND_DUMPSTER:
                this.mappingState = MappingState.Dumpster;
                break;

            default:
                Console.WriteLine("Failed to recognize your command, try using the editMapHelp()");
                break;
            }
            if (this.mappingState != oldState)
            {
                ScriptManager.getInstance().log("Changed to edit: " + this.mappingState.ToString());
            }
            Console.WriteLine("Mapping: " + this.mappingState.ToString());
        }
Example #16
0
        /// <summary>
        /// Empty constructor of this indicator.
        /// Generally it shouldn't be used.
        /// </summary>
        //public Indicator()
        //{
        //    Initialize();
        //}

        /// <summary>
        /// This constructor sets all attributes of this indicator.
        /// Generally this constructor should be used for the instantiation of a new indicator object.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pluginName"></param>
        /// <param name="filterStatement"></param>
        /// <param name="updateInterval"></param>
        /// <param name="storageDuration"></param>
        /// <param name="mappingDuration"></param>
        /// <param name="dataType"></param>
        /// <param name="statementWarning"></param>
        /// <param name="statementCritical"></param>
        /// <param name="indicatorValues"></param>
        public Indicator(string name, string pluginName, string filterStatement, TimeSpan updateInterval, TimeSpan storageDuration, TimeSpan mappingDuration,
                         DataType dataType, string statementWarning, string statementCritical, ExtendedObservableCollection <IndicatorValue> indicatorValues, string monitoredSystemMAC, MappingState indicatorMapping)
        {
            Initialize();

            this.Name               = name;
            this.PluginName         = pluginName;
            this.FilterStatement    = filterStatement;
            this.UpdateInterval     = updateInterval;
            this.StorageDuration    = storageDuration;
            this.MappingDuration    = mappingDuration;
            this.DataType           = dataType;
            this.StatementWarning   = statementWarning;
            this.StatementCritical  = statementCritical;
            this.IndicatorValues    = indicatorValues;
            this.MonitoredSystemMAC = monitoredSystemMAC;
            this.indicatorMapping   = indicatorMapping;
        }
Example #17
0
    /// <summary>
    /// Enable cursor and begin assigning procedure.
    /// </summary>
    public void Activate()
    {
        for (int i = 0; i < 4; i++)
        {
            inputManager.characterInputs[i].UnmapPlayer();
        }

        playerToMap       = 0;
        buttonToMap       = -1;
        buttonIsBeingHeld = true;

        map = MappingState.PLAYER;

        cursor.ShowAtWorld(
            mainMenu.InputInfoDisplays[0].ShowNextKey(),
            inputMethodTextSize.x,
            inputMethodTextSize.y);
        cursor.enabled = true;
    }
Example #18
0
 private void ProcessOrphanMappings(IEnumerable <IMapping <TEntity> > orphanMappings)
 {
     IMapping <TEntity>[] mappings = orphanMappings.ToArray();
     if (mappings.Length > 0)
     {
         this.eventDispatcher.OrphanMappingsProcessing(
             new OrphanMappingsProcessingArgs(
                 mappings.Length, this.parameterProvider.OrphanMappingBehavior));
         MappingState targetState =
             this
             .parameterProvider
             .OrphanMappingBehavior == OrphanMappingBehavior.Deactivate
                 ? MappingState.Deactivated
                 : MappingState.Removed;
         foreach (IMapping <TEntity> mapping in mappings)
         {
             this.SetMappingState(mapping, targetState);
         }
     }
 }
Example #19
0
        public void UpdateMapper(int iterations)
        {
            Room.Tile[,] tiles = _tiles;
            for (int i = 0; i < iterations; i++)
            {
                switch (state)
                {
                case MappingState.FindingEdges:
                {
                    Room.Tile             tile    = tiles[_x, _y];
                    Room.Tile.TerrainType terrain = tile.Terrain;
                    Room.SlopeDirection   slope   = (terrain == Room.Tile.TerrainType.Slope) ? room.IdentifySlope(_x, _y) : Room.SlopeDirection.Broken;

                    if (HasEdge(_x, _y, Direction.Left) && !HasEdge(_x - 1, _y, Direction.Right))
                    {
                        AddEdge(_x, _y, Direction.Left);
                    }
                    if (HasEdge(_x, _y, Direction.Down) && !HasEdge(_x, _y - 1, Direction.Up))
                    {
                        AddEdge(_x, _y, Direction.Down);
                    }
                    if (HasEdge(_x, _y, Direction.Right) && !HasEdge(_x + 1, _y, Direction.Left))
                    {
                        AddEdge(_x, _y, Direction.Right);
                    }
                    if (HasEdge(_x, _y, Direction.Up) && !HasEdge(_x, _y + 1, Direction.Down))
                    {
                        AddEdge(_x, _y, Direction.Up);
                    }

                    if (slope != Room.SlopeDirection.Broken)
                    {
                        AddSlopeEdge(_x, _y, slope);
                    }

                    _x++;
                    if (_x >= room.TileWidth)
                    {
                        _x = 0;
                        _y++;
                        if (_y >= room.TileHeight)
                        {
                            _y    = corners.Count;
                            state = MappingState.DuplicatingPoints;
                        }
                    }
                }
                break;

                case MappingState.DuplicatingPoints:
                {
                    corners.Add(corners[_x]);
                    _x++;
                    if (_x >= _y)
                    {
                        state = MappingState.Done;
                        _x    = 0;
                        _y    = 0;
                    }
                }
                break;

                case MappingState.Done:
                    return;
                }
            }
        }
        public void GetMetricValueTest()
        {
            #region Test 1 Warining

            MetricManager_Accessor target = new MetricManager_Accessor();

            int monitoredSystem = 85;
            string pluginName = "RAM";
            string indicator = "Load";
            string value = "95";
            MappingState expected = MISD.Core.States.MappingState.Warning;

            MappingState actual;
            actual = target.GetMetricValue(monitoredSystem, pluginName, indicator, value);
            Assert.AreEqual(expected, actual);

            #endregion

            #region Test 2 Critical

            target = new MetricManager_Accessor();

            monitoredSystem = 85;
            pluginName = "RAM";
            indicator = "Load";
            value = "100";
            expected = MISD.Core.States.MappingState.Critical;

            actual = target.GetMetricValue(monitoredSystem, pluginName, indicator, value);
            Assert.AreEqual(expected, actual);

            #endregion

            #region Test 3 OK
            target = new MetricManager_Accessor();

            monitoredSystem = 85;
            pluginName = "RAM";
            indicator = "Load";
            value = "89";
            expected = MISD.Core.States.MappingState.OK;

            actual = target.GetMetricValue(monitoredSystem, pluginName, indicator, value);
            Assert.AreEqual(expected, actual);

            #endregion

            #region Test 4 OK
            target = new MetricManager_Accessor();

            monitoredSystem = 85;
            pluginName = "RAM";
            indicator = "Load";
            value = "1";
            expected = MISD.Core.States.MappingState.OK;

            actual = target.GetMetricValue(monitoredSystem, pluginName, indicator, value);
            Assert.AreEqual(expected, actual);

            #endregion
        }
Example #21
0
 public override string ToString()
 {
     return(MappingState?.ToString() ?? base.ToString());
 }