transitions.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2016 Shaun Edwards
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 
00019 #include "packml_sm/transitions.h"
00020 #include "packml_sm/events.h"
00021 namespace packml_sm
00022 {
00023 
00024 StateCompleteTransition::StateCompleteTransition(PackmlState & from, PackmlState & to)
00025 {
00026   this->setTargetState(&to);
00027   from.addTransition(this);
00028   ROS_INFO_STREAM("Creating state complete transition from " <<
00029                   from.name().toStdString() << " to " << to.name().toStdString());
00030 }
00031 
00032 bool StateCompleteTransition::eventTest(QEvent *e)
00033 {
00034   if (e->type() != QEvent::Type(PACKML_STATE_COMPLETE_EVENT_TYPE))
00035     return false;
00036   return (true);
00037 }
00038 
00039 
00040 CmdTransition::CmdTransition(const CmdEnum &cmd_value, const QString &name_value,
00041               PackmlState & from, PackmlState & to) :
00042   cmd(cmd_value),
00043   name(name_value)
00044 {
00045   this->setTargetState(&to);
00046   from.addTransition(this);
00047   ROS_INFO_STREAM("Creating " << this->name.toStdString() << " transition from " <<
00048                   from.name().toStdString() << " to " << to.name().toStdString());
00049 }
00050 
00051 bool CmdTransition::eventTest(QEvent *e)
00052 {
00053 //    ROS_INFO_STREAM("Testing event type: " << e->type());
00054   if (e->type() != QEvent::Type(PACKML_CMD_EVENT_TYPE))
00055     return false;
00056   CmdEvent *se = static_cast<CmdEvent*>(e);
00057 //    ROS_INFO_STREAM("Type cmd: " << cmd << ", event cmd: " << se->cmd);
00058   return (cmd == se->cmd);
00059 }
00060 
00061 ErrorTransition::ErrorTransition(PackmlState & from, PackmlState & to)
00062 {
00063   this->setTargetState(&to);
00064   from.addTransition(this);
00065   ROS_INFO_STREAM("Creating error transition from " <<
00066                   from.name().toStdString() << " to " << to.name().toStdString());
00067 }
00068 
00069 bool ErrorTransition::eventTest(QEvent *e)
00070 {
00071   if (e->type() != QEvent::Type(PACKML_ERROR_EVENT_TYPE))
00072     return false;
00073   return (true);
00074 }
00075 
00076 }


packml_sm
Author(s): Shaun Edwards
autogenerated on Sat Jun 8 2019 20:13:34