public static string CheckControllerStatus()
        {
            Station          station          = Station.ActiveStation as Station;
            RsTask           task             = station.ActiveTask;
            RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;

            return("Controller: " + rsIrc5Controller.SystemState.ToString());
        }
Beispiel #2
0
        public RsTask CreatePlan()
        {
            var tmp = new RsTask(new List <Subtask>());

            if (u.Create(tmp))
            {
                u.Save();
                return(tmp);
            }
            return(null);
        }
        public static string LoadModuleFromFile(string moduleFilePath)
        {
            //Get Station object
            Station station = Project.ActiveProject as Station;

            //Check for existance of Module
            if (System.IO.File.Exists(moduleFilePath))
            {
                try
                {
                    RsTask task = station.ActiveTask;
                    if (task != null)
                    {
                        RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
                        ABB.Robotics.Controllers.Controller controller =
                            new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));

                        if (controller != null)
                        {
                            //Request Mastership
                            using (ABB.Robotics.Controllers.Mastership m =
                                       ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
                            {
                                if (controller.Rapid.ExecutionStatus ==
                                    ABB.Robotics.Controllers.RapidDomain.ExecutionStatus.Stopped)
                                {
                                    //Load Module if Rapid Execution State is stopped
                                    ABB.Robotics.Controllers.RapidDomain.Task vTask = controller.Rapid.GetTask(task.Name);
                                    bool loadResult = vTask.LoadModuleFromFile(moduleFilePath,
                                                                               ABB.Robotics.Controllers.RapidDomain.RapidLoadMode.Replace);
                                    Thread.Sleep(1000);
                                }
                            }
                        }
                    }
                }
                catch (ABB.Robotics.GeneralException gex)
                {
                    Logger.AddMessage(new LogMessage(gex.Message.ToString()));
                }

                catch (Exception ex)
                {
                    Logger.AddMessage(new LogMessage(ex.Message.ToString()));
                }
            }
            return("Loading module: " + moduleFilePath);
        }
