Esempio n. 1
0
 internal string[] FormatInputs(IInputPortMgr inPortMgr)
 {
     string[] results = null;
     if (inPortMgr != null && inPortMgr.Count > 0)
     {
         results = new string[inPortMgr.Count];
         for (int i = 0; i < inPortMgr.Count; i++)
         {
             results[i] = string.Format("{0} ({1})", inPortMgr[i].ContentType, inPortMgr[i].IncomingStatus);
         }
     }
     else
         results = new string[0];
     return results;
 }
Esempio n. 2
0
        internal void ExecWorker(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            #region Log
            _Logger.Debug("ExecWorker() begin");
            #endregion

            Exception ex = null;

            bool isValidContinue = false;

            // --- begin execution ------------------------------------------------
            UpdateStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

            try
            {
                int numNodes = 0;
                int numOfNodesRemoved = 0;
                int kValue = -1;
                INetwork inputNet = null;
                INetwork outputNet = null;
                IFrame frame1 = null;   // Singular frame returns count of isolates removed

                // ---
                //1) Validate the parameters
                var myParamMgr = paramMgr as IExtractKthCoreParamMgr;
                isValidContinue = ValidateParams(myParamMgr, out kValue, out ex);
                if (isValidContinue && !IsCancelled)
                {
                    //2) Get the input network and validate it
                    GetInputs(inPortMgr, out inputNet, out numNodes);
                    isValidContinue = ValidateInputNetwork(inputNet, out ex);
                    if (isValidContinue && !IsCancelled)
                    {
                        //3) Validate the input network combined with the input parameters
                        isValidContinue = ValidateCombinedInputs(inputNet, kValue, out ex);
                        if (isValidContinue && !IsCancelled)
                        {
                            //4) Create and validate a copy of the input network (the copy will be modified)
                            outputNet = CopyInputNetwork(inputNet);
                            isValidContinue = ValidateNetworkCopy(inputNet, outputNet, out ex);
                            if (isValidContinue && !IsCancelled)
                            {
                                //5) Perform the kth core extraction
                                numOfNodesRemoved = ExtractKthCore(outputNet, kValue);

                                //6) Validate the output
                                isValidContinue = ValidateOutputNetwork0(outputNet, numNodes, numOfNodesRemoved, out ex);
                            }
                        }
                    }
                }

                WrapUp(isValidContinue, outputNet, outPortMgr, ex);
            }
            catch (Exception x)
            {
                // update the status if the ex is not recoverable
                ExecWorkerCleanUp(x);
            }
        }
Esempio n. 3
0
 internal override void _inPortMgr_InputAvailabilityChanged(IInputPortMgr sender, InputAvailabilityChangedEventArgs ea)
 {
     _inPortMgr_InputAvailabilityChanged_TimesCalled++;
 }
Esempio n. 4
0
 internal override void _inPortMgr_ConnectionChanging(IInputPortMgr sender, ConnectionChangingEventArgs ea)
 {
     _inPortMgr_ConnectionChanging_TimesCalled++;
 }
Esempio n. 5
0
 internal void GetInputs(IInputPortMgr inPortMgr, out INetwork network0)
 {
     IInputNetworkPort inPort0 = inPortMgr.GetPort(0) as IInputNetworkPort;
     network0 = inPort0.InputNetwork;
 }
Esempio n. 6
0
        public void Execute(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            IsAsynch = false;
            WorkerStatus = FxWorkerStatus.ExecutingSynch;
            CompletionCalled = false;
            PercentProgress = 0;

            ExecWorker(paramMgr, inPortMgr, settings, outPortMgr);
        }
Esempio n. 7
0
 public abstract void ExecuteCore(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr);
Esempio n. 8
0
        internal void PersistInPortMgr(IInputPortMgr inPortMgr, System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("InputPortMgr");
            IInputPort inPort = null;
            for (int i = 0; i < inPortMgr.Count; i++)
            {
                inPort = inPortMgr[i];
                PersistInPort(inPort, writer);
            }

            writer.WriteEndElement();
        }
