private Dictionary <string, SwitchingEquipment> ConvertSwitchingEquipment(Container breakerContainer, Container disconnectorContainer)
        {
            Dictionary <string, SwitchingEquipment> equipment = new Dictionary <string, SwitchingEquipment>();

            foreach (var item in breakerContainer.Entities.Values)
            {
                if (item is Breaker)
                {
                    Breaker breaker = item as Breaker;
                    if (!equipment.ContainsKey(breaker.MRID))
                    {
                        equipment.Add(breaker.MRID, new SwitchingEquipment()
                        {
                            Mrid = breaker.MRID, ManipulationConut = breaker.ManipulationCount
                        });
                    }
                }
            }

            foreach (var item in disconnectorContainer.Entities.Values)
            {
                if (item is Disconnector)
                {
                    Disconnector disconnector = item as Disconnector;
                    if (!equipment.ContainsKey(disconnector.MRID))
                    {
                        equipment.Add(disconnector.MRID, new SwitchingEquipment()
                        {
                            Mrid = disconnector.MRID, ManipulationConut = disconnector.ManipulationCount
                        });
                    }
                }
            }
            return(equipment);
        }
        public void WriteTrx()
        {
            if (Breaker.IsBreakReceived())
            {
                return;
            }

            IList <RunData>    items   = RunDataListBuilder.GetFull();
            IList <ResultFile> results = Collector.Collect(items);

            if (results.Count == 0)
            {
                Console.WriteLine("No results where generated, nothing to merge to the output trx");
                return;
            }

            using (Stream stream = TrxWriter.OpenResultFile(Args))
            {
                // Console.WriteLine("Results File: " + Args.Root + "\\" + Args.Output);
                if (TrxWriter.WriteFile(results, stream) == false)
                {
                    ResultCode = 3;
                }
            }
        }
        private double getLatitude(TreeNode <NodeData> node)
        {
            if (node.Data.Type == DMSType.ACLINESEGMENT)
            {
                //+
                ACLineSegment acLineSegment = (ACLineSegment)node.Data.IdentifiedObject;
                return(acLineSegment.Latitude);
            }
            else if (node.Data.Type == DMSType.BREAKER)
            {
                //+
                Breaker breaker = (Breaker)node.Data.IdentifiedObject;
                return(breaker.Latitude);
            }
            else if (node.Data.Type == DMSType.ENEGRYSOURCE)
            {
                //+
                EnergySource source = (EnergySource)node.Data.IdentifiedObject;
                return(source.Latitude);
            }
            else if (node.Data.Type == DMSType.ENERGYCONSUMER)
            {
                //+
                EnergyConsumer consumer = (EnergyConsumer)node.Data.IdentifiedObject;
                return(consumer.Latitude);
            }
            else if (node.Data.Type == DMSType.GENERATOR)
            {
                //+
                Generator generator = (Generator)node.Data.IdentifiedObject;
                return(generator.Latitude);
            }

            return(0);
        }
