Example #1
0
        protected void displayProgress(ProcessingInfo processingInfo)
        {
            string progressText = String.Format("Stage {0} of {1}:",
                                                processingInfo.StageIndex, processingInfo.StagesCount
                                                );
            double totalPercentage = 0.0;

            if (processingInfo.StageIndex > 1)
            {
                totalPercentage = (
                    (double)(processingInfo.StageIndex - 1) / (double)processingInfo.StagesCount * 100
                    );
            }
            totalPercentage += (
                1.0 / (double)processingInfo.StagesCount * (processingInfo.Progress / 100.0) * 100.0
                );
            progressText += "\r\n   " + processingInfo.StageName;
            progressText += "\r\n" + processingInfo.InfoText.Replace(": ", ": \r\n   ");
            this.Invoke((MethodInvoker) delegate {
                this.progressText.Text          = progressText;
                this.percentageCurrentStep.Text = processingInfo.Progress.ToString("0.00") + " %";
                this.progressStep.Value         = (int)processingInfo.Progress;
                this.percentageTotal.Text       = totalPercentage.ToString("0.00") + " %";
                this.progressTotal.Value        = (int)totalPercentage;
            });
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                memoryItem = context_.CurrentFrame.Allocate(Id, false);
            }

            if (slot_.ID == (int)NodeSlotId.InReset)
            {
                memoryItem.Value = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                if ((bool)memoryItem.Value == false)
                {
                    memoryItem.Value = true;
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }

            return(info);
        }
Example #3
0
        private static void DoLoadCards(CreditCardsFilter filter)
        {
            CCSynchronizeCards graph = PXGraph.CreateInstance <CCSynchronizeCards>();

            filter.EnableCustomerPaymentDialog = false;
            graph.Filter.Current = filter;

            if (!graph.ValidateLoadCardsAction())
            {
                int newCardsCnt = graph.GetCardsAllProfiles();

                if (newCardsCnt > 0)
                {
                    foreach (CCSynchronizeCard syncCard in graph.CustomerCardPaymentData.Cache.Inserted)
                    {
                        if (syncCard.NoteID.HasValue)
                        {
                            ProcessingInfo.AppendProcessingInfo(syncCard.NoteID.Value, Messages.LoadCardCompleted);
                        }
                    }

                    try
                    {
                        graph.Persist();
                    }
                    catch
                    {
                        ProcessingInfo.ClearProcessingRows();
                        throw;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            object objCond = GetValueFromSlot((int)NodeSlotId.VarCond);

            if (objCond == null)
            {
                info.State = ActionNode.LogicState.Warning;
                info.ErrorMessage = "Please connect a variable node into the slot Condition";
                LogManager.Instance.WriteLine(LogVerbosity.Warning,
                    "{0} : Branch failed. {1}.",
                    Title, info.ErrorMessage);
            }

            if (objCond != null)
            {
                bool cond = (bool)objCond;

                if (cond == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutTrue);
                }
                else
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutFalse);
                }
            }

            return info;
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;
            object val = GetValueFromSlot((int)NodeSlotId.Message);

            if (val == null)
            {
                info.State        = ActionNode.LogicState.Warning;
                info.ErrorMessage = "Please connect a string variable node";

                LogManager.Instance.WriteLine(LogVerbosity.Warning,
                                              "{0} : No message display because no variable node connected. {1}.",
                                              Title, info.ErrorMessage);
            }
            else
            {
                LogManager.Instance.WriteLine(LogVerbosity.Info, val.ToString());
            }

            ActivateOutputLink(context_, (int)NodeSlotId.Out);

            return(info);
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            object objCond = GetValueFromSlot((int)NodeSlotId.VarCond);

            if (objCond == null)
            {
                info.State        = ActionNode.LogicState.Warning;
                info.ErrorMessage = "Please connect a variable node into the slot Condition";
                LogManager.Instance.WriteLine(LogVerbosity.Warning,
                                              "{0} : Branch failed. {1}.",
                                              Title, info.ErrorMessage);
            }

            if (objCond != null)
            {
                bool cond = (bool)objCond;

                if (cond == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutTrue);
                }
                else
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutFalse);
                }
            }

            return(info);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                memoryItem = context_.CurrentFrame.Allocate(Id, true);
            }

            if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                bool val = (bool)memoryItem.Value;
                memoryItem.Value = !((bool)memoryItem.Value);

                SetValueInSlot((int)NodeSlotId.VarOutIsA, val);

                if (val == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutA);
                }
                else
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutB);
                }
            }

            return(info);
        }
