Пример #1
0
        /// <summary>
        /// Gets the active mapping entry. The active mapping entry is the one the user has most
        /// recently selected in the PluginEditorView. This method is similar to the
        /// ActiveGraphableEntry property in PluginEditorView.
        /// </summary>
        public IMappingEntry GetActiveMappingCopy()
        {
            if (this.ActiveGraphableEntryId < 0)
            {
                return(null);
            }
            else
            {
                IMappingEntry activeEntry;
                IBaseGraphableMappingManager activeEntryManager;
                if (this.ActiveGraphableEntryType == GraphableEntryType.Mapping)
                {
                    activeEntryManager = this.mappingManager;
                }
                else if (this.ActiveGraphableEntryType == GraphableEntryType.Generator)
                {
                    activeEntryManager = this.genMappingManager;
                }
                else
                {
                    //Unknown MappingType
                    Debug.Assert(false);
                    return(null);
                }

                IReturnStatus <IMappingEntry> getCopyRetStatus =
                    activeEntryManager.GetCopyOfMappingEntryById(this.ActiveGraphableEntryId);
                Debug.Assert(getCopyRetStatus.IsValid);

                activeEntry = getCopyRetStatus.Value;

                return(activeEntry);
            }
        }
Пример #2
0
        public void CreateAndAddEntryFromGenInfo_TimeBasedGenInfo_CorrectlyInitializedInRangeType()
        {
            GeneratorMappingManager genMgr        = Factory_GeneratorMappingManager_Default();
            GenEntryConfigInfo      genConfigInfo = Factory_GenEntryConfigInfo_Default();

            genConfigInfo.PeriodType = GenPeriodType.Time;

            int newId = genMgr.CreateAndAddEntryFromGenInfo(genConfigInfo);

            IReturnStatus <IGeneratorMappingEntry> getCopyRetStatus = genMgr.GetCopyOfMappingEntryById(newId);

            Assert.IsTrue(getCopyRetStatus.IsValid);
            Assert.AreEqual(MssMsgType.RelTimePeriodPos, getCopyRetStatus.Value.InMssMsgRange.MsgType);
        }
        /// <summary>
        /// Returns a list of MappingEntries from the GeneratorMappingEntries stored in this
        /// GeneratorMappingManager. A GeneratorMappingEntry will be in this list if
        /// <paramref name="inputMsg"/> falls into it's input range. Due the the nature of the
        /// GeneratorMappingEntries stored in this GeneratorMappingManager, the returned list will
        /// only ever contain a maximum of one element. This is because a GeneratorMappingEntry's
        /// input range will only accept one message that has a unique id.
        /// </summary>
        public override IEnumerable <IGeneratorMappingEntry> GetCopiesOfMappingEntriesForMsg(MssMsg inputMsg)
        {
            lock (MssComponentHub.criticalSectioinLock)
            {
                List <IGeneratorMappingEntry> associatedEntryList = new List <IGeneratorMappingEntry>();
                if (inputMsg.Type == MssMsgType.RelBarPeriodPos || inputMsg.Type == MssMsgType.RelTimePeriodPos)
                {
                    IReturnStatus <IGeneratorMappingEntry> associatedEntryCopy =
                        GetCopyOfMappingEntryById((int)inputMsg.Data1);
                    if (associatedEntryCopy.IsValid)
                    {
                        associatedEntryList.Add(associatedEntryCopy.Value);
                    }
                }

                return(associatedEntryList);
            }
        }
Пример #4
0
        public void CreateAndAddEntryFromGenInfo_DefaultGenInfo_CorrectlyInitializedOutRange()
        {
            GeneratorMappingManager genMgr        = Factory_GeneratorMappingManager_Default();
            GenEntryConfigInfo      genConfigInfo = Factory_GenEntryConfigInfo_Default();

            int newId = genMgr.CreateAndAddEntryFromGenInfo(genConfigInfo);

            IReturnStatus <IGeneratorMappingEntry> getCopyRetStatus = genMgr.GetCopyOfMappingEntryById(newId);

            Assert.IsTrue(getCopyRetStatus.IsValid);
            IGeneratorMappingEntry genEntry = getCopyRetStatus.Value;

            Assert.AreEqual(genEntry.Id, genEntry.OutMssMsgRange.Data1RangeBottom);
            Assert.AreEqual(genEntry.Id, genEntry.OutMssMsgRange.Data1RangeTop);
            Assert.AreEqual(MssMsgUtil.UNUSED_MSS_MSG_DATA,
                            genEntry.OutMssMsgRange.Data2RangeBottom);
            Assert.AreEqual(MssMsgUtil.UNUSED_MSS_MSG_DATA,
                            genEntry.OutMssMsgRange.Data2RangeTop);
            Assert.AreEqual(MssMsgType.Generator, genEntry.OutMssMsgRange.MsgType);
        }
Пример #5
0
 public ReturnStatusTest(ITestOutputHelper logger, ServerFixture <ReturnStatus> server)
 {
     this.logger = logger;
     this.client = server.CreateClient <IReturnStatus>();
 }
        protected override void WriteToResponseBody(HttpContext context)
        {
            //Write the collected data into the response
            XDocument doc = new XDocument();

            XElement packet = new XElement("packet");

            doc.Add(packet);
            XElement status;

            IReturnStatus acc_status = ReturnStatus.Combine(_ProcessingContextCollection.ProcessingContexts.Select(pc => pc.ReturnModel.Status));

            if (true) //TODO:
            {
                status = new XElement("status");
                packet.Add(status);
                status.Add(new XAttribute("issuccessful", acc_status.IsSuccessful?1:0));

                // TODO: We construct the status section from the a combination of all statuses of all RetirnModels (which are just 1 for now)
                if (acc_status.StatusResults != null && acc_status.StatusResults.Count > 0)
                {
                    status.Add(new XElement("messages", new XCData(JsonConvert.SerializeObject(acc_status.StatusResults))));
                }

                status.Add(new XElement("message", new XCData(acc_status.StatusResults.Aggregate("", (a, sr) => (sr.StatusResultType == EStatusResult.StatusResultError)?a + sr.Message: a))));
            }

            foreach (IProcessingContext processingContext in _ProcessingContextCollection.ProcessingContexts)
            {
                if (processingContext.ReturnModel.Data != null)
                {
                    JsonSerializerSettings settings = new JsonSerializerSettings();
                    settings.Error = (serializer, err) =>
                    {
                        err.ErrorContext.Handled = true;
                    };

                    settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

                    packet.Add(new XElement("data", new XCData(JsonConvert.SerializeObject(processingContext.ReturnModel.Data, settings))));
                }

                if (processingContext.ReturnModel.Views != null)
                {
                    XElement views = new XElement("views");
                    foreach (var item in processingContext.ReturnModel.Views)
                    {
                        var v = new XElement(item.Key, new XCData(item.Value.Content));
                        v.Add(new XAttribute("sid", item.Value.SId));
                        views.Add(v);
                    }
                    //views.Add(new XElement("normal", new XCData(processingContext.View)));
                    packet.Add(views);
                }

                if (processingContext.ReturnModel.LookupData != null)
                {
                    packet.Add(new XElement("lookups", new XCData(JsonConvert.SerializeObject(processingContext.ReturnModel.LookupData))));
                }
            }

            context.Response.WriteAsync(doc.ToString()).Wait();
        }