Merge lp:~danilovesky/workcraft/trunk-bug-1335055 into lp:workcraft

Proposed by Danil Sokolov
Status: Merged
Merged at revision: 510
Proposed branch: lp:~danilovesky/workcraft/trunk-bug-1335055
Merge into: lp:workcraft
Diff against target: 81 lines (+24/-29)
1 file modified
CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java (+24/-29)
To merge this branch: bzr merge lp:~danilovesky/workcraft/trunk-bug-1335055
Reviewer Review Type Date Requested Status
Danil Sokolov Approve
Review via email: mp+224797@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Danil Sokolov (danilovesky) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java'
2--- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-04-24 20:24:53 +0000
3+++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/STGGenerator.java 2014-06-27 11:44:47 +0000
4@@ -30,12 +30,12 @@
5 import org.workcraft.plugins.circuit.VisualFunctionComponent;
6 import org.workcraft.plugins.circuit.VisualFunctionContact;
7 import org.workcraft.plugins.circuit.VisualJoint;
8+import org.workcraft.plugins.cpog.optimisation.BooleanFormula;
9 import org.workcraft.plugins.cpog.optimisation.Literal;
10 import org.workcraft.plugins.cpog.optimisation.booleanvisitors.FormulaToString;
11 import org.workcraft.plugins.cpog.optimisation.dnf.Dnf;
12 import org.workcraft.plugins.cpog.optimisation.dnf.DnfClause;
13 import org.workcraft.plugins.cpog.optimisation.dnf.DnfGenerator;
14-import org.workcraft.plugins.cpog.optimisation.expressions.BooleanOperations;
15 import org.workcraft.plugins.cpog.optimisation.expressions.DumbBooleanWorker;
16 import org.workcraft.plugins.petri.VisualPlace;
17 import org.workcraft.plugins.stg.STG;
18@@ -171,40 +171,35 @@
19 }
20 }
21
22- // generate implementation for each of the drivers
23+ // Generate implementation for each of the drivers
24 for(VisualContact c : drivers.keySet()) {
25 if (c instanceof VisualFunctionContact) {
26- // function based driver
27- Dnf set = null;
28- Dnf reset = null;
29 VisualFunctionContact contact = (VisualFunctionContact)c;
30+ // Determine I/O type of the contact
31 SignalTransition.Type ttype = SignalTransition.Type.OUTPUT;
32+ boolean comesFromEnvironment = false;
33 if (contact.getParent() instanceof VisualCircuitComponent) {
34- set = DnfGenerator.generate(contact.getFunction().getSetFunction());
35- if (contact.getFunction().getResetFunction() != null) {
36- reset = DnfGenerator.generate(contact.getFunction().getResetFunction());
37- } else {
38- BooleanOperations.worker = new DumbBooleanWorker();
39- reset = DnfGenerator.generate(BooleanOperations.worker.not(contact.getFunction().getSetFunction()));
40- }
41- if (((VisualCircuitComponent)contact.getParent()).getIsEnvironment()) {
42- ttype = SignalTransition.Type.INPUT;
43- } else if (contact.getIOType()==IOType.INPUT) {
44- ttype = SignalTransition.Type.INPUT;
45- }
46- } else {
47- set = DnfGenerator.generate(contact.getFunction().getSetFunction());
48- reset = DnfGenerator.generate(contact.getFunction().getResetFunction());
49- if (contact.getIOType()==IOType.INPUT) {
50- ttype = SignalTransition.Type.INPUT;
51- }
52- }
53- implementDriver(circuit, stg, contact, drivers, targetDrivers, set, reset, ttype);
54+ comesFromEnvironment = ((VisualCircuitComponent)contact.getParent()).getIsEnvironment();
55+ }
56+ if (comesFromEnvironment || (contact.getIOType()==IOType.INPUT)) {
57+ ttype = SignalTransition.Type.INPUT;
58+ }
59+ // Function based driver
60+ BooleanFormula setFunc = contact.getFunction().getSetFunction();
61+ BooleanFormula resetFunc = contact.getFunction().getResetFunction();
62+ if ((setFunc != null) && (resetFunc == null)) {
63+ resetFunc = new DumbBooleanWorker().not(setFunc);
64+ } else if ((setFunc == null) && (resetFunc != null)) {
65+ setFunc = new DumbBooleanWorker().not(resetFunc);
66+ }
67+ Dnf setDnf = DnfGenerator.generate(setFunc);
68+ Dnf resetDnf = DnfGenerator.generate(resetFunc);
69+ implementDriver(circuit, stg, contact, drivers, targetDrivers, setDnf, resetDnf, ttype);
70 } else {
71- // some generic driver implementation otherwise
72- Dnf set = new Dnf(new DnfClause());
73- Dnf reset = new Dnf(new DnfClause());
74- implementDriver(circuit, stg, c, drivers, targetDrivers, set, reset, SignalTransition.Type.INPUT);
75+ // Some generic driver implementation otherwise
76+ Dnf setDnf = new Dnf(new DnfClause());
77+ Dnf resetDnf = new Dnf(new DnfClause());
78+ implementDriver(circuit, stg, c, drivers, targetDrivers, setDnf, resetDnf, SignalTransition.Type.INPUT);
79 }
80 }
81 return stg;

Subscribers

People subscribed via source and target branches