Example #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
 {
     ProcessingInfo info = new ProcessingInfo();
     info.State = ActionNode.LogicState.Ok;
     ActivateOutputLink(context_, (int)NodeSlotId.Out);
     context_.RegisterNextSequence(GetFunction(), typeof(OnEnterFunctionEvent), null);
     return info;
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;
            ActivateOutputLink(context_, (int)NodeSlotId.Out);
            context_.RegisterNextSequence(GetFunction(), typeof(OnEnterFunctionEvent), null);
            return(info);
        }
Example #10
0
 protected static void displayProgress(ProcessingInfo processingInfo)
 {
     //return;
     Console.Clear();
     Console.WriteLine(String.Format("Stage {0} of {1}: {2}",
                                     processingInfo.StageIndex, processingInfo.StagesCount, processingInfo.StageName
                                     ));
     Console.WriteLine(processingInfo.InfoText);
     Console.WriteLine(processingInfo.Progress.ToString("0.00") + " %");
 }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            object intVal = GetValueFromSlot((int)NodeSlotId.Delay);

            if (intVal == null)
            {
                info.State        = ActionNode.LogicState.Ok;
                info.ErrorMessage = "Please connect a integer variable node";

                LogManager.Instance.WriteLine(LogVerbosity.Error,
                                              "{0} : {1}.",
                                              Title, info.ErrorMessage);

                return(info);
            }

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                memoryItem = context_.CurrentFrame.Allocate(Id, TimeSpan.Zero);
            }

            TimeSpan startTime = (TimeSpan)memoryItem.Value;

            int      delay       = (int)intVal;
            double   delayDouble = ((double)delay) / 1000.0;
            TimeSpan t           = DateTime.Now.TimeOfDay.Subtract(startTime);
            double   totalSecs   = t.TotalSeconds;

            //this is the first time, so we set the current time
            if (startTime == TimeSpan.Zero)
            {
                totalSecs        = 0.0;
                startTime        = DateTime.Now.TimeOfDay;
                memoryItem.Value = startTime;
            }
            else if (totalSecs >= delayDouble)
            {
                startTime        = TimeSpan.Zero;
                memoryItem.Value = startTime;
                ActivateOutputLink(context_, (int)NodeSlotId.Out);
                CustomText = String.Empty;
                return(info);
            }

            CustomText = string.Format("Delay ({0:0.000} seconds left)", delayDouble - totalSecs);

            context_.RegisterNextExecution(GetSlotById((int)NodeSlotId.In));
            return(info);
        }
        private void saveProgress(long noOfProcessedPasswords, String nexPassword)
        {
            using (var db = new HashingContext()) {
                ProcessingInfo processingInfo = db.ProcessingInfo.FirstOrDefault();
                processingInfo.NextPassword            = nexPassword;
                processingInfo.NoOfProcessedPasswords += noOfProcessedPasswords;
                db.SaveChanges();

                NoOfProcessedPasswords = processingInfo.NoOfProcessedPasswords;
                NextPassword           = processingInfo.NextPassword;
            }
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            if (slot_.ID == (int)NodeSlotId.InReset)
            {
                m_Counter   = 0;
                m_IsInitial = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

                if (m_IsInitial == false)
                {
                    object objN = GetValueFromSlot((int)NodeSlotId.VarInN);

                    if (objN == null)
                    {
                        info.State        = ActionNode.LogicState.Warning;
                        info.ErrorMessage = "Please connect a variable node into the slot N";
                        LogManager.Instance.WriteLine(LogVerbosity.Warning,
                                                      "{0} : DoN failed. {1}.",
                                                      Title, info.ErrorMessage);
                    }

                    if (objN != null)
                    {
                        int n = (int)objN;

                        if (memoryItem == null)
                        {
                            memoryItem = context_.CurrentFrame.Allocate(Id, n);
                        }

                        memoryItem.Value = n;
                    }

                    m_IsInitial = true;
                }

                if (m_Counter < (int)memoryItem.Value)
                {
                    m_Counter++;
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }

            return(info);
        }
Example #14
0
        // spara antalet lösenord och nästa lösenord till databasen
        // med hjälp av entityFramwork.
        private void saveProgress(long noOfProcessedPasswords, String nexPassword)
        {
            // using kommer att rensa i ordning efter db när scopet är klart
            using (var db = new HashingContext()) {
                ProcessingInfo processingInfo = db.ProcessingInfo.FirstOrDefault();
                processingInfo.NextPassword            = nexPassword;
                processingInfo.NoOfProcessedPasswords += noOfProcessedPasswords;
                db.SaveChanges();

                NoOfProcessedPasswords = processingInfo.NoOfProcessedPasswords;
                NextPassword           = processingInfo.NextPassword;
            }
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            //call script with input nodes
            List <ScriptSlotData> list = new List <ScriptSlotData>(m_ScriptElement.InputCount);

            foreach (NodeSlot slot in this.SlotVariableIn)
            {
                if (slot is NodeSlotVar)
                {
                    NodeSlotVar varSlot = slot as NodeSlotVar;
                    list.Add(new ScriptSlotData(varSlot.Text, varSlot.ID, GetValueFromSlot(varSlot.ID)));
                }
            }
            ScriptSlotDataCollection parameters = new ScriptSlotDataCollection(list);

            list.Clear();

            //
            foreach (NodeSlot slot in this.SlotVariableOut)
            {
                if (slot is NodeSlotVar)
                {
                    NodeSlotVar varSlot = slot as NodeSlotVar;
                    list.Add(new ScriptSlotData(varSlot.Text, varSlot.ID, GetValueFromSlot(varSlot.ID)));
                }
            }
            ScriptSlotDataCollection returnVals = new ScriptSlotDataCollection(list);

            list.Clear();

            if (m_ScriptElement.Run(parameters, returnVals) == false)
            {
                info.ErrorMessage = "Some errors in the execution of the script";
                info.State        = ActionNode.LogicState.Error;
                return(info);
            }

            //set output slot value
            foreach (ScriptSlotData s in returnVals.List)
            {
                SetValueInSlot(s.ID, s.Value);
            }

            ActivateOutputLink(context_, (int)NodeSlotId.Out);

            return(info);
        }
Example #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            //TODO
            //Set output variable

            // the nodes executed after the node CallFunctionNode are already registered
            // we only have to delete the subsequence
            context_.RemoveLastSequence();

            return info;
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            //TODO
            //Set output variable

            // the nodes executed after the node CallFunctionNode are already registered
            // we only have to delete the subsequence
            context_.RemoveLastSequence();

            return(info);
        }