Example #4
0
        public void BreaksTheRightWayWithMultipleParagraphs()
        {
            var breaker = new Breaker(@"This is the first line.

This is the second line, which is actually a paragraph, which happens to be pretty long, although it might/might not have correct punctuation.

The third line is also fairly long, and it has a bunch of CAPITALIZED FILL WORDS: BLA BLA BLA BLA BLA.");

            const int maxWidth = 50;
            var       lines    = breaker.GetLines(maxWidth).ToList();

            PrintLines(lines, maxWidth);

            Assert.That(lines, Is.EqualTo(new[]
            {
                "This is the first line.",
                "",
                "This is the second line, which is actually a",
                "paragraph, which happens to be pretty long,",
                "although it might/might not have correct",
                "punctuation.",
                "",
                "The third line is also fairly long, and it has a",
                "bunch of CAPITALIZED FILL WORDS: BLA BLA BLA BLA",
                "BLA."
            }));
        }
Example #5
0
    public void SetBreaker(Breaker newBreaker)
    {
        //If we have an existing breaker, give back the power to that one.
        //This should not happen often, but just in case we do not want someone to duplicate or lose power.
        if (breaker != null)
        {
            breaker.takenPower -= requiredPower;
            breaker.connected.Remove(this);
            breaker.CheckPower();
        }

        breaker = newBreaker;

        //Remove power from the new breaker
        //Make the breaker check if it will blackout the generator
        breaker.takenPower += requiredPower;
        breaker.connected.Add(this);
        breaker.CheckPower();

        if (breaker.hasPower)
        {
            hasPower = true;
        }

        if (tooltip != null)
        {
            tooltip.SetProperty("Has Power", hasPower.ToString());
        }
    }
Example #6
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="breaker"></param>
    private void PowerStatusReaction(Breaker breaker)
    {
        //Requesting a new soldier from the barracks
        Soldier soldier = barracks.RequestSoldier(null);

        if (soldier != null)
        {
            if (listOfBrokenBreaker.Count == 0)
            {
                listOfBrokenBreaker.Add(breaker);
            }
            else
            {
                foreach (Breaker breakers in listOfBrokenBreaker)
                {
                    if (breakers != breaker)
                    {
                        listOfBrokenBreaker.Add(breaker);
                    }
                }
            }
            // Get the position of the collider:
            Vector3 colliderPos = breaker.GetComponent <BoxCollider>().transform.position + -breaker.transform.forward * 1;
            Debug.Log(colliderPos);
            soldier.Instructions.Push(new SearchRoom(breaker.GetComponentInParent <Room>(), searchTimer, navigationTimer,
                                                     soldier));
            soldier.Instructions.Push(new Interact(breaker, soldier));
            soldier.CurrentInstruction = new Goto(colliderPos, 0, soldier);
            soldier.SpookLevel         = Soldier.ReportState.Investigating;
        }
        else
        {
            Debug.Log("No soldier was available for a PowerStatusReaction");
        }
    }
Example #7
0
        public TextReaderPort()
        {
            this.textReader = Console.In;
            this.lines = new Breaker<string>(textReader.ReadLine);

            Initialize();
        }
Example #8
0
        public TextReaderPort(string path)
            : base(path)
        {
            this.textReader = new StreamReader(Path);
            this.lines = new Breaker<string>(textReader.ReadLine);

            Initialize();
        }
Example #9
0
        public void DoesNotBreakWhenThereIsNoNeed()
        {
            var breaker = new Breaker("this is a short line");

            var lines = breaker.GetLines(100).ToList();

            Assert.That(lines, Is.EqualTo(new[] { "this is a short line" }));
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Breaker breaker = db.Breakers.Find(id);

            db.Breakers.Remove(breaker);
            db.SaveChanges();
            return(RedirectToAction("Index", new { rid = breaker.RectifierID }));
        }
Example #11
0
    private void Awake()
    {
        _subject = new Subject();

        _movement = GetComponent <Movement>();
        _breaker  = GetComponent <Breaker>();
        _anim     = GetComponent <Animator>();
    }
    private void Start()
    {
        _camera = Camera.main;

        _rb      = GetComponent <Rigidbody> ();
        _breaker = GetComponent <Breaker>();

        Time.timeScale = 1.5f;
    }
Example #13
0
        static void Main(string[] args)
        {
            System.Console.Write("S: ");
            string input = System.Console.ReadLine();

            System.Console.WriteLine("H: {0}", hasher.Hash(input));
            var breaker = new Breaker(input);

            breaker.Run(15000000);
        }
        public void Can_serialize_IEnumerable()
        {
            var dto = new Breaker
            {
                Blah = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
            };

            var from = Serialize(dto, includeXml: false);
            Assert.IsNotNull(from.Blah);
            from.PrintDump();
        }
        public void Clean()
        {
            if (Breaker.IsBreakReceived())
            {
                return;
            }

            IList <RunData> items = RunDataListBuilder.GetFull();

            Cleaner.Clean(items);
        }
        public void ChangeBreakerStatus(long GID, bool NormalOpen)
        {
            Dictionary <long, double> keyValues = new Dictionary <long, double>();

            keyValues[GID] = NormalOpen ? 1 : 0;

            Dictionary <long, IdentifiedObject> networkModel = new Dictionary <long, IdentifiedObject>();

            networkModel = CalculationEngineCache.Instance.GetNMSModel();
            Breaker breaker = (Breaker)networkModel[GID];
            Dictionary <long, DerForecastDayAhead> prod = new Dictionary <long, DerForecastDayAhead>();

            prod = CalculationEngineCache.Instance.GetAllDerForecastDayAhead();
            IslandCalculations islandCalculations = new IslandCalculations();

            if (NormalOpen)
            {
                foreach (long generatorGid in breaker.Generators)
                {
                    if (!CalculationEngineCache.Instance.TurnedOffGenerators.Contains(generatorGid))
                    {
                        CalculationEngineCache.Instance.TurnedOffGenerators.Add(generatorGid);
                        islandCalculations.GeneratorOff(generatorGid, prod);
                        CalculationEngineCache.Instance.TempProductionCached.Add(generatorGid, prod[generatorGid]);
                        prod.Remove(generatorGid);
                        if (CalculationEngineCache.Instance.TurnedOnGenerators.Contains(generatorGid))
                        {
                            CalculationEngineCache.Instance.TurnedOnGenerators.Remove(generatorGid);
                        }
                        CalculationEngineCache.Instance.SendDerForecastDayAhead();
                    }
                }
            }
            else
            {
                foreach (long generatorGid in breaker.Generators)
                {
                    if (CalculationEngineCache.Instance.TurnedOffGenerators.Contains(generatorGid))
                    {
                        CalculationEngineCache.Instance.TurnedOffGenerators.Remove(generatorGid);

                        prod.Add(generatorGid, CalculationEngineCache.Instance.TempProductionCached[generatorGid]);
                        CalculationEngineCache.Instance.TempProductionCached.Remove(generatorGid);
                        islandCalculations.GeneratorOn(generatorGid, prod);
                        if (!CalculationEngineCache.Instance.TurnedOnGenerators.Contains(generatorGid))
                        {
                            CalculationEngineCache.Instance.TurnedOnGenerators.Add(generatorGid);
                        }
                        CalculationEngineCache.Instance.SendDerForecastDayAhead();
                    }
                }
            }
            ClientSideCE.Instance.ProxyScadaListOfGenerators.SendListOfGenerators(keyValues);
        }
        public void Execute()
        {
            if (WindowsFileHelper.FolderExist(Args.Root) == false)
            {
                WindowsFileHelper.CreateFolder(Args.Root);
            }

            IRunDataEnumerator enumerator = RunDataListBuilder.GetEnumerator();

            if (enumerator.HasItems() == false)
            {
                Console.WriteLine("Test Classes where not found, nothing to run");
                return;
            }

            while (enumerator.HasItems())
            {
                if (Breaker.IsBreakReceived())
                {
                    return;
                }

                ExecutorLauncher.WaitForAnyThreadToComplete();
                while (ExecutorLauncher.HasFreeThreads())
                {
                    if (Breaker.IsBreakReceived())
                    {
                        return;
                    }

                    if (!enumerator.HasItems())
                    {
                        break;
                    }

                    RunData data = enumerator.PeekNext();
                    if (null == data)
                    {
                        // if peeked all items till the end, but none of them was valid to launch a thread (due to concurrent groups)
                        break;
                    }

                    if (ExecutorLauncher.LaunchExecutor(data))
                    {
                        // if launching succeded (group was valid)
                        enumerator.MoveNext();
                    }
                }
            }

            ExecutorLauncher.WaitForAll();
        }
Example #18
0
    private void EnermyFactory(MonsterData data, bool isPause)
    {
        Debug.Log("Enermy generate!" + data.GetPos());
        Monster tmp;

        if (data.GetMonsterType() == MonsterType.Breaker)
        {
            tmp = new Breaker(data.GetPos(), world);
            tmp.GetMonster().AddComponent <MonsterUpdate>();
            tmp.GetMonster().GetComponent <MonsterUpdate>().SetMonster(tmp);
            tmp.SetPaused(isPause);
        }
    }
Example #19
0
        public void CanBreakBetweenWords()
        {
            //                         0          10         20
            var breaker = new Breaker("this is a short line");

            var lines = breaker.GetLines(10).ToList();

            Assert.That(lines, Is.EqualTo(new[]
            {
                "this is a",
                "short line"
            }));
        }
        public void Can_serialize_IEnumerable()
        {
            var dto = new Breaker
            {
                Blah = new List <int> {
                    1, 2, 3, 4, 5, 6, 7, 8, 9
                }
            };

            var from = Serialize(dto, /*includeXml:*/ false);

            from.PrintDump();
        }
Example #21
0
        public ActionResult Edit([Bind(Include = "BreakerID,RectifierID,Amp,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29,F30")] Breaker breaker)
        {
            if (ModelState.IsValid)
            {
                db.Entry(breaker).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { rid = breaker.RectifierID }));
            }

            ViewBag.CurrentRectifierID = breaker.RectifierID;
            ViewBag.RectifierID        = new SelectList(db.Rectifiers, "RectifierID", "Serial", breaker.RectifierID);
            return(View(breaker));
        }