Esempio n. 9
0
 public override void ExecWorker(Common.Params.IParamMgr paramMgr, IInputPortMgr inPortMgr, Common.Settings.ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
 {
     ExecuteWorkerCalled = true;
     base.ExecWorker(paramMgr, inPortMgr, settings, outPortMgr);
 }
Esempio n. 10
0
 internal void _inPortMgr_ConnectionChanging(IInputPortMgr sender, ConnectionChangingEventArgs ea)
 {
     if (sender != null)
     {
         if (ea.Action != ConnectionAction.None)
         {
             // in all cases, the element state will go to incomplete.
             SetStatus(ElementStatus.Incomplete, StatusChangeDriver.NormalTransition, null);
         }
     }
 }
Esempio n. 11
0
 internal void _inPortMgr_InputAvailabilityChanged(IInputPortMgr sender, InputAvailabilityChangedEventArgs ea)
 {
     // This handles notifications from input ports about the status of input pipes.
     if (sender != null)
     {
         UpdateStatusWithResultsFromUpstream(ea.NewStatus);
     }
 }
Esempio n. 12
0
 internal void _inPortMgr_ConnectionChanged(IInputPortMgr sender, ConnectionChangedEventArgs ea)
 {
     if (sender != null)
     {
         if (ea.Action != ConnectionAction.None)
         {
             // in all cases, the element state will go to incomplete.  All cases should be set to
             // incomplete by the _inPortMgr_ConnectionChanging handler, we do it here also for
             // consistency
             SetStatus(ElementStatus.Incomplete, StatusChangeDriver.NormalTransition, null);
         }
     }
 }
Esempio n. 13
0
        internal void _Execute( IParamMgr paramMgr, 
                                IInputPortMgr inPortMgr, 
                                ICompoundSettingsMgr settings, 
                                IOutputPortMgr outPortMgr)
        {
            SetStatus(FxStatus.Validating, StatusChangeDriver.NormalTransition, "Beginning pre-execution validations.");

            if (paramMgr != null)
            {
            //    IDataPropertiesElementParamMgr myParamMgr = paramMgr as IDataPropertiesElementParamMgr;
            //    if (myParamMgr != null)
            //    {
            //        #region Log

            //        Log(BlueSpider.Common.Constants.LogEntryTitle_Start, null);
            //        #endregion

            //        // begin execution ------------------------------------------------
            //        SetStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

            //        //1) get the input data
            //        IInputDataPort inPort = inPortMgr[0] as IInputDataPort;
            //        InputData = inPort.InputDataObj;
            //        // inform listeners that values/items at the core have been modified and to refesh the UI.
            //        OnCoreModified(new CoreModifiedEventArgs());

            //        // now set the input data as the item to be displaed in the secondary fx M
            //    }
            //    else
            //        SetStatus(FxStatus.UnInitialized, StatusChangeDriver.ValidationFailure, "ParamMgr is not of type IDataPropertiesElementParamMgr.");
            }
            else
            {
                SetStatus(FxStatus.UnInitialized, StatusChangeDriver.ValidationFailure, "ParamMgr is null.");
            }
        }
Esempio n. 14
0
 public void ExecuteAsync(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Esempio n. 15
0
        internal void GetInputs(IInputPortMgr inPortMgr, out INetwork inputNet, out int numNodes)
        {
            IInputNetworkPort inPort0 = inPortMgr[0] as IInputNetworkPort;
            inputNet = inPort0.InputNetwork;

            numNodes = inputNet.NodeCount;
        }
Esempio n. 16
0
 public void ConnectionChanging_DummyHandler(IInputPortMgr sender, ConnectionChangingEventArgs ea)
 {
     ConnectionChanging_TimesCalled++;
     RecievedEventArgs = ea;
     RecievedSender = sender;
 }
Esempio n. 17
0
        public void Execute(IParamMgr paramMgr, IInputPortMgr inPortMgr, ICompoundSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            SetStatus(FxStatus.Validating, StatusChangeDriver.NormalTransition, "Beginning pre-execution validations.");

            if (paramMgr != null)
            {
                var myParamMgr = paramMgr as IDataPropertiesElementParamMgr;
                if (myParamMgr != null)
                {
                    #region Log

                    _Logger.Info("Execute() begin");
                    #endregion

                    // begin execution ------------------------------------------------
                    SetStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

                    //1) get the input data
                    IInputDataPort inPort = inPortMgr[0] as IInputDataPort;
                    var retriever = new FramePropertyRetrieverToPlainText();
                    Properties = retriever.GetProperties(inPort.InputDataObj);
                    // inform listeners that values/items at the core have been modified and to refesh the UI.
                    OnCoreModified(new CoreModifiedEventArgs());

                    // now set the input data as the item to be displaed in the secondary fx M
                }
                else
                    SetStatus(FxStatus.UnInitialized, StatusChangeDriver.ValidationFailure, "ParamMgr is not of type IDataPropertiesElementParamMgr.");
            }
            else
            {
                SetStatus(FxStatus.UnInitialized, StatusChangeDriver.ValidationFailure, "ParamMgr is null.");
            }
        }
Esempio n. 18
0
 public void InputAvailabilityChanged_DummyHandler(IInputPortMgr sender, InputAvailabilityChangedEventArgs ea)
 {
     InputAvailabilityChanged_TimesCalled++;
     RecievedEventArgs = ea;
     RecievedSender = sender;
 }
Esempio n. 19
0
        public void ExecuteAsync(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            if (IsBusy)
            {
                CancelAsync();
                Reset();
            }

            IsAsynch = true;
            WorkerStatus = FxWorkerStatus.ExecutingAsynch;
            CompletionCalled = false;
            PercentProgress = 0;

            AsynchOp = AsyncOperationManager.CreateOperation(null);
            new ExecDelegate(ExecWorker).BeginInvoke(paramMgr, inPortMgr, settings, outPortMgr, null, null);
        }
Esempio n. 20
0
        internal void ExecWorker(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            #region Log
            _Logger.Info("ExecWorker() begin");
            #endregion

            Exception ex = null;
            bool isValidContinue = false;

            // --- begin execution ------------------------------------------------
            UpdateStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

            try
            {
                int nodeCount, edgeCount = 0;
                bool isDirected, allowCycles, allowSelfLoops, allowMultiEdges;
                string networkName = null;
                INetwork outputNet = null;

                IRandomNetGenParamMgr myParamMgr = paramMgr as IRandomNetGenParamMgr;
                isValidContinue = ValidateParams(myParamMgr, out nodeCount, out edgeCount, out isDirected, out networkName, out allowCycles, out allowSelfLoops, out allowMultiEdges, out ex);

                if (isValidContinue && !IsCancelled)
                {
                    outputNet = CreateNetwork(Guid.NewGuid(), myParamMgr);

                    isValidContinue = ValidateOutputNetwork(outputNet, nodeCount, edgeCount, isDirected, out ex);
                }

                WrapUp(isValidContinue, IsCancelled, outputNet, outPortMgr, ex);
            }
            catch (Exception x)
            {
                // update the status if the ex is not recoverable
                ExecWorkerCleanUp(x);
            }
        }
Esempio n. 21
0
        public virtual void ExecWorker(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            #region Log
            _logger.Debug("ExecWorker() begin");
            #endregion

            // --- begin execution ------------------------------------------------
            UpdateStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

            try
            {
                ExecuteCore(paramMgr, inPortMgr, settings, outPortMgr);

                //     WrapUp(IsValidContinue, outputFrame, outPortMgr, ex);   ******
                WrapUp(outPortMgr);
            }
            catch (Exception x)
            {
                _logger.ErrorException("ExecWorker() handled the exception and passed it to ExecWorkerCleanUp()", x);
                // update the status if the ex is not recoverable
                ExecWorkerCleanUp(x);
            }
        }
Esempio n. 22
0
        internal void ExecWorker(IParamMgr paramMgr, IInputPortMgr inPortMgr, ISimpleSettingsMgr settings, IOutputPortMgr outPortMgr)
        {
            #region Log
            _Logger.Info("ExecWorker() begin");
            #endregion

            Exception ex = null;
            bool isValidContinue = false;

            // --- begin execution ------------------------------------------------
            UpdateStatus(FxStatus.Executing, StatusChangeDriver.NormalTransition, "Beginning execution.");

            try
            {
                string fileName = null;
                bool exportNodeAttributes = false;
                bool exportEdgeAttributes = false;
                NetworkFileTypes fileType = NetworkFileTypes.GraphML;

                INetwork inputNet = null;

                // ---
                IExportNetworkParamMgr myParamMgr = paramMgr as IExportNetworkParamMgr;
                isValidContinue = ValidateParams(myParamMgr, out fileName, out exportNodeAttributes, out exportEdgeAttributes, out fileType, out ex);
                if (isValidContinue && !IsCancelled)
                {
                    GetInputs(inPortMgr, out inputNet);
                    // ---
                    isValidContinue = ValidateInputNetwork(inputNet, exportNodeAttributes, exportEdgeAttributes, out ex);
                    if (isValidContinue && !IsCancelled)
                    {
                        WriteFile((IBasicAdjList)inputNet, fileName, exportNodeAttributes, exportEdgeAttributes, fileType);
                    }
                }

                WrapUp(isValidContinue, fileName, outPortMgr, ex);
            }
            catch (Exception x)
            {
                // update the status if the ex is not recoverable
                ExecWorkerCleanUp(x);
            }
        }