Example #18
0
 protected Processor()
 {
     this.Store             = new Store();
     this.Extractor         = new Extractor(this);
     this.Preparer          = new Preparer(this);
     this.JsDuck            = new JsDuck(this);
     this.Reader            = new Reader(this);
     this.Consolidator      = new Consolidator(this);
     this.SpecialsGenerator = new SpecialsGenerator(this);
     this.TypesChecker      = new TypesChecker(this);
     this.ResultsGenerator  = new ResultsGenerator(this);
     this.Exceptions        = new List <Exception>();
     this.JsDuckErrors      = new List <string>();
     this.ProcessingInfo    = new ProcessingInfo();
 }
Example #19
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            //call script with input nodes
            List<ScriptSlotData> list = new List<ScriptSlotData>(m_ScriptElement.InputCount);
            foreach (NodeSlot slot in this.SlotVariableIn)
            {
                if (slot is NodeSlotVar)
                {
                    NodeSlotVar varSlot = slot as NodeSlotVar;
                    list.Add(new ScriptSlotData(varSlot.Text, varSlot.ID, GetValueFromSlot(varSlot.ID)));
                }
            }
            ScriptSlotDataCollection parameters = new ScriptSlotDataCollection(list);
            list.Clear();

            //
            foreach (NodeSlot slot in this.SlotVariableOut)
            {
                if (slot is NodeSlotVar)
                {
                    NodeSlotVar varSlot = slot as NodeSlotVar;
                    list.Add(new ScriptSlotData(varSlot.Text, varSlot.ID, GetValueFromSlot(varSlot.ID)));
                }
            }
            ScriptSlotDataCollection returnVals = new ScriptSlotDataCollection(list);
            list.Clear();

            if (m_ScriptElement.Run(parameters, returnVals) == false)
            {
                info.ErrorMessage = "Some errors in the execution of the script";
                info.State = ActionNode.LogicState.Error;
                return info;
            }

            //set output slot value
            foreach (ScriptSlotData s in returnVals.List)
            {
                SetValueInSlot(s.ID, s.Value);
            }

            ActivateOutputLink(context_, (int)NodeSlotId.Out);

            return info;
        }
        public void AddData(double time, Frame frame1, Frame frame2)
        {
            Invoke((MethodInvoker) delegate {
                ProcessingInfo processingInfo = new ProcessingInfo(time, frame1, frame2);
                _frameNumber++;
                chartTime.Series[0].Points.AddXY(_frameNumber, processingInfo.Time);
                chartMetrics.Series[0].Points.AddXY(_frameNumber, processingInfo.Mse);
                chartMetrics.Series[1].Points.AddXY(_frameNumber, processingInfo.Psnr);
                chartMetrics.Series[2].Points.AddXY(_frameNumber, processingInfo.Bfm);

                if (textBoxLog.Text.Length == 0)
                {
                    textBoxLog.Text += @"Frame; Time (Sec); MSE; PSNR; MBF" + Environment.NewLine;
                }
                textBoxLog.Text += string.Format("{0}; {1:F7}; {2}; {3}; {4};{5}",
                                                 _frameNumber, processingInfo.Time,
                                                 processingInfo.Mse, processingInfo.Psnr, processingInfo.Bfm, Environment.NewLine);
            });
        }
        public ImageProcessorProviderTester()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: Add any initialization after the InitializeComponent call
            _robot = new Robot();
            _robot.SetID("RI1000-0014");
            _robot.SetName("RI1000-0014");

            _processingInfo = new ProcessingInfo();
            _processingInfo.SetPlateID("441300240121");
            _processingInfo.SetImagingID("441300240121-071706-124312");
            _processingInfo.SetProfileID("profile1");
            _processingInfo.SetRegionID("region1");
            _processingInfo.SetRegionType(Formulatrix.Integrations.ImagerLink.Imaging.RegionType.Overview);
            _processingInfo.SetWellNumber(1);
            _processingInfo.SetDropNumber(2);
        }
 public void init(String defaultPassword)
 {
     using (var db = new HashingContext()) {
         ProcessingInfo processingInfo = db.ProcessingInfo.FirstOrDefault();
         if (processingInfo == null)
         {
             db.Add(new ProcessingInfo {
                 NextPassword = defaultPassword, NoOfProcessedPasswords = 0
             });
             db.SaveChanges();
             NextPassword           = defaultPassword;
             NoOfProcessedPasswords = 0;
         }
         else
         {
             NextPassword           = processingInfo.NextPassword;
             NoOfProcessedPasswords = processingInfo.NoOfProcessedPasswords;
         }
     }
 }