Beispiel #4
0
        public bool Update(RsTask item)
        {
            CheckNull(item);

            if (IsNotProcessing())
            {
                var tmp = db.GlobalTasks.FirstOrDefault(x => x.Code == item.Code);
                if (tmp != null)
                {
                    tmp.Code    = item.Code;
                    tmp.NavProp = item.NavProp;
                    return(true);
                }
            }
            return(false);
        }
        public static string SaveRapid(string filePath)
        {
            string result = "Rapid saved: false";

            try
            {
                Station          station          = Project.ActiveProject as Station;
                RsTask           rsTask           = station.ActiveTask;
                RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)rsTask.Parent;

                ABB.Robotics.Controllers.Controller controller = new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
                Task   controllerTask = controller.Rapid.GetTask(rsTask.Name);
                string name           = controllerTask.Name;

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                filePath = filePath + @"\";
                int i = 1;

                while (Directory.Exists(filePath + "simulation-" + i))
                {
                    i++;
                }
                Directory.CreateDirectory(filePath + "simulation-" + i);
                controllerTask.SaveProgramToFile(filePath + "simulation-" + i);
                result = filePath + "simulation-" + i;
            }
            catch (ABB.Robotics.GeneralException gex)
            {
                Logger.AddMessage(new LogMessage(gex.Message.ToString()));
            }
            catch (Exception ex)
            {
                Logger.AddMessage(new LogMessage(ex.Message.ToString()));
            }
            return(result);
        }
        public static string LoadStation(string stationFilepath)
        {
            Station station = Station.Load(stationFilepath, false);

            if (station != null)
            {
                Project.ActiveProject = station;
                GraphicControl gc = new GraphicControl();
                gc.RootObject = station;
                DocumentWindow docwindow = new DocumentWindow();
                docwindow.Control = gc;
                docwindow.Caption = System.IO.Path.GetFileName("View");
                UIEnvironment.Windows.Add(docwindow);
                string test = ABB.Robotics.RobotStudio.Controllers.ControllerType.StationVC.ToString();

                Logger.AddMessage(new LogMessage(test, "MyKey"));
            }

            RsTask           task         = station.ActiveTask;
            RsIrc5Controller rscontroller = (RsIrc5Controller)task.Parent;

            return("Loading station: " + stationFilepath);
        }
        //创建虚拟信号
        public static void VirtualSignals()
        {
            #region VirtualSignals Example
            Project.UndoContext.BeginUndoStep("VirtualSignals");
            try
            {
                Station station = Project.ActiveProject as Station;
                #region ISStep1
                if (Simulator.DataRecorder.Sinks.Contains("SignalSink"))
                {
                    Simulator.DataRecorder.Sinks.Remove(Simulator.DataRecorder.Sinks["SignalSink"]);
                }
                #endregion

                #region ISStep2

                Simulator.DataRecorder.Sinks.Add(new DataRecorderSink("SignalSink"));
                #endregion
                DataRecorderSink signalSink            = (DataRecorderSink)Simulator.DataRecorder.Sinks["SignalSink"];
                BuiltInControllerSourceSignals signals = station.BuiltInDataRecorderSignals.ControllerSignals;
                signalSink.Enabled = true;
                signalSink.DataRecorder.Start();

                RsTask           task             = station.ActiveTask;
                RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
                ABB.Robotics.Controllers.Controller controller =
                    new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
                Logger.AddMessage("isVitural:" + controller.IsVirtual);

                BuiltInDataRecorderMotionSignal energy = BuiltInDataRecorderMotionSignal.TotalMotorPowerConsumption;
                BuiltInDataRecorderMotionSignal speed  = BuiltInDataRecorderMotionSignal.TCPSpeedInCurrentWorkObject;
                // DataRecorderSignal dr = signals.GetMotionSignal(new Guid(rsIrc5Controller.SystemId.ToString()), controller.MotionSystem.ActiveMechanicalUnit.Name, energy);
                RsIrc5ControllerCollection controllerlist = station.Irc5Controllers;
                foreach (RsIrc5Controller irc5Controller in controllerlist)
                {
                    DataRecorderSignal energy_consumption = signals.GetMotionSignal(new Guid(rsIrc5Controller.SystemId.ToString()), controller.MotionSystem.ActiveMechanicalUnit.Name, energy);
                    DataRecorderSignal TcpSpeed           = signals.GetMotionSignal(new Guid(rsIrc5Controller.SystemId.ToString()), controller.MotionSystem.ActiveMechanicalUnit.Name, speed);
                    if (TcpSpeed != null && !signalSink.Signals.Contains(TcpSpeed) && energy_consumption != null && !signalSink.Signals.Contains(energy_consumption))
                    {
                        signalSink.Signals.Add(energy_consumption);
                        signalSink.Signals.Add(TcpSpeed);
                        Logger.AddMessage("TCP_ID:" + TcpSpeed.Id);
                        Logger.AddMessage("TCP_DisplayPath:" + TcpSpeed.DisplayPath);
                        Logger.AddMessage("ENERGY_ID:" + energy_consumption.Id);
                        Logger.AddMessage("ENERGY_DisplayPath:" + energy_consumption.DisplayPath);
                    }
                    else
                    {
                        Logger.AddMessage("TcpSpeed为空");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.AddMessage(new LogMessage(ex.Message.ToString()));
                Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
            }
            finally
            {
                Project.UndoContext.EndUndoStep();
            }
            #endregion
        }
        public static bool LoadProgramFromFile(string filePath)
        {
            bool result = false;

            Project.UndoContext.BeginUndoStep("LoadProgramFromFile");
            //Get Station object
            #region LoadProgramFromFileStep1
            Station station = Project.ActiveProject as Station;
            #endregion

            //Check for existance of Program
            if (System.IO.File.Exists(filePath))
            {
                try
                {
                    RsTask task = station.ActiveTask;

                    if (task != null)
                    {
                        //Get RsIrc5Controller instance
                        #region LoadProgramFromFileStep2
                        RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
                        //Get virtual controller instance from  RsIrc5Controller
                        ABB.Robotics.Controllers.Controller controller =
                            new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
                        //get task
                        ABB.Robotics.Controllers.RapidDomain.Task vTask = controller.Rapid.GetTask(task.Name);
                        #endregion

                        //Request Mastership
                        #region LoadProgramFromFileStep3
                        using (ABB.Robotics.Controllers.Mastership m =
                                   ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
                        #endregion
                        {
                            if (controller.Rapid.ExecutionStatus ==
                                ABB.Robotics.Controllers.RapidDomain.ExecutionStatus.Stopped)
                            {
                                //Load Program if Rapid Execution is stopped
                                #region LoadProgramFromFileStep4
                                vTask.LoadProgramFromFile(filePath,
                                                          ABB.Robotics.Controllers.RapidDomain.RapidLoadMode.Replace);
                                #endregion
                                System.Threading.Thread.Sleep(1000);
                                result = true;
                            }
                        }
                    }
                }
                catch (ABB.Robotics.GeneralException gex)
                {
                    Logger.AddMessage(new LogMessage(gex.Message.ToString()));
                    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
                    result = false;
                }
                catch (Exception ex)
                {
                    Logger.AddMessage(new LogMessage(ex.Message.ToString()));
                    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
                    result = false;
                }
                finally
                {
                    Project.UndoContext.EndUndoStep();
                }
            }
            return(result);
        }
Beispiel #9
0
 public bool Delete(RsTask Item)
 {
     return(Delete(db.GlobalTasks, Item));
 }
Beispiel #10
0
 public bool Create(RsTask item)
 {
     return(Create(db.GlobalTasks, item));
 }