예제 #1
0
        public void OnObjectWasTakenTrigger(TrackableObject obj)
        {
            ObjectDetectionZone myZone = null;

            // find the zone that the object was last seen
            foreach (ObjectDetectionZone zone in ObjectDetectionManager.Instance.CurrentLayout.ObjectDetectionZones)
            {
                if (zone.Id == obj.LastSeenZoneId)
                {
                    // found the zone
                    myZone = zone;
                }
            }

            // check if rec is running
            if (StateManager.Instance.State == AllEnums.State.RECORD && !m_BlockUntilObjectIsBackAgain)
            {
                // create a scene for displaying the picking of the object
                Scene.Scene     autoScene = new Scene.Scene();
                Scene.SceneRect rect      = ObjectDetectionManager.Instance.createSceneRectForObjectDetectionZone(myZone, true);
                autoScene.Add(rect);

                AdaptiveScene adaptiveScene = new AdaptiveScene(autoScene, AdaptivityLevel.AdaptivityLevels.FirstOrDefault());

                EditWorkflowManager.Instance.createStep(AllEnums.PBD_Mode.OBJECT_RECOGNIZED, adaptiveScene, "Benutze Objekt-" + obj.Name, obj.Name);

                m_BlockUntilObjectIsBackAgain = true;
            }
        }
예제 #2
0
        /*public void saveToCSV(string step)
         * {
         *  var csv = new StringBuilder();
         *
         *  // check if scnes dir exists
         *  if (!Directory.Exists(ProjectConstants.STUDY_DIR))
         *  {
         *      // if not create it
         *      Directory.CreateDirectory(ProjectConstants.STUDY_DIR);
         *  }
         *  string path = ProjectConstants.STUDY_DIR+ "\\PBD_"+ this.m_CsvNameTime +".csv";
         *
         *
         *  //var newLine = string.Format("{0},{1},{2}{3}", PBDManager.Instance.StartTime.ToString(), PBDManager.Instance.EndTime.ToString(), PBDManager.Instance.DurationTime.ToString(), Environment.NewLine);
         *  long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
         *  var newLine = string.Format("{0},{1},{2}{3}", step, now, now - m_CsvNameTime, Environment.NewLine);
         *  csv.Append(newLine);
         *
         *  // File.WriteAllText( path, csv.ToString());
         *  File.AppendAllText(path, csv.ToString());
         * }*/

        public void checkAutomaticallyForAssemblyStep()
        {
            // PDB active?
            if (StateManager.Instance.State == AllEnums.State.RECORD && !m_BlockAssemblyCheck && !m_BlockUntilObjectIsBackAgain)
            {
                long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

                if (now - m_LlastWithdrawlTimestampInMillis > 10000) // was last withdrawl at least 10 seconds ago?
                {
                    if (now - m_lastWorkingTimestampInMillis > 3000) //threshold
                    {
                        //did we already take a snapshot of this period
                        if (!m_AlreadyDetectedAssembly)
                        {
                            // user might be waiting for automatically created step
                            // check if something happened
                            AssemblyZone z = AssemblyZoneManager.Instance.createAssemblyZoneFromChanges();

                            if (z != null)
                            {
                                // block assembly until next pick
                                m_BlockAssemblyCheck = true;

                                // create a scene for displaying assemblyzone and add it to workflow
                                Scene.Scene autoScene = new Scene.Scene();
                                autoScene.Add(z.getDrawable(true));
                                AdaptiveScene adaptiveScene = new AdaptiveScene(autoScene, AdaptivityLevel.AdaptivityLevels.FirstOrDefault());
                                EditWorkflowManager.Instance.createStep(AllEnums.PBD_Mode.ASSEMBLY_DONE, adaptiveScene, "Zone-" + z.Id, z.TriggerMessage);
                                AssemblyZoneManager.Instance.CurrentLayout.AssemblyZones.Add(z);
                                m_AlreadyDetectedAssembly = true;

                                // temporarilty display feedback that zone was detected
                                Scene.Scene     feedbackScene = new Scene.Scene();
                                Scene.SceneText text          = new Scene.SceneText(0.5 * KinectManager.Instance.ImageSize.Width, 0.5 * KinectManager.Instance.ImageSize.Height, "Step created", System.Windows.Media.Color.FromRgb(255, 255, 255), 10.0, new System.Windows.Media.FontFamily("Arial"));
                                feedbackScene.Add(text);
                                SceneManager.Instance.TemporaryFeedbackScene = feedbackScene;
                                SceneManager.Instance.DisplayTempFeedback    = true;
                                m_CreatedFeedbackTimestampInMillis           = now;
                            }

                            // create a new snapshot
                            if (!m_IsUserWorking)
                            {
                                AssemblyZoneManager.Instance.createDepthSnapshot();
                            }
                        }
                    }
                }
            }

            // maybe find a better place for this:
            // check if the feedback should still be displayed
            long nower = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            if (nower - m_CreatedFeedbackTimestampInMillis > m_FeedbackShow_Time)
            {
                SceneManager.Instance.DisplayTempFeedback = false;
                SceneManager.Instance.TemporaryFeedbackScene.Clear();
            }
        }