Example #23
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                object a     = GetValueFromSlot((int)NodeSlotId.VarInStartClosed);
                bool   state = a != null ? (bool)a : true;
                memoryItem = context_.CurrentFrame.Allocate(Id, state);
            }

            bool val = (bool)memoryItem.Value;

            if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                if (val == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }
            else if (slot_.ID == (int)NodeSlotId.InOpen)
            {
                memoryItem.Value = true;
            }
            else if (slot_.ID == (int)NodeSlotId.InClose)
            {
                memoryItem.Value = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InToggle)
            {
                memoryItem.Value = !val;
            }

            return(info);
        }
 //  Hämta nästa lösenord från databasen. Fins det inget sparat lösenord
 //  så kommer defaultPassword att användas.
 public void Init(String defaultPassword)
 {
     // using kommer att rensa i ordning efter db när scopet är klart
     using (var db = new HashingContext())
     {
         ProcessingInfo processingInfo = db.ProcessingInfo.FirstOrDefault();
         if (processingInfo == null)
         {
             db.Add(new ProcessingInfo {
                 NextPassword = defaultPassword, NoOfProcessedPasswords = 0
             });
             db.SaveChanges();
             NextPassword           = defaultPassword;
             NoOfProcessedPasswords = 0;
         }
         else
         {
             NextPassword           = processingInfo.NextPassword;
             NoOfProcessedPasswords = processingInfo.NoOfProcessedPasswords;
         }
     }
 }
Example #25
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;
            object val = GetValueFromSlot((int)NodeSlotId.Message);

            if (val == null)
            {
                info.State = ActionNode.LogicState.Warning;
                info.ErrorMessage = "Please connect a string variable node";

                LogManager.Instance.WriteLine(LogVerbosity.Warning,
                    "{0} : No message display because no variable node connected. {1}.",
                    Title, info.ErrorMessage);
            }
            else
            {
                LogManager.Instance.WriteLine(LogVerbosity.Info, val.ToString());
            }

            ActivateOutputLink(context_, (int)NodeSlotId.Out);

            return info;
        }
Example #26
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            if (slot_.ID == (int)NodeSlotId.InReset)
            {
                m_Counter = 0;
                m_IsInitial = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

                if (m_IsInitial == false)
                {
                    object objN = GetValueFromSlot((int)NodeSlotId.VarInN);

                    if (objN == null)
                    {
                        info.State = ActionNode.LogicState.Warning;
                        info.ErrorMessage = "Please connect a variable node into the slot N";
                        LogManager.Instance.WriteLine(LogVerbosity.Warning,
                            "{0} : DoN failed. {1}.",
                            Title, info.ErrorMessage);
                    }

                    if (objN != null)
                    {
                        int n = (int)objN;

                        if (memoryItem == null)
                        {
                            memoryItem = context_.CurrentFrame.Allocate(Id, n);
                        }

                        memoryItem.Value = n;
                    }

                    m_IsInitial = true;
                }

                if (m_Counter < (int)memoryItem.Value)
                {
                    m_Counter++;
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }

            return info;
        }