Example #22
0
        public void Rearrange(Column column)
        {
            var maxLineLength = column.Width - 2 * column.Padding;

            Lines = Lines
                    .SelectMany(line =>
            {
                var breaker = new Breaker(line);

                return(breaker.GetLines(maxLineLength));
            })
                    .ToArray();
        }
        public BreakerSingleDTO createSingleBreakerDTO(Breaker _breaker, VillageSmartGrid _vsg)
        {
            var dto = new BreakerSingleDTO
            {
                id          = _breaker.ID,
                BreakerID   = _breaker.BreakID,
                Connection1 = _breaker.Connector1,
                Connection2 = _breaker.Connector2,
                //FK
                VSGID = _breaker._vsgID
            };

            return(dto);
        }
Example #24
0
        private ResourceDescription CreateBreakerResourceDescription(Breaker cimBreaker)
        {
            ResourceDescription rd = null;

            if (cimBreaker != null)
            {
                long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.BREAKER, importHelper.CheckOutIndexForDMSType(DMSType.BREAKER));
                rd = new ResourceDescription(gid);
                importHelper.DefineIDMapping(cimBreaker.ID, gid);

                SCADAConverter.PopulateBreakerProperties(cimBreaker, rd, importHelper, report);
            }
            return(rd);
        }
Example #25
0
        public void Save(string userId, string corrId, string value)
        {
            GetRetryPolicy().Execute(() =>
            {
                Breaker.Execute(() =>
                {
                    Console.WriteLine("Try save to db");
                    _dataAccess.GetConnection(userId, corrId).GetDatabase().StringSet(corrId, value);
                });
            });

            Console.WriteLine("Save to cache");
            MemoryCache.Default.AddOrGetExisting(corrId, value, _cachePolicy);
        }
        public void Parse()
        {
            if (Breaker.IsBreakReceived())
            {
                return;
            }

            foreach (string assemblyPath in Args.AssemblyList)
            {
                Assembly        assembly     = WindowsFileHelper.GetAssembly(assemblyPath);
                TestAssembly    testAssembly = Parser.Parse(assembly);
                IList <RunData> items        = RunDataBuilder.Create(testAssembly);
                RunDataListBuilder.Add(items);
            }
        }