예제 #3
0
        // is called whenever box is triggered
        public void OnBoxTriggeredPBD(Box box)
        {
            // check if rec is running
            if (StateManager.Instance.State == AllEnums.State.RECORD && !m_BlockUntilObjectIsBackAgain)
            {
                AdminView.Instance.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        () =>
                {
                    // create a scene for displaying the withdrawel from the box
                    Scene.Scene autoScene = new Scene.Scene();
                    autoScene.Add(box.getDrawable(true));

                    AdaptiveScene adaptiveScene = new AdaptiveScene(autoScene, AdaptivityLevel.AdaptivityLevels.FirstOrDefault());

                    EditWorkflowManager.Instance.createStep(AllEnums.PBD_Mode.BOX_WITHDRAWEL, adaptiveScene, "Box-" + box.Id, box.TriggerMessage);

                    // temporarilly - only allow one assembly step per withdrawl
                    m_BlockAssemblyCheck = false;
                    m_LlastWithdrawlTimestampInMillis = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                }
                        )
                    );
            }
        }
예제 #4
0
        public void createEndScene(string pName, string pEndcondition)
        {
            // create a scene for displaying the withdrawel from the box
            Scene.Scene     autoScene = new Scene.Scene();
            Scene.SceneText text      = new Scene.SceneText(0.5 * KinectManager.Instance.ImageSize.Width, 0.5 * KinectManager.Instance.ImageSize.Height, "Fertig", System.Windows.Media.Color.FromRgb(255, 255, 255), 10.0, new System.Windows.Media.FontFamily("Arial"));
            autoScene.Add(text);

            AdaptiveScene adaptiveScene = new AdaptiveScene(autoScene, AdaptivityLevel.AdaptivityLevels.FirstOrDefault());

            createStep(AllEnums.PBD_Mode.END_CONDITION, adaptiveScene, pName, pEndcondition);
        }
예제 #5
0
        private void createAssemblyButton_Click(object sender, RoutedEventArgs e)
        {
            Object o = listBoxAssemblyZones.SelectedItem;

            if (o != null)
            {
                if (o is AssemblyZone)
                {
                    AssemblyZone z = (AssemblyZone)o;

                    AdaptiveScene easyScene   = new AdaptiveScene(EditWorkflowManager.Instance.getAssemblyZoneAutoScene(z), AdaptivityLevel.AdaptivityLevels.First());
                    AdaptiveScene mediumScene = new AdaptiveScene(EditWorkflowManager.Instance.getAssemblyZoneAutoScene(z), AdaptivityLevel.AdaptivityLevels.ElementAt(1));

                    var adaptiveScenes = new List <AdaptiveScene> {
                        easyScene, mediumScene
                    };

                    EditWorkflowManager.Instance.createStep(HciLab.motionEAP.InterfacesAndDataModel.AllEnums.PBD_Mode.ASSEMBLY_DONE, adaptiveScenes, "Zone-" + z.Id, z.TriggerMessage);
                }
            }
        }
예제 #6
0
        private void createBoxButton_Click(object sender, RoutedEventArgs e)
        {
            Object o = listBoxBoxes.SelectedItem;

            if (o != null)
            {
                if (o is Box)
                {
                    Box b = (Box)o;

                    AdaptiveScene easyScene   = new AdaptiveScene(EditWorkflowManager.Instance.getBoxAutoScene(b), AdaptivityLevel.AdaptivityLevels.First());
                    AdaptiveScene mediumScene = new AdaptiveScene(EditWorkflowManager.Instance.getBoxAutoScene(b), AdaptivityLevel.AdaptivityLevels.ElementAt(1));

                    var adaptiveScenes = new List <AdaptiveScene> {
                        easyScene, mediumScene
                    };

                    EditWorkflowManager.Instance.createStep(HciLab.motionEAP.InterfacesAndDataModel.AllEnums.PBD_Mode.BOX_WITHDRAWEL, adaptiveScenes, "Box-" + b.Id, b.TriggerMessage);
                }
            }
        }
예제 #7
0
        private void createFromTableButton_Click(object sender, RoutedEventArgs e)
        {
            Object o = listBoxNetworkTables.SelectedItem;

            if (o != null)
            {
                if (o is TableInfo)
                {
                    TableInfo   tableInfo = (TableInfo)o;
                    Scene.Scene autoScene;
                    autoScene = new Scene.Scene();

                    AdaptiveScene aScene = new AdaptiveScene(autoScene, AdaptivityLevel.AdaptivityLevels.FirstOrDefault());

                    WorkingStep step = new WorkingStep();
                    step.AdaptiveScenes.Add(aScene);
                    step.EndConditionObjectName = "net" + tableInfo.Id;

                    EditWorkflowManager.Instance.createStep(HciLab.motionEAP.InterfacesAndDataModel.AllEnums.PBD_Mode.NETWORK_TABLE_DONE, aScene, "NetTable-" + tableInfo.Id, step.EndConditionObjectName);
                }
            }
        }
예제 #8
0
 public void AddWorkingStepByDemonstration(AdaptiveScene adaptiveScene, string pName, string withdrawel, int sNumber, string endCondition, AllEnums.PBD_Mode mode)
 {
     AddWorkingStepByDemonstration(new List <AdaptiveScene> {
         adaptiveScene
     }, pName, withdrawel, sNumber, endCondition, mode);
 }
예제 #9
0
 public void createStep(AllEnums.PBD_Mode mode, AdaptiveScene adaptiveScene, string name, string endCondition)
 {
     createStep(mode, new List <AdaptiveScene> {
         adaptiveScene
     }, name, endCondition);
 }