Source Code Cross Referenced for Clock.java in  » Code-Analyzer » javapathfinder » DEOS » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » javapathfinder » DEOS 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright (C) 2005 United States Government as represented by the
003:        // Administrator of the National Aeronautics and Space Administration
004:        // (NASA).  All Rights Reserved.
005:        // 
006:        // This software is distributed under the NASA Open Source Agreement
007:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
008:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
009:        // directory tree for the complete NOSA document.
010:        // 
011:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018:        //
019:        package DEOS;
020:
021:        import gov.nasa.jpf.jvm.Verify;
022:
023:        /**
024:         * DOCUMENT ME!
025:         */
026:        public class Clock {
027:            public static int TIME_CONSTRAINT = Registry.numPeriods * 20 * 2; // numPeriods is usually 3
028:            public static int NOINTERRUPTS = 0;
029:            public static int TIMEOUT = 1;
030:            public static int SYSTEMINTERRUPT = 2;
031:            public static int NOTIMECHANGE = 3;
032:            int currentTime = -20;
033:            PeriodicClock clockToNotify; // may use a list in another version
034:            NewTimer timerToNotify; // if there are more than two clocking devices
035:            boolean eventDriven = false;
036:
037:            // For abstraction - need to keep track of current time before event fo
038:
039:            /**
040:             * Main constructor
041:             */
042:            public Clock(PeriodicClock periodicIn, NewTimer timerIn) {
043:                if (DEOS.abstraction) {
044:                    currentTime = -20;
045:                } else {
046:                    currentTime = -1;
047:                }
048:
049:                clockToNotify = periodicIn;
050:                timerToNotify = timerIn;
051:            }
052:
053:            /**
054:             * To get the current time
055:             * @return currentTime
056:             */
057:            public int getCurrentTime() {
058:                return currentTime;
059:            }
060:
061:            /**
062:             * To set the timer
063:             * @param timeIn time with which to set timer
064:             */
065:            public void setTimer(int timeIn) {
066:                timerToNotify.setTimer(timeIn, currentTime);
067:            }
068:
069:            /**
070:             * Clock clears interrupts
071:             */
072:            public void clearInterrupts() {
073:                clockToNotify.clearInterrupt();
074:                timerToNotify.clearTimeOut();
075:            }
076:
077:            /**
078:             * Clock ticks
079:             * @return int - NOINTERRUPTS or TIMEOUT or SYSTEMINTERRUPT
080:             */
081:            public int ticks() {
082:                clearInterrupts();
083:
084:                int delta;
085:
086:                if (!DEOS.abstraction) {
087:                    delta = 1;
088:                } else {
089:                    int timeToEOP = (clockToNotify.getTimeToEOP());
090:                    int timeOutTime = (timerToNotify.getStoppingTime());
091:                    int timeToTimeOut = (timeOutTime - currentTime);
092:
093:                    //System.out.println("currentTime = " + currentTime + " timeToEOP = " + timeToEOP + " timeOutTime = " + timeOutTime + " timeToTimeOut  = " + timeToTimeOut);
094:                    if (Verify.randomBool()) {
095:                        delta = 0;
096:                    } else {
097:                        if (timeToEOP <= timeToTimeOut) {
098:                            delta = timeToEOP;
099:                        } else {
100:                            delta = timeToTimeOut;
101:                        }
102:                    }
103:                }
104:
105:                if (delta == 0) {
106:                    return NOTIMECHANGE;
107:                } else {
108:                    if ((currentTime + delta) > TIME_CONSTRAINT) {
109:                        return NOTIMECHANGE;
110:                    }
111:
112:                    currentTime = (currentTime + delta);
113:                    clockToNotify.clockTicks(currentTime);
114:                    timerToNotify.clockTicks(currentTime);
115:
116:                    if (clockToNotify.isInterrupted()) {
117:                        timerToNotify.interruptTimer();
118:
119:                        return SYSTEMINTERRUPT;
120:                    } else if (timerToNotify.isTimeOut()) {
121:                        return TIMEOUT;
122:                    } else {
123:                        return NOINTERRUPTS;
124:                    }
125:                }
126:            }
127:
128:            /**
129:             * System interrupt or time out events
130:             * @return the event that occurred
131:             */
132:
133:            /* does not seem to be called anywhere?
134:               public int interruptEvents() {
135:                 clearInterrupts();
136:                 int timeToEOP = (clockToNotify.getTimeToEOP());
137:                 int periodTime = (currentTime + timeToEOP);
138:                 int timeOutTime = (timerToNotify.getStoppingTime());
139:                 if (periodTime <= timeOutTime) {
140:                   currentTime = periodTime;  
141:                   clockToNotify.clockTicks(currentTime);
142:                   timerToNotify.clockTicks(currentTime);
143:                   return SYSTEMINTERRUPT;
144:                 } else {
145:                   currentTime = timeOutTime;
146:                   clockToNotify.clockTicks(currentTime);
147:                   timerToNotify.clockTicks(currentTime);
148:                   return TIMEOUT;
149:                 }
150:               }
151:             */
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.