Example #27
0
    override public void ExtractInstructions(Entity entity)
    {
        instructions = new List <Instruction>();
        foreach (GameObject obj in routine)
        {
            // For each breaker to repair, add a goto, an interact, and a searchroom:
            Breaker breakerObj = obj.GetComponent <Breaker>();
            // Get the position of the collider:
            Vector3 colliderPos = breakerObj.GetComponent <Collider>().transform.position;

            instructions.Add(new Goto(colliderPos, 0, entity));
            instructions.Add(new Interact(breakerObj, entity));
            instructions.Add(new SearchRoom(breakerObj.GetComponentInParent <Room>(), searchTimer, navigationTimer, entity));
        }
    }
Example #28
0
        public void WorksWhenTooLongWordIsFirstAndItIsFollowedByAnotherWord()
        {
            var breaker = new Breaker("THISISJUSTTOOLONGTOFITONA LINE");

            const int maxWidth = 20;
            var       lines    = breaker.GetLines(maxWidth).ToList();

            PrintLines(lines, maxWidth);

            Assert.That(lines, Is.EqualTo(new[]
            {
                "THISISJUSTTOOLONGTOF",
                "ITONA LINE"
            }));
        }
Example #29
0
        // GET: Breakers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Breaker breaker = db.Breakers.Find(id);

            if (breaker == null)
            {
                return(HttpNotFound());
            }

            ViewBag.CurrentRectifierID = breaker.RectifierID;
            return(View(breaker));
        }
