[Avida-SVN] r1674 - in branches/uml/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Wed Jun 13 06:23:34 PDT 2007
Author: hjg
Date: 2007-06-13 09:23:34 -0400 (Wed, 13 Jun 2007)
New Revision: 1674
Modified:
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLStateDiagram.cc
branches/uml/source/main/cUMLStateDiagram.h
Log:
Added support for triggers, guards, and actions to use terminals.
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-06-13 13:23:34 UTC (rev 1674)
@@ -438,7 +438,36 @@
tInstLibEntry<tMethod>("trans-10", &cHardwareCPU::Inst_TransLab10, false,
"Change to transition label 10"),
tInstLibEntry<tMethod>("trans-11", &cHardwareCPU::Inst_TransLab11, false,
- "Change to transition label 11"),
+ "Change to transition label 11"),
+
+ tInstLibEntry<tMethod>("trig-0", &cHardwareCPU::Inst_Trigger0, false,
+ "Change to trigger 0"),
+ tInstLibEntry<tMethod>("trig-1", &cHardwareCPU::Inst_Trigger1, false,
+ "Change to trigger 1"),
+ tInstLibEntry<tMethod>("trig-2", &cHardwareCPU::Inst_Trigger2, false,
+ "Change to trigger 2"),
+ tInstLibEntry<tMethod>("trig-3", &cHardwareCPU::Inst_Trigger3, false,
+ "Change to trigger 3"),
+
+ tInstLibEntry<tMethod>("guard-0", &cHardwareCPU::Inst_Guard0, false,
+ "Change to guard 0"),
+ tInstLibEntry<tMethod>("guard-1", &cHardwareCPU::Inst_Guard1, false,
+ "Change to guard 1"),
+ tInstLibEntry<tMethod>("guard-2", &cHardwareCPU::Inst_Guard2, false,
+ "Change to guard 2"),
+ tInstLibEntry<tMethod>("guard-3", &cHardwareCPU::Inst_Guard3, false,
+ "Change to guard 3"),
+
+ tInstLibEntry<tMethod>("action-0", &cHardwareCPU::Inst_Action0, false,
+ "Change to action 0"),
+ tInstLibEntry<tMethod>("action-1", &cHardwareCPU::Inst_Action1, false,
+ "Change to action 1"),
+ tInstLibEntry<tMethod>("action-2", &cHardwareCPU::Inst_Action2, false,
+ "Change to action 2"),
+ tInstLibEntry<tMethod>("action-3", &cHardwareCPU::Inst_Action3, false,
+ "Change to action 3"),
+
+
// Placebo instructions
tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip),
@@ -4349,5 +4378,44 @@
bool cHardwareCPU::Inst_TransLab11(cAvidaContext& ctx)
{ return (organism->getStateDiagram()->absoluteJumpTransitionLabel(11)); }
+bool cHardwareCPU::Inst_Trigger0(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpTrigger(0)); }
+
+bool cHardwareCPU::Inst_Trigger1(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpTrigger(1)); }
+
+bool cHardwareCPU::Inst_Trigger2(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpTrigger(2)); }
+
+bool cHardwareCPU::Inst_Trigger3(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpTrigger(3)); }
+
+bool cHardwareCPU::Inst_Guard0(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpGuard(0)); }
+
+bool cHardwareCPU::Inst_Guard1(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpGuard(1)); }
+
+bool cHardwareCPU::Inst_Guard2(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpGuard(2)); }
+
+bool cHardwareCPU::Inst_Guard3(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpGuard(3)); }
+
+bool cHardwareCPU::Inst_Action0(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpAction(0)); }
+
+bool cHardwareCPU::Inst_Action1(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpAction(1)); }
+
+bool cHardwareCPU::Inst_Action2(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpAction(2)); }
+
+bool cHardwareCPU::Inst_Action3(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->absoluteJumpAction(3)); }
+
+
+
+
\ No newline at end of file
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-06-13 13:23:34 UTC (rev 1674)
@@ -584,6 +584,22 @@
bool Inst_TransLab10(cAvidaContext& ctx);
bool Inst_TransLab11(cAvidaContext& ctx);
+ bool Inst_Trigger0(cAvidaContext& ctx);
+ bool Inst_Trigger1(cAvidaContext& ctx);
+ bool Inst_Trigger2(cAvidaContext& ctx);
+ bool Inst_Trigger3(cAvidaContext& ctx);
+
+ bool Inst_Guard0(cAvidaContext& ctx);
+ bool Inst_Guard1(cAvidaContext& ctx);
+ bool Inst_Guard2(cAvidaContext& ctx);
+ bool Inst_Guard3(cAvidaContext& ctx);
+
+ bool Inst_Action0(cAvidaContext& ctx);
+ bool Inst_Action1(cAvidaContext& ctx);
+ bool Inst_Action2(cAvidaContext& ctx);
+ bool Inst_Action3(cAvidaContext& ctx);
+
+
};
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/main/cOrganism.cc 2007-06-13 13:23:34 UTC (rev 1674)
@@ -750,15 +750,17 @@
bool cOrganism::addTransitionTotal()
{
bool val;
- val = getStateDiagram()->addTransitionTotal(m_orig_state_index, m_dest_state_index, m_trigger_index, m_guard_index, m_action_index);
+// val = getStateDiagram()->addTransitionTotal(m_orig_state_index, m_dest_state_index, m_trigger_index, m_guard_index, m_action_index);
+ val = getStateDiagram()->addTransitionTotal();
+
- if (val) {
+/* if (val) {
m_orig_state_index = 0;
m_dest_state_index = 0;
m_trigger_index = 0;
m_action_index = 0;
m_guard_index = 0;
- }
+ } */
return val;
}
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/main/cUMLModel.cc 2007-06-13 13:23:34 UTC (rev 1674)
@@ -92,6 +92,35 @@
temp->addTransitionLabel(2, 1, 2);
temp->addTransitionLabel(3, 0, 0);
+ std::string trig_label = "ta";
+ std::string trig_operation_id = "ta";
+ temp->addTrigger(trig_label, trig_operation_id);
+
+ trig_label = "tb";
+ trig_operation_id = "tb";
+ temp->addTrigger(trig_label, trig_operation_id);
+
+ trig_label = "tc";
+ trig_operation_id = "tc";
+ temp->addTrigger(trig_label, trig_operation_id);
+
+ trig_label = "td";
+ trig_operation_id = "td";
+ temp->addTrigger(trig_label, trig_operation_id);
+
+ temp->addGuard("ga");
+ temp->addGuard("gb");
+ temp->addGuard("gc");
+ temp->addGuard("gd");
+
+ temp->addAction("aa");
+ temp->addAction("ab");
+ temp->addAction("ac");
+ temp->addAction("ad");
+
+
+
+
cUMLStateDiagram* temp1 = getStateDiagram(1);
temp1->addTransitionLabel(3, 2, 1);
temp1->addTransitionLabel(0, 1, 0);
Modified: branches/uml/source/main/cUMLStateDiagram.cc
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.cc 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/main/cUMLStateDiagram.cc 2007-06-13 13:23:34 UTC (rev 1674)
@@ -387,6 +387,57 @@
}
+bool cUMLStateDiagram::addTransitionTotal()
+{
+ if ((states.size() == 0)) {
+
+ return false;
+ }
+
+ transition trany;
+ trany.orig_state = getOrigStateIndex();
+ trany.dest_state = getDestStateIndex();
+
+
+ // Do not create transition if the origin state is unreachable.
+// Taken out on 5/22
+// if ((trany.orig_state != 0) && (states[trany.orig_state].num_incoming == 0)) {
+// return false;
+// }
+
+ // increment number of edges for a state
+ states[getOrigStateIndex()].num_outgoing += 1;
+ states[getDestStateIndex()].num_incoming += 1;
+
+
+ transition_label tl;
+ tl.trigger = getTriggerIndex();
+ tl.guard = getGuardIndex();
+ tl.action = getActionIndex();
+ trany.trans = tl;
+
+
+ // no dupes
+ if (findTrans(trany.orig_state, trany.dest_state, trany.trans.trigger, trany.trans.guard, trany.trans.action)) {
+ return false;
+ }
+
+
+ transitions.push_back(trany);
+
+
+ // reset all indices
+ orig_state_index = 0;
+ dest_state_index = 0;
+ trigger_index = 0;
+ action_index = 0;
+ guard_index = 0;
+
+ return true;
+
+}
+
+
bool cUMLStateDiagram::currTrans(int orig, int dest, int tr, int gu, int act)
{
Modified: branches/uml/source/main/cUMLStateDiagram.h
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.h 2007-06-12 20:14:14 UTC (rev 1673)
+++ branches/uml/source/main/cUMLStateDiagram.h 2007-06-13 13:23:34 UTC (rev 1674)
@@ -135,6 +135,7 @@
// bool addTransitionLabel();
bool addTransition();
bool addTransitionTotal(int, int, int, int, int);
+ bool addTransitionTotal();
bool addTrigger(std::string, std::string);
bool addGuard(std::string);
bool addAction(std::string);
More information about the Avida-cvs
mailing list