From 05f9dbe1bfa1aa874c88b2afe643f58e8169d687 Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr>
Date: Tue, 2 Dec 2008 08:30:34 +0000
Subject: [PATCH] NC update

---
 src/nc/NCCapacityUnit.java | 74 +++++++++++++++++++++++++++++++++++
 src/nc/NCLink.java         |  9 +++++
 src/nc/NCStructure.java    | 10 ++++-
 src/nc/NCSwitch.java       | 19 +++++++++
 src/nc/NCTimeUnit.java     | 79 ++++++++++++++++++++++++++++++++++++++
 src/nc/NCTraffic.java      | 29 +++++++++++++-
 6 files changed, 217 insertions(+), 3 deletions(-)
 create mode 100755 src/nc/NCCapacityUnit.java
 create mode 100755 src/nc/NCTimeUnit.java

diff --git a/src/nc/NCCapacityUnit.java b/src/nc/NCCapacityUnit.java
new file mode 100755
index 0000000000..e21996f3d1
--- /dev/null
+++ b/src/nc/NCCapacityUnit.java
@@ -0,0 +1,74 @@
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+*
+* ludovic.apvrille AT enst.fr
+*
+* This software is a computer program whose purpose is to allow the
+* edition of TURTLE analysis, design and deployment diagrams, to
+* allow the generation of RT-LOTOS or Java code from this diagram,
+* and at last to allow the analysis of formal validation traces
+* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
+* from INRIA Rhone-Alpes.
+*
+* This software is governed by the CeCILL  license under French law and
+* abiding by the rules of distribution of free software.  You can  use,
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info".
+*
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability.
+*
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or
+* data to be ensured and,  more generally, to use and operate it in the
+* same conditions as regards security.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*
+* /**
+* Class NCCapacityUnit
+* Creation: 28/11/2008
+* @version 1.0 28/11/2008
+* @author Ludovic APVRILLE
+* @see
+*/
+
+package nc;
+
+
+public class NCCapacityUnit {
+    
+	public static final String MBS = "Mbs";
+	public static final String KBS = "Kbs";
+	
+	private String unit;
+	
+	public NCCapacityUnit() {
+		unit = MBS;
+	}
+	
+	public void setUnit(String s) {
+		if (s.equals(MBS)) {
+			unit = MBS;
+		}
+		
+		if (s.equals(KBS)) {
+			unit = KBS;
+		}
+	}
+	
+	public String getStringUnit() {
+		return unit;
+	}
+	
+}
\ No newline at end of file
diff --git a/src/nc/NCLink.java b/src/nc/NCLink.java
index fef492b6b0..b0aad277f7 100755
--- a/src/nc/NCLink.java
+++ b/src/nc/NCLink.java
@@ -49,6 +49,7 @@ package nc;
 
 public class NCLink extends NCElement  {
 	protected int capacity;
+	protected NCCapacityUnit capacityUnit = new NCCapacityUnit(); // Default value: Mbs 
 	protected NCLinkedElement le1, le2;
 	
 	public NCLink() {}
@@ -77,5 +78,13 @@ public class NCLink extends NCElement  {
 		le2 = ncle;
 	}
 	
+	public void setCapacityUnit(NCCapacityUnit _unit) {
+		capacityUnit = _unit;
+	}
+	
+	public NCCapacityUnit getCapacityUnit() {
+		return capacityUnit;
+	}
+	
 	
 }
\ No newline at end of file
diff --git a/src/nc/NCStructure.java b/src/nc/NCStructure.java
index 8043f6dc60..671db68fef 100755
--- a/src/nc/NCStructure.java
+++ b/src/nc/NCStructure.java
@@ -124,6 +124,8 @@ public class NCStructure extends NCElement {
 			tmp += sw.getName();
 			tmp += "\" schedulingPolicy=\"";
 			tmp += NCSwitch.getStringSchedulingPolicy(sw.getSchedulingPolicy());
+			tmp += "\" capacity=\"" + sw.getCapacity();
+			tmp += "\" capacityUnit=\"" + sw.getCapacityUnit().getStringUnit();
 			tmp += "\" />\n";
 		}
 		return tmp;
@@ -132,16 +134,18 @@ public class NCStructure extends NCElement {
 	private String getXMLTraffics() {
 		String tmp = "";
 		for(NCTraffic tr: traffics) {
-			tmp += "<traffic ";
+			tmp += "<Traffic ";
 			tmp += " name=\"";
 			tmp += tr.getName();
-			tmp += " Periodic=\"";
+			tmp += "\" Periodic=\"";
 			if (tr.getPeriodicType() == 0) {
 				tmp += "periodic";
 			} else {
 				tmp += "aperiodic";
 			}
 			tmp += "\" deadline=\"" + tr.getDeadline();
+			tmp += "\" deadlineUnit=\"" + tr.getDeadlineUnit().getStringUnit();
+			tmp += "\" minPacketSize=\"" + tr.getMinPacketSize();
 			tmp += "\" maxPacketSize=\"" + tr.getMaxPacketSize();
 			tmp += "\" priority=\"" + tr.getPriority();
 			tmp += "\" />\n";
@@ -157,6 +161,8 @@ public class NCStructure extends NCElement {
 			tmp += lk.getName();
 			tmp += "\" capacity=\"";
 			tmp += lk.getCapacity();
+			tmp += "\" capacityUnit=\"";
+			tmp += lk.getCapacityUnit().getStringUnit();
 			tmp += "\" end1=\"";
 			tmp += lk.getLinkedElement1().getName();
 			tmp += "\" end2=\"";
diff --git a/src/nc/NCSwitch.java b/src/nc/NCSwitch.java
index 3f7f7eee22..628978e207 100755
--- a/src/nc/NCSwitch.java
+++ b/src/nc/NCSwitch.java
@@ -56,6 +56,8 @@ public class NCSwitch extends NCLinkedElement  {
 	public static String[] SchedulingPolicies = {FCFS, STATIC, WFQ};
 	
 	private int schedulingPolicy = 0;
+	private int capacity = 0;
+	private NCCapacityUnit unitCapacity = new NCCapacityUnit(); // Default value: Mbs 
 	
 	public NCSwitch() {
 	}
@@ -82,5 +84,22 @@ public class NCSwitch extends NCLinkedElement  {
 		return -1;
 	}
 	
+	public void setCapacity(int _capacity) {
+		capacity = _capacity;
+	}
+	
+	public int getCapacity() {
+		return capacity;
+	}
+	
+	public void setCapacityUnit(NCCapacityUnit _unit) {
+		unitCapacity = _unit;
+	}
+	
+	public NCCapacityUnit getCapacityUnit() {
+		return unitCapacity;
+	}
+	
+	
 
 }
\ No newline at end of file
diff --git a/src/nc/NCTimeUnit.java b/src/nc/NCTimeUnit.java
new file mode 100755
index 0000000000..4d5b032cfe
--- /dev/null
+++ b/src/nc/NCTimeUnit.java
@@ -0,0 +1,79 @@
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+*
+* ludovic.apvrille AT enst.fr
+*
+* This software is a computer program whose purpose is to allow the
+* edition of TURTLE analysis, design and deployment diagrams, to
+* allow the generation of RT-LOTOS or Java code from this diagram,
+* and at last to allow the analysis of formal validation traces
+* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
+* from INRIA Rhone-Alpes.
+*
+* This software is governed by the CeCILL  license under French law and
+* abiding by the rules of distribution of free software.  You can  use,
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info".
+*
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability.
+*
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or
+* data to be ensured and,  more generally, to use and operate it in the
+* same conditions as regards security.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*
+* /**
+* Class NCTimeUnit
+* Creation: 28/11/2008
+* @version 1.0 28/11/2008
+* @author Ludovic APVRILLE
+* @see
+*/
+
+package nc;
+
+
+public class NCTimeUnit {
+    
+	public static final String US = "us";
+	public static final String MS = "ms";
+	public static final String S = "s";
+	
+	private String unit;
+	
+	public NCTimeUnit() {
+		unit = MS;
+	}
+	
+	public void setUnit(String s) {
+		if (s.equals(US)) {
+			unit = US;
+		}
+		
+		if (s.equals(MS)) {
+			unit = MS;
+		}
+		
+		if (s.equals(S)) {
+			unit = S;
+		}
+	}
+	
+	public String getStringUnit() {
+		return unit;
+	}
+	
+}
\ No newline at end of file
diff --git a/src/nc/NCTraffic.java b/src/nc/NCTraffic.java
index 188ebe1984..ec6993ec8b 100755
--- a/src/nc/NCTraffic.java
+++ b/src/nc/NCTraffic.java
@@ -50,23 +50,34 @@ package nc;
 public class NCTraffic extends NCElement  {
 	protected int periodicType = 0; // 0: periodic ; 1: aperiodic
 	protected int deadline = 10;
-	protected int maxPacketSize = 20;
+	protected NCTimeUnit deadlineUnit;
+	protected int minPacketSize = 20;
+	protected int maxPacketSize = 40;
 	protected int priority = 0; // 0 to 3
 	
 	public NCTraffic() {}
 	
 	public void setPeriodicType(int _periodicType) {
 		periodicType = _periodicType;
+		deadlineUnit = new NCTimeUnit();
 	}
 	
 	public void setDeadline(int _deadline) {
 		deadline = _deadline;
 	}
 	
+	public void setDeadlineUnit(NCTimeUnit _deadlineUnit) {
+		deadlineUnit = _deadlineUnit;
+	}
+	
 	public void setMaxPacketSize(int _maxPacketSize) {
 		maxPacketSize = _maxPacketSize;
 	}
 	
+	public void setMinPacketSize(int _minPacketSize) {
+		minPacketSize = _minPacketSize;
+	}
+	
 	public void setPriority(int _priority) {
 		priority = _priority;
 	}
@@ -75,10 +86,26 @@ public class NCTraffic extends NCElement  {
         return periodicType;
     }
 	
+	public static String getStringPeriodicType(int periodicType) {
+		if (periodicType == 0) {
+			return "periodic";
+		} else {
+			return "aperiodic";
+		}
+	}
+	
 	public int getDeadline() {
         return deadline;
     }
 	
+	public NCTimeUnit getDeadlineUnit() {
+		return deadlineUnit;
+	}
+	
+	public int getMinPacketSize() {
+        return minPacketSize;
+    }
+	
 	public int getMaxPacketSize() {
         return maxPacketSize;
     }
-- 
GitLab