Exemplo n.º 1
0
 private void ProcessTypeRadioButtonHandler(object sender, EventArgs e)
 {
     if (radioButtonProcessTypeParallelepiped.Checked)
     {
         _processType = ProcessTypeEnum.Parallelepiped;
     }
     else if (radioButtonProcessTypePyramid.Checked)
     {
         _processType = ProcessTypeEnum.Pyramid;
     }
     else
     {
         _processType = ProcessTypeEnum.Cone;
     }
 }
        public Log AddLog <TEntity>(TEntity entity, ProcessTypeEnum ProcessType, Guid Id)
            where TEntity : new()
        {
            string json = JsonConvert.SerializeObject(CloneWithoutClassProperty(entity));
            Log    log  = new Log();

            log.Table       = entity.GetType().Name.Split('_')[0];
            log.Data        = json;
            log.DateTime    = DateTime.Now;
            log.Id          = Guid.NewGuid();
            log.ProcessType = ProcessType;
            log.RoleId      = _uow.GetRepository <User>().Get(SessionHelper.CurrentUser.Id).Roles.FirstOrDefault().Id;
            log.RowGuid     = Id;
            log.UserId      = SessionHelper.CurrentUser.Id;

            return(_uow.GetRepository <Log>().Add(log));
        }
Exemplo n.º 3
0
        public ProcessElastic Create(ProcessTypeEnum type, string affectedObjectId, object initObject, string description)
        {
            var processId = Guid.NewGuid().ToString();
            var process   = new ProcessElastic
            {
                Id               = processId,
                Status           = (int)ProcessStatusEnum.InProgress,
                Type             = (int)type,
                Start            = DateTime.UtcNow,
                Percent          = 0.0,
                ErrorMessages    = new System.Collections.Generic.List <string>(),
                InitObject       = initObject,
                AffectedObjectId = affectedObjectId,
                Description      = description
            };

            processQuery.Index(process);
            return(process);
        }
        public void FilterMedian(Frame frame, Frame[] frames, int frameNumber, int radius, ColorModelEnum colorModel, ProcessTypeEnum processType)
        {
            var bitmapData = frame.BitmapData;
            var result     = frame.Buffer;
            var buffers    = frames.Select(item => item.Buffer).ToArray();

            if (processType == ProcessTypeEnum.Parallelepiped)
            {
                Parallel.For(0, bitmapData.Height, row => {
                    int byteIndex = row * bitmapData.Stride;
                    for (int col = 0; col < bitmapData.Width; col++)
                    {
                        int pixelIndex = byteIndex + col * 3;
                        var n          = 0;
                        double r1      = 0, g1 = 0, b1 = 0;
                        for (int fi = 0; fi < frameNumber; fi++)
                        {
                            for (int i = -radius; i <= radius; i++)
                            {
                                var row2 = ColorModel.GetValue(row + i, 0, bitmapData.Height - 1) * bitmapData.Stride;
                                for (int j = -radius; j <= radius; j++)
                                {
                                    var col2 = ColorModel.GetValue(col + j, 0, bitmapData.Width - 1) * 3;

                                    r1 += 1f / buffers[fi][row2 + col2 + 2];
                                    g1 += 1f / buffers[fi][row2 + col2 + 1];
                                    b1 += 1f / buffers[fi][row2 + col2];
                                    n++;
                                }
                            }
                        }

                        result[pixelIndex + 2] = (byte)ColorModel.GetValue((int)(n / r1), 0, 255);
                        result[pixelIndex + 1] = (byte)ColorModel.GetValue((int)(n / g1), 0, 255);
                        result[pixelIndex]     = (byte)ColorModel.GetValue((int)(n / b1), 0, 255);
                    }
                });
            }
            else
            {
                Parallel.For(0, bitmapData.Height, row =>
                {
                    int byteIndex = row * bitmapData.Stride;
                    for (int col = 0; col < bitmapData.Width; col++)
                    {
                        int pixelIndex = byteIndex + col * 3;

                        var n     = 0;
                        double r1 = 0, g1 = 0, b1 = 0;
                        for (int fi = 0; fi < frameNumber; fi++)
                        {
                            var r = radius - radius * (fi) / frameNumber;
                            for (int i = -r; i <= r; i++)
                            {
                                var row2 = ColorModel.GetValue(row + i, 0, bitmapData.Height - 1) * bitmapData.Stride;
                                for (int j = -r; j <= r; j++)
                                {
                                    var col2 = ColorModel.GetValue(col + j, 0, bitmapData.Width - 1) * 3;

                                    r1 += 1f / buffers[fi][row2 + col2 + 2];
                                    g1 += 1f / buffers[fi][row2 + col2 + 1];
                                    b1 += 1f / buffers[fi][row2 + col2];
                                    n++;
                                }
                            }
                        }


                        result[pixelIndex + 2] = (byte)ColorModel.GetValue((int)(n / r1), 0, 255);
                        result[pixelIndex + 1] = (byte)ColorModel.GetValue((int)(n / g1), 0, 255);
                        result[pixelIndex]     = (byte)ColorModel.GetValue((int)(n / b1), 0, 255);
                    }
                });
            }
        }
 public void FilterLinearAverage(Frame frame, Frame[] frames, int frameNumber, int radius, ColorModelEnum colorModel, ProcessTypeEnum processType)
 {
     Console.Write("I'm HERE!");
     if (colorModel == ColorModelEnum.Rgb)
     {
         FilterLinearAverageRgb(frame, frames, frameNumber, radius, processType);
     }
     else
     {
         FilterLinearAverageRgb(frame, frames, frameNumber, radius, processType);
     }
 }
Exemplo n.º 6
0
 private void checkForceNWC(ProcessTypeEnum processType, string sn, string curStation, string preStation)
 {
     CurrentSession.AddValue("IsForceNWC", "N");
     if (processType == ProcessTypeEnum.Product &&
         !string.IsNullOrEmpty(sn) &&
         !string.IsNullOrEmpty(preStation) &&
         !string.IsNullOrEmpty(curStation))
     {
         IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
         ForceNWCInfo cond = new ForceNWCInfo();
         cond.productID = sn;
         cond.preStation = preStation;
         cond.forceNWC = curStation;
         bool bExist = partRep.CheckExistForceNWC(cond);
         if (bExist)
         {
             CurrentSession.AddValue("IsForceNWC", "Y");
         }
     }
 }