Example #30
0
                public static void Main(string[] args)
                {
                    long timeout = 5;

                    int    n = 80;    // number of binary variables
                    int    m = n / 5; // number of constraints
                    int    p = n / 5; // Each constraint picks p variables and requires that half of them are 1
                    Random R = new Random(1234);

                    //TAG:begin-model
                    using (Model M = new Model("SolveBinary"))
                    {
                        M.SetLogHandler(System.Console.Out);

                        //Variable x = M.Variable("x", n, Domain.InRange(0,1));
                        Variable x = M.Variable("x", n, Domain.Binary());
                        M.Objective(ObjectiveSense.Minimize, Expr.Sum(x));
                        //M.SetSolverParam("numThreads",1);

                        int[] idxs = new int[n]; for (int i = 0; i < n; ++i)
                        {
                            idxs[i] = i;
                        }
                        int[] cidxs = new int[p];

                        for (var i = 0; i < m; ++i)
                        {
                            nshuffle(R, idxs, p);
                            Array.Copy(idxs, cidxs, p);
                            M.Constraint(Expr.Sum(x.Pick(cidxs)), Domain.EqualsTo(p / 2));
                        }
                        //TAG:end-model

                        var B = new Breaker(M, timeout);

                        //TAG:begin-create-thread
                        var T = new Thread(new ThreadStart(B.run));
                        T.Start();
                        //TAG:end-create-thread
                        M.Solve();
                        B.stopThread();
                        T.Join();

                        Console.WriteLine("End.");
                    }
                }
Example #31
0
        // GET: Breakers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Breaker breaker = db.Breakers.Find(id);

            if (breaker == null)
            {
                return(HttpNotFound());
            }

            ViewBag.CurrentRectifierID = breaker.RectifierID;
            ViewBag.RectifierID        = new SelectList(db.Rectifiers, "RectifierID", "Serial", breaker.RectifierID);
            return(View(breaker));
        }
Example #32
0
        private void initializeRender(ToRenderMessage message)
        {
            string sceneBlobUri = message.SceneName;

            m_sceneID       = message.SceneId;
            m_sceneUri      = message.SceneName;
            m_mergerHandler = new MessageQueue <MergerMessage>(message.SceneId.ToString());
            m_breaker       = new Breaker(message.WriteInterval, message.HaltTime,
                                          message.RequiredSpp, m_engine, m_log);

            m_log.Info("Scene start." + DateTime.Now);
            m_scene = new Scene(sceneBlobUri, m_localDirectory);
            m_log.Info("Scene finish." + DateTime.Now);
            m_log.Info("Scene created");
            m_log.Info(m_scene.SceneDirectory);
            m_log.Info(m_scene.ScenePath);
        }
        public void Can_serialize_IEnumerable()
        {
            var dto = new Breaker
            {
                Blah = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
            };

            var from = Serialize(dto, includeXml: false);
            Assert.IsNotNull(from.Blah);
            from.PrintDump();
        }