scxml.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 import os
00019 import rospy
00020 
00021 from python_qt_binding.QtGui import *
00022 from python_qt_binding.QtCore import *
00023 
00024 from airbus_pyqt_extend import QtAgiCore
00025 
00026 # Load my resources file
00027 from res import R
00028 
00029 class SCXMLState(QStandardItem):
00030     
00031     ROOT_STATE   = 0
00032     SIMPLE_STATE = 1
00033     PARENT_STATE = 2
00034     
00035     NOPE = ""
00036     RECUSIVE = '-r'
00037     
00038     PENDING = 0
00039     ACTIVED = 1
00040     ERROR   = -1
00041     
00042     def __init__(self, name, type=1):
00043         QStandardItem.__init__(self, name)
00044         self.setEditable(False)
00045         
00046         self._type   = type
00047         self._name   = name 
00048         self._status = self.PENDING
00049         
00050         self.setup()
00051         
00052     def setType(self, type):
00053         self._type = type
00054         self.refresh()
00055         
00056     def type(self):
00057         return self._type
00058     
00059     def setStatus(self, status, opt=""):
00060         
00061         self._status = status
00062         
00063         if self._type == self.SIMPLE_STATE:
00064             
00065             if status == 0:
00066                 self.setIcon(R.getIconById("ic_unactive_state"))
00067             elif status == 1:
00068                 self.setIcon(R.getIconById("ic_active_state"))
00069             elif status == -1:
00070                 self.setIcon(R.getIconById("ic_pause_state"))
00071             else:
00072                 self.setIcon(R.getIconById("ic_ssm_in_error"))
00073                 
00074         elif self._type == self.PARENT_STATE:
00075             
00076             if status == 0:
00077                 self.setIcon(R.getIconById("ic_unactive_parent_state"))
00078             elif status == 1:
00079                 self.setIcon(R.getIconById("ic_active_parent_state"))
00080             elif status == -1:
00081                 self.setIcon(R.getIconById("ic_pause_parent_state"))
00082             else:
00083                 self.setIcon(R.getIconById("ic_ssm_in_error"))
00084     
00085     def status(self):
00086         return self._status
00087     
00088     def get_name(self):
00089         return self._name
00090     
00091     def refresh(self):
00092         self.setStatus(self.status())
00093         
00094     setup = refresh
00095     


airbus_ssm_plugin
Author(s): Ludovic Delval
autogenerated on Thu Jun 6 2019 17:59:30