Example #27
0
 protected void processedHandler(bool success, ProcessingInfo processingInfo)
 {
     this.Invoke((MethodInvoker) delegate {
         List <string> jsDuckErrors = this.displayJsDuckErrors.Checked
                                 ? this.processor.GetJsDuckErrors()
                                 : new List <string>();
         List <Exception> exceptions = this.processor.GetExceptions();
         StringBuilder textContentSb = new StringBuilder();
         string title = (success || processingInfo.StageIndex == processingInfo.StagesCount)
                                 ? ((jsDuckErrors.Count == 0 && exceptions.Count == 0)
                                         ? "Processing successfully finished."
                                         : "Processing finished with following errors:")
                                 : "Processing can NOT start due to those errors:";
         if (success && jsDuckErrors.Count == 0 && exceptions.Count == 0)
         {
             MessageBox.Show(title, "Finished");
         }
         else
         {
             if (jsDuckErrors.Count > 0)
             {
                 textContentSb.AppendLine(title);
                 textContentSb.AppendLine("");
                 foreach (string jsDuckError in jsDuckErrors)
                 {
                     textContentSb.AppendLine("");
                     textContentSb.AppendLine("\t" + jsDuckError);
                 }
             }
             if (exceptions.Count > 0)
             {
                 textContentSb.AppendLine(title);
                 textContentSb.AppendLine("");
                 foreach (Exception ex in exceptions)
                 {
                     if (ex is ArgumentException)
                     {
                         textContentSb.AppendLine("");
                         textContentSb.AppendLine("\t" + ex.Message);
                     }
                     else
                     {
                         textContentSb.AppendLine("");
                         textContentSb.AppendLine(
                             Desharp.Debug.Dump(ex, new Desharp.DumpOptions {
                             SourceLocation = true,
                             Return         = true,
                         }).Replace("\t", "   ")
                             );
                     }
                 }
             }
             int width      = 800;
             int height     = 600;
             Form msgWindow = new Form()
             {
                 Width           = width,
                 Height          = height,
                 FormBorderStyle = FormBorderStyle.FixedDialog,
                 Text            = success ? "Finished with errors." : "Not started due to errors.",
                 StartPosition   = FormStartPosition.CenterScreen
             };
             TextBox textContent = new TextBox()
             {
                 Left      = 20,
                 Top       = 20,
                 Width     = width - 60,
                 Height    = height - 60 - 30 - 30,
                 Text      = textContentSb.ToString().Replace("\n", "\r\n"),
                 BackColor = this.BackColor,
                 Multiline = true,
                 ReadOnly  = true,
             };
             Button confirmBtn = new Button()
             {
                 Text         = "Ok",
                 Top          = height - 60 - 30,
                 Left         = (width / 2) - (100 / 2),
                 Width        = 100,
                 DialogResult = DialogResult.OK
             };
             confirmBtn.Click += (sender, e) => {
                 msgWindow.Close();
             };
             msgWindow.Controls.Add(textContent);
             textContent.DeselectAll();
             msgWindow.Controls.Add(confirmBtn);
             msgWindow.AcceptButton = confirmBtn;
             msgWindow.ShowDialog();
         }
         this.setControlsEnabled(true);
         this.initProcessorInstance();
         this.checkInputs();
     });
 }
Example #28
0
        private async Task RunPipeline(PipelineInstance instance)
        {
            await Task.Yield();

            RunningPipelines.Add(instance);

            mLogger?.Trace($"Processing line id:{instance.Id} started for blueprint '{instance.Name}'");
            instance.State = "Initialized";

            Package package = await instance.Blueprint.QueueProvider.ReceiveNextMessageAsync();

            while (package != null)
            {
                if (package == Package.Fake)
                {
                    mLogger?.Trace($"line:{instance.Id} | Cool down before next attempt to get next package.");
                    await mWaitEvent.WaitAsync();
                }
                else
                {
                    package.Profile.Dequeued = DateTime.Now;
                    instance.Blueprint.Counters.IncrementIn();

                    mLogger?.Trace($"line:{instance.Id} | Incomming package with id:{package.Id}.");
                    instance.State = "Processing";

                    var transferingContext = new TransferingContext
                    {
                        Id = $"{package.Id}:{instance.Id}:{Guid.NewGuid().ToString("n")}",
                        ProcessingStart = DateTime.Now
                    };
                    transferingContext.Meta.Add("ID", transferingContext.Id);
                    transferingContext.Meta.Add("Package label", package.Label);
                    transferingContext.Meta.Add("Package ID", package.Id);

                    try
                    {
                        if (!RunningContextes.TryAdd(transferingContext.Id, transferingContext))
                        {
                            mLogger?.Warn($"Unable to register transfering context with id:{transferingContext.Id}");
                        }

                        await instance.Blueprint.Pipeline.Process(transferingContext, package.Load, package.Id,
                                                                  Guid.NewGuid().ToString("n"),
                                                                  new Headers(package.Headers));

                        if (transferingContext.Exception != null)
                        {
                            instance.Blueprint.Counters.Errors++;
                            mLogger?.Error(
                                $"Exception occured during processing on line id:{instance.Id}. Exception: {transferingContext.Exception}");
                        }

                        if (package.ExternalDeliverBoxId != null)
                        {
                            mWaitBoxes[package.ExternalDeliverBoxId.Value].SetValue(
                                transferingContext.FinalUnitContext.Unit,
                                transferingContext.Exception);
                        }
                    }
                    catch (Exception e)
                    {
                        instance.Blueprint.Counters.Errors++;

                        if (package.ExternalDeliverBoxId != null)
                        {
                            mWaitBoxes[package.ExternalDeliverBoxId.Value].SetValue(null, e);
                        }
                    }
                    finally
                    {
                        ProcessingInfo info = new ProcessingInfo
                        {
                            StepName = "FINALIZATION",
                            Started  = DateTime.Now
                        };
                        transferingContext.ProcessingHistory.Push(info);

                        foreach (var finalizer in instance.Blueprint.Finalizers)
                        {
                            try
                            {
                                finalizer(package, transferingContext);
                            }
                            catch (Exception ex)
                            {
                                mLogger?.Error(
                                    $"Error occured during finalizing package with id:{package.Id}. Exception: {ex}");
                            }
                        }
                        info.Finished = DateTime.Now;

                        if (!RunningContextes.TryRemove(transferingContext.Id, out transferingContext))
                        {
                            mLogger?.Warn($"Unable to unregister transfering context with id:{transferingContext.Id}");
                        }

                        instance.Blueprint.Counters.IncrementOut();

                        package.Profile.ProcessFinished = DateTime.Now;
                        instance.PackagesProfiles.Push(package.Profile);
                        package.Profile = null;
                    }
                }

                instance.State = "WaitForMessage";
                mLogger?.Trace($"line:{instance.Id} | Wait for package.");
                package = await instance.Blueprint.QueueProvider.ReceiveNextMessageAsync();
            }

            instance.State = "Finished";
            mLogger?.Trace($"Processing line id:{instance.Id} finished for blueprint '{instance.Name}'");
        }
Example #29
0
        public ProcessResultWindow(ProcessingInfo info)
        {
            InitializeComponent();

            DataContext = info;
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();

            info.State = ActionNode.LogicState.Ok;

            if (slot_.ID == (int)NodeSlotId.In)
            {
                int firstIndex = 0, lastIndex = -1;

                #region first index

                object objFirstIndex = GetValueFromSlot((int)NodeSlotId.VarInFirstIndex);

                if (objFirstIndex == null)
                {
                    info.State        = ActionNode.LogicState.Warning;
                    info.ErrorMessage = "Please connect a variable node into the slot First Index";
                    LogManager.Instance.WriteLine(LogVerbosity.Warning,
                                                  "{0} : For Loop failed. {1}.",
                                                  Title, info.ErrorMessage);
                    return(info);
                }

                if (objFirstIndex != null)
                {
                    firstIndex = (int)objFirstIndex;
                }

                #endregion // first index

                #region last index

                object objLastIndex = GetValueFromSlot((int)NodeSlotId.VarInLastIndex);

                if (objLastIndex == null)
                {
                    info.State        = ActionNode.LogicState.Warning;
                    info.ErrorMessage = "Please connect a variable node into the slot Last Index";
                    LogManager.Instance.WriteLine(LogVerbosity.Warning,
                                                  "{0} : For Loop failed. {1}.",
                                                  Title, info.ErrorMessage);
                    return(info);
                }

                if (objLastIndex != null)
                {
                    lastIndex = (int)objLastIndex;
                }

                #endregion last index

                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

                if (memoryItem == null)
                {
                    memoryItem = context_.CurrentFrame.Allocate(Id, new ForLoopNodeInfo {
                        Counter = firstIndex, IsWaitingLoopBody = false
                    });
                }

                ForLoopNodeInfo memoryInfo = (ForLoopNodeInfo)memoryItem.Value;

                if (memoryInfo.IsWaitingLoopBody == false)
                {
                    SetValueInSlot((int)NodeSlotId.VarOutIndex, memoryInfo.Counter);

                    if (memoryInfo.Counter <= lastIndex)
                    {
                        memoryInfo.IsWaitingLoopBody = true;
                        memoryInfo.Counter++;
                        // register again this node in order to active itself
                        // after the sequence activated by the loop body slot
                        // is finished
                        memoryInfo.Step  = context_.RegisterNextExecution(GetSlotById((int)NodeSlotId.In));
                        memoryItem.Value = memoryInfo;

                        ProcessingContext newContext = context_.PushNewContext();
                        newContext.Finished += new EventHandler(OnLoopBodyFinished);
                        ActivateOutputLink(newContext, (int)NodeSlotId.OutLoop);
                    }
                    else
                    {
                        context_.CurrentFrame.Deallocate(Id);
                        ActivateOutputLink(context_, (int)NodeSlotId.OutCompleted);
                    }
                }
            }
            else if (slot_.ID == (int)NodeSlotId.InBreak)
            {
                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);
                ForLoopNodeInfo memoryInfo = (ForLoopNodeInfo)memoryItem.Value;
                context_.RemoveExecution(context_, memoryInfo.Step);
                context_.CurrentFrame.Deallocate(Id);
                ActivateOutputLink(context_, (int)NodeSlotId.OutCompleted);
            }

            return(info);
        }
Example #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                memoryItem = context_.CurrentFrame.Allocate(Id, true);
            }

            if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                bool val = (bool)memoryItem.Value;
                memoryItem.Value = !((bool)memoryItem.Value);

                SetValueInSlot((int)NodeSlotId.VarOutIsA, val);

                if (val == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutA);
                }
                else
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.OutB);
                }
            }

            return info;
        }
Example #32
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            if (slot_.ID == (int)NodeSlotId.In)
            {
                int firstIndex = 0, lastIndex = -1;

                #region first index

                object objFirstIndex = GetValueFromSlot((int)NodeSlotId.VarInFirstIndex);

                if (objFirstIndex == null)
                {
                    info.State = ActionNode.LogicState.Warning;
                    info.ErrorMessage = "Please connect a variable node into the slot First Index";
                    LogManager.Instance.WriteLine(LogVerbosity.Warning,
                        "{0} : For Loop failed. {1}.",
                        Title, info.ErrorMessage);
                    return info;
                }

                if (objFirstIndex != null)
                {
                    firstIndex = (int)objFirstIndex;
                }

                #endregion // first index

                #region last index

                object objLastIndex = GetValueFromSlot((int)NodeSlotId.VarInLastIndex);

                if (objLastIndex == null)
                {
                    info.State = ActionNode.LogicState.Warning;
                    info.ErrorMessage = "Please connect a variable node into the slot Last Index";
                    LogManager.Instance.WriteLine(LogVerbosity.Warning,
                        "{0} : For Loop failed. {1}.",
                        Title, info.ErrorMessage);
                    return info;
                }

                if (objLastIndex != null)
                {
                    lastIndex = (int)objLastIndex;
                }

                #endregion last index

                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

                if (memoryItem == null)
                {
                    memoryItem = context_.CurrentFrame.Allocate(Id, new ForLoopNodeInfo { Counter = firstIndex, IsWaitingLoopBody = false });
                }

                ForLoopNodeInfo memoryInfo = (ForLoopNodeInfo)memoryItem.Value;

                if (memoryInfo.IsWaitingLoopBody == false)
                {
                    SetValueInSlot((int)NodeSlotId.VarOutIndex, memoryInfo.Counter);

                    if (memoryInfo.Counter <= lastIndex)
                    {
                        memoryInfo.IsWaitingLoopBody = true;
                        memoryInfo.Counter++;
                        // register again this node in order to active itself
                        // after the sequence activated by the loop body slot
                        // is finished
                        memoryInfo.Step = context_.RegisterNextExecution(GetSlotById((int)NodeSlotId.In));
                        memoryItem.Value = memoryInfo;

                        ProcessingContext newContext = context_.PushNewContext();
                        newContext.Finished += new EventHandler(OnLoopBodyFinished);
                        ActivateOutputLink(newContext, (int)NodeSlotId.OutLoop);
                    }
                    else
                    {
                        context_.CurrentFrame.Deallocate(Id);
                        ActivateOutputLink(context_, (int)NodeSlotId.OutCompleted);
                    }
                }
            }
            else if (slot_.ID == (int)NodeSlotId.InBreak)
            {
                MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);
                ForLoopNodeInfo memoryInfo = (ForLoopNodeInfo)memoryItem.Value;
                context_.RemoveExecution(context_, memoryInfo.Step);
                context_.CurrentFrame.Deallocate(Id);
                ActivateOutputLink(context_, (int)NodeSlotId.OutCompleted);
            }

            return info;
        }
Example #33
0
        private static void PrepareProcessor(Processor current, object obj)
        {
            var nextAction = current.Next?.ProcessAction;

            if (current.IsAsync)
            {
                var nextAsyncProcessor = ProcessingElement.NextAsyncProcessor(current.Next);
                current.ProcessTask = async(tctx, octx) =>
                {
                    ProcessingInfo info = new ProcessingInfo
                    {
                        Started  = DateTime.Now,
                        StepName = !string.IsNullOrEmpty(current.Name) ? current.Name : current.Method.Name
                    };

                    tctx.ProcessingHistory.Push(info);

                    try
                    {
                        var parameters = PrepareParameters(current, octx, tctx);

                        if (current.Method.ReturnType.IsGenericType &&
                            current.Method.ReturnType.GetGenericTypeDefinition() == typeof(Task <>))
                        {
                            octx.Unit =
                                await Wrap(current.Method.Invoke(obj ?? current.ConcreteObject, parameters.ToArray()));
                        }

                        if (current.Method.ReturnType == typeof(Task))
                        {
                            await(Task) current.Method.Invoke(obj ?? current.ConcreteObject, parameters.ToArray());
                        }

                        info.Finished = DateTime.Now;

                        nextAction?.Invoke(tctx, octx);

                        if (nextAsyncProcessor != null)
                        {
                            await nextAsyncProcessor.ProcessTask(tctx, octx);
                        }
                    }
                    catch (PipelineProcessingException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        Exception resultException = ProcessException(current, tctx, e, octx, obj, true);
                        throw new PipelineProcessingException(resultException);
                    }
                };
            }
            else
            {
                current.ProcessAction = (tctx, octx) =>
                {
                    ProcessingInfo info = new ProcessingInfo
                    {
                        Started  = DateTime.Now,
                        StepName = !string.IsNullOrEmpty(current.Name) ? current.Name : current.Method.Name
                    };

                    tctx.ProcessingHistory.Push(info);

                    try
                    {
                        var parameters = PrepareParameters(current, octx, tctx);

                        if (current.Method.ReturnType == typeof(void))
                        {
                            current.Method.Invoke(obj ?? current.ConcreteObject, parameters.ToArray());
                        }
                        else
                        {
                            octx.Unit = current.Method.Invoke(obj ?? current.ConcreteObject, parameters.ToArray());
                        }

                        info.Finished = DateTime.Now;

                        nextAction?.Invoke(tctx, octx);
                    }
                    catch (PipelineProcessingException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        var resultException = ProcessException(current, tctx, e, octx, obj, true);
                        if (resultException != null)
                        {
                            throw new PipelineProcessingException(resultException);
                        }
                    }
                    finally
                    {
                        info.Finished = DateTime.Now;
                    }
                };
            }
        }
Example #34
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                object a = GetValueFromSlot((int)NodeSlotId.VarInStartClosed);
                bool state = a != null ? (bool)a : true;
                memoryItem = context_.CurrentFrame.Allocate(Id, state);
            }

            bool val = (bool)memoryItem.Value;

            if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                if (val == true)
                {
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }
            else if (slot_.ID == (int)NodeSlotId.InOpen)
            {
                memoryItem.Value = true;
            }
            else if (slot_.ID == (int)NodeSlotId.InClose)
            {
                memoryItem.Value = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InToggle)
            {
                memoryItem.Value = !val;
            }

            return info;
        }
Example #35
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ProcessingInfo ActivateLogic(ProcessingContext context_, NodeSlot slot_)
        {
            ProcessingInfo info = new ProcessingInfo();
            info.State = ActionNode.LogicState.Ok;

            MemoryStackItem memoryItem = context_.CurrentFrame.GetValueFromID(Id);

            if (memoryItem == null)
            {
                memoryItem = context_.CurrentFrame.Allocate(Id, false);
            }

            if (slot_.ID == (int)NodeSlotId.InReset)
            {
                memoryItem.Value = false;
            }
            else if (slot_.ID == (int)NodeSlotId.InEnter)
            {
                if ((bool)memoryItem.Value == false)
                {
                    memoryItem.Value = true;
                    ActivateOutputLink(context_, (int)NodeSlotId.Out);
                }
            }

            return info;
        }
Example #36
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 /// <param name="slot"></param>
 /// <returns></returns>
 public ProcessingInfo Activate(ProcessingContext context, NodeSlot slot)
 {
     State = ActivateLogic(context, slot);
     return State;
 }