//============================================================================== // // Copyright (c) 2002- // Authors: // * Dave Parker (University of Oxford) // //------------------------------------------------------------------------------ // // This file is part of PRISM. // // PRISM is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // PRISM is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with PRISM; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //============================================================================== package pta; import java.util.Map; public class LocZone { public int loc; public Zone zone; public LocZone(int loc, Zone zone) { this.loc = loc; this.zone = zone; } /** * Do combined discrete *then* time post operation wrt. an edge. * Note: time part includes c-closure. */ public void post(Edge edge) { PTA pta = edge.getParent().getParent(); dPost(edge); tPost(pta); } /** * Do time part of post operation (including c-closure). * Note: pta is passed in just for efficiency, could find it if we wanted. */ public void tPost(PTA pta) { // Time successor (up) zone.up(pta.getInvariantConstraints(loc)); // c-Closure zone.cClosure(pta.getMaxClockConstraint()); } /** * Do discrete part of post operation (wrt. an edge). */ public void dPost(Edge edge) { Transition tr = edge.getParent(); // Intersect this zone with guard of edge's transition's guard for (Constraint c : tr.getGuardConstraints()) { zone.addConstraint(c); } // Apply clock resets in edge for (Map.Entrye : edge.getResets()) { zone.reset(e.getKey(), e.getValue()); } // Intersect with invariant of target location zone.addConstraints(tr.getParent().getInvariantConstraints(edge.getDestination())); // Set location to target location loc = edge.getDestination(); } /** * dPre: discrete predecessor */ public void dPre(Edge edge) { Transition tr = edge.getParent(); // Backwards reset of clocks from edge for (Map.Entrye : edge.getResets()) { zone.backReset(e.getKey(), e.getValue()); } // Intersect with guard of edge's transition's guard for (Constraint c : tr.getGuardConstraints()) { zone.addConstraint(c); } // Intersect with invariant of source location zone.addConstraints(tr.getParent().getInvariantConstraints(tr.getSource())); // Set location to source location loc = tr.getSource(); } /** * Clone this location/zone pair */ public LocZone deepCopy() { return new LocZone(loc, zone.deepCopy()); } // Standard Java methods public int hashCode() { // Simple hash code return loc; } public boolean equals(Object o) { LocZone lz; if (o == null) return false; try { lz = (LocZone) o; } catch (ClassCastException e) { return false; } if (loc != lz.loc) return false; return (zone.equals(lz.zone)); } public String toString() { return "(" + zone.getPTA().getLocationNameString(loc) + "," + zone + ")"; } }