This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

179
java/COUNTER/ACCESS.CPP Normal file
View File

@@ -0,0 +1,179 @@
#include <access/access.hpp>
#include <access/arecord.hpp>
#include <common/openfile.hpp>
#include <common/systime.hpp>
#include <thread/sleep.hpp>
AccessManager::AccessManager(void)
: mStrPathAccessLog("/var/log/httpd/access_log"), mStrPathMessageLog("var/log/messages")
{
}
AccessManager::AccessManager(const AccessManager &someAccessManager)
{ // private implementation
}
AccessManager::~AccessManager()
{
}
AccessManager &AccessManager::operator=(const AccessManager &someAccessManager)
{ // private implementation
}
DWORD AccessManager::getAccessLineCount(void)
{
String strLine;
DWORD lineCount(0);
File accessFile(mStrPathAccessLog);
if(!accessFile.isOkay())return FALSE;
while(accessFile.getLine(strLine))lineCount++;
return lineCount;
}
void AccessManager::accessDelta(DWORD prevLines,DWORD currLines)
{
Block<String> accessLines;
String strLine;
File accessLog;
accessLog.open(mStrPathAccessLog);
if(!accessLog.isOkay())return;
while(accessLog.getLine(strLine))accessLines.insert(strLine);
accessLog.close();
for(int indexLine=0;indexLine<accessLines.size();indexLine++)
{
if(indexLine<prevLines)continue;
String &currLine=accessLines[indexLine];
if(!currLine.strstr("GET"))continue;
AccessRecord accessRecord;
accessRecord.ip(currLine.betweenString(0,' '));
accessRecord.date(SDate().dayMonthYearStringToDate(currLine.betweenString('[',':')));
accessRecord.time(currLine.betweenString('[',' ').betweenString(':',0));
getHost(accessRecord);
mAccessFile.insert(accessRecord);
}
if(mAccessFile.isDirty())
{
mAccessFile.flush();
accessPage();
}
}
void AccessManager::accessPage(void)
{
Block<AccessRecord> accessRecords;
SystemTime systemTime;
String strPostfix;
String strPrefix;
String strLine;
File outFile;
SDate currDate;
mAccessFile.getEntries(accessRecords);
createCounter(accessRecords.size());
strPrefix="<FONT SIZE=\"+1\" COLOR=\"Lime\"><B><I>";
strPostfix="</I></B></FONT><BR>";
outFile.open("/home/httpd/html/access/access.html","wb");
if(!outFile.isOkay())return;
outFile.writeLine("<HTML>");
outFile.writeLine("<HEAD>");
outFile.writeLine("<TITLE></TITLE>");
outFile.writeLine("</HEAD>");
outFile.writeLine("<BODY BACKGROUND=\"setup.gif\" TEXT=\"#000000\" LINK=\"#00AA00\" VLINK=\"#808080\" ALINK=\"ff00ff\">");
outFile.writeLine("<P ALIGN=\"CENTER\"><FONT COLOR=\"Lime\" SIZE=\"+3\"><B><I>Ganymede System Monitor</I></B></FONT></P>");
outFile.writeLine("<P>&nbsp;</P>");
outFile.writeLine(String("<P><B><I><FONT COLOR=\"Lime\" SIZE=\"+3\">HTTP Access Log, ")+(String)systemTime+String("</FONT><FONT COLOR=\"Lime\"><BR>"));
outFile.writeLine("</FONT></I></B>");
for(int index=0;index<accessRecords.size();index++)
{
AccessRecord &accessRecord=accessRecords[index];
if(!index)currDate=accessRecord.date();
else if(!(currDate==accessRecord.date())){outFile.writeLine("<BR>");currDate=accessRecord.date();}
outFile.writeLine(strPrefix+accessRecord.ip()+String(" (")+accessRecord.host()+String(") on ")+accessRecord.date().makeString()+String(" at ")+accessRecord.time()+strPostfix);
}
outFile.writeLine("</P>");
outFile.writeLine("</BODY>");
outFile.writeLine("</HTML>");
}
void AccessManager::getHost(AccessRecord &accessRecord)
{
String strPathResultFile("host.rst");
String strSystem("/usr/bin/host ");
String strHostNotFoundTryAgain("Host not found, try again.");
String strHostNotFound("Host not found.");
String strLine;
char *ptrLine;
File inFile;
strSystem+=accessRecord.ip();
strSystem+=String(" &>")+strPathResultFile;
::unlink(strPathResultFile);
::system(strSystem);
inFile.open(strPathResultFile);
if(!inFile.isOkay()){accessRecord.host(strHostNotFound);return;}
inFile.getLine(strLine);
if(strLine.isNull()||strLine==strHostNotFound||strLine==strHostNotFound){accessRecord.host(strHostNotFound);return;}
ptrLine=(char*)strLine+(strLine.length()-1);
while(ptrLine>(char*)strLine&&*ptrLine!=' ')ptrLine--;
if(' '==*ptrLine)ptrLine++;
accessRecord.host(ptrLine);
}
void AccessManager::createCounter(int accessCount)
{
File outFile;
String strCount;
::sprintf(strCount,"%06d",accessCount);
outFile.open("/home/httpd/html/log/access.cnt","wb");
if(!outFile.isOkay())return;
outFile.writeLine(strCount);
outFile.close();
}
void AccessManager::perform(void)
{
DWORD accessLines(getAccessLineCount());
DWORD newAccessLines;
SDate currDate(SDate::TodaysDate);
SDate nextDate;
Sleep sleeper;
BOOL isInit(TRUE);
while(TRUE)
{
::printf("AccessManager is sleeping\n");
if(!isInit)sleeper.sleep(TimeOut);
isInit=FALSE;
::printf("AccessManager is awake\n");
nextDate=SDate(SDate::TodaysDate);
if(DayCount<=nextDate.daysBetweenActual(currDate,nextDate))
{
currDate=nextDate;
mAccessFile.reset();
}
newAccessLines=getAccessLineCount();
if(newAccessLines<accessLines)accessLines=newAccessLines;
if(newAccessLines==accessLines)continue;
if(newAccessLines!=accessLines)
{
::printf("AccessManager is processing the change log...\n");
accessDelta(accessLines,newAccessLines);
accessLines=newAccessLines;
::printf("AccessManager is finished processing the change log.\n");
}
}
}

View File

@@ -0,0 +1,2 @@
000910

View File

@@ -0,0 +1 @@
file:/D:\work\JAVA\COUNTER

BIN
java/COUNTER/COMMAND.COM Normal file

Binary file not shown.

2
java/COUNTER/COUNTER.DAT Normal file
View File

@@ -0,0 +1,2 @@
0

179
java/COUNTER/COUNTER.MAK Normal file
View File

@@ -0,0 +1,179 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Java Virtual Machine Java Workspace" 0x0809
!IF "$(CFG)" == ""
CFG=Counter - Java Virtual Machine Debug
!MESSAGE No configuration specified. Defaulting to Counter - Java Virtual\
Machine Debug.
!ENDIF
!IF "$(CFG)" != "Counter - Java Virtual Machine Release" && "$(CFG)" !=\
"Counter - Java Virtual Machine Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Counter.mak" CFG="Counter - Java Virtual Machine Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Counter - Java Virtual Machine Release" (based on\
"Java Virtual Machine Java Workspace")
!MESSAGE "Counter - Java Virtual Machine Debug" (based on\
"Java Virtual Machine Java Workspace")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
JAVA=jvc.exe
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ""
# PROP BASE Intermediate_Dir ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ""
# PROP Intermediate_Dir ""
# PROP Target_Dir ""
OUTDIR=.
INTDIR=.
ALL : "$(OUTDIR)\OutFile.class" "$(OUTDIR)\HotLink.class"\
"$(OUTDIR)\InFile.class"
CLEAN :
-@erase "$(INTDIR)\HotLink.class"
-@erase "$(INTDIR)\InFile.class"
-@erase "$(INTDIR)\OutFile.class"
# ADD BASE JAVA /O
# ADD JAVA /O
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ""
# PROP BASE Intermediate_Dir ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ""
# PROP Intermediate_Dir ""
# PROP Target_Dir ""
OUTDIR=.
INTDIR=.
ALL : "$(OUTDIR)\OutFile.class" "$(OUTDIR)\Counter.class"\
"$(OUTDIR)\InFile.class"
CLEAN :
-@erase "$(INTDIR)\Counter.class"
-@erase "$(INTDIR)\InFile.class"
-@erase "$(INTDIR)\OutFile.class"
# ADD BASE JAVA /g
# ADD JAVA /g
!ENDIF
################################################################################
# Begin Target
# Name "Counter - Java Virtual Machine Release"
# Name "Counter - Java Virtual Machine Debug"
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\OutFile.java
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
"$(INTDIR)\OutFile.class" : $(SOURCE) "$(INTDIR)"
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
"$(INTDIR)\OutFile.class" : $(SOURCE) "$(INTDIR)"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\Counter.java
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
"$(INTDIR)\HotLink.class" : $(SOURCE) "$(INTDIR)"
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
"$(INTDIR)\Counter.class" : $(SOURCE) "$(INTDIR)"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\InFile.java
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
"$(INTDIR)\InFile.class" : $(SOURCE) "$(INTDIR)"
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
"$(INTDIR)\InFile.class" : $(SOURCE) "$(INTDIR)"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\Counter.html
!IF "$(CFG)" == "Counter - Java Virtual Machine Release"
!ELSEIF "$(CFG)" == "Counter - Java Virtual Machine Debug"
!ENDIF
# End Source File
# End Target
# End Project
################################################################################

13
java/COUNTER/COUNTER.SLN Normal file
View File

@@ -0,0 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 1.00
Project("{66355F20-A65B-11D0-BFB5-00A0C91EBFA0}") = "counter", "counter.vjp", "{E614FBE0-5035-11D3-A128-D95DC27FC260}"
EndProject
Global
GlobalSection(LocalDeployment) = postSolution
StartupProject = {E614FBE0-5035-11D3-A128-D95DC27FC260}
EndGlobalSection
GlobalSection(BuildOrder) = postSolution
0 = {E614FBE0-5035-11D3-A128-D95DC27FC260}
EndGlobalSection
GlobalSection(DeploymentRoot) = postSolution
EndGlobalSection
EndGlobal

BIN
java/COUNTER/COUNTER.SUO Normal file

Binary file not shown.

BIN
java/COUNTER/COUNTER.VJP Normal file

Binary file not shown.

BIN
java/COUNTER/Counter.class Normal file

Binary file not shown.

13
java/COUNTER/Counter.html Normal file
View File

@@ -0,0 +1,13 @@
<html>
<head>
<title>proto</title>
</head>
<body>
<hr>
<applet code=Counter.class width=90 height=30>
<param name="counter" value="......">
</applet>
<hr>
<a href="Counter.java">The source.</a>
</body>
</html>

39
java/COUNTER/Counter.java Normal file
View File

@@ -0,0 +1,39 @@
import java.awt.*;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Date;
import java.awt.Frame;
import java.awt.image.*;
import java.io.*;
public class Counter extends java.applet.Applet
{
private Led mLed=null;
public Counter()
{
setBackground(Color.white);
}
public void init()
{
mLed=new Led(this);
}
public void start()
{
mLed.start();
}
public void stop()
{
mLed.stop();
}
public void update(Graphics graphics)
{
paint(graphics);
}
public void paint(Graphics graphics)
{
mLed.paint(graphics);
}
}

View File

@@ -0,0 +1,82 @@
import java.awt.*;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Date;
import java.awt.Frame;
import java.awt.image.*;
import java.io.*;
import java.net.*;
public class Counter extends java.applet.Applet implements Runnable
{
// private Thread mThread;
private String mStrFileName;
public Counter()
{
}
public void init()
{
mStrFileName=new String("counter.dat");
repaint();
}
public void run()
{
// InFile inFile;
// System.out.println("Hello");
// try{inFile=new InFile(getCodeBase(),mStrFileName);}
// try{inFile.open(getCodeBase(),mStrFileName);}
// catch(Exception exception){return;}
// String strLine=new String();
// try{strLine=inFile.readLine();}
// catch(Exception exception){return;}
// Integer iCounter=new Integer(strLine);
// int counter=iCounter.intValue();
// counter++;
// strLine.valueOf(counter);
// inFile.close();
// OutFile outFile=new OutFile();
// try{outFile.open(getCodeBase(),mStrFileName);}
// catch(Exception exception){return;}
// try{outFile.write(strLine);}
// catch(Exception exception){return;}
// outFile.close();
}
public void start()
{
InFile inFile;
try{inFile=new InFile(getCodeBase(),mStrFileName);}
catch(Exception exception){return;}
String strLine=new String();
try{strLine=inFile.readLine();}
catch(Exception exception){return;}
Integer iCounter=new Integer(strLine);
int counter=iCounter.intValue();
counter++;
strLine=String.valueOf(counter);
inFile.close();
OutFile outFile;
String str=new String(getCodeBase().toString());
// try{outFile=new OutFile(getCodeBase(),mStrFileName);}
// catch(Exception exception){return;}
// try{outFile.write(strLine);}
// catch(Exception exception){return;}
// outFile.close();
// if(mThread==null){mThread=new Thread(this);mThread.start();}
}
public void stop()
{
// if(null!=mThread){mThread.stop();mThread=null;}
}
// public void update(Graphics graphics)
// {
// paint(graphics);
// }
// public void paint(Graphics graphics)
// {
// }
}

View File

@@ -0,0 +1,39 @@
import java.awt.*;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Date;
import java.awt.Frame;
import java.awt.image.*;
import java.io.*;
public class Counter extends java.applet.Applet
{
private Led mLed=null;
public Counter()
{
setBackground(Color.white);
}
public void init()
{
mLed=new Led(this);
}
public void start()
{
mLed.start();
}
public void stop()
{
mLed.stop();
}
public void update(Graphics graphics)
{
paint(graphics);
}
public void paint(Graphics graphics)
{
mLed.paint(graphics);
}
}

BIN
java/COUNTER/Counter.mdp Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

BIN
java/COUNTER/IMAGE/DASH.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

BIN
java/COUNTER/IMAGE/FIVE.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

BIN
java/COUNTER/IMAGE/FOUR.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

BIN
java/COUNTER/IMAGE/LED.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
java/COUNTER/IMAGE/NINE.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
java/COUNTER/IMAGE/ONE.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

BIN
java/COUNTER/IMAGE/SIX.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

BIN
java/COUNTER/IMAGE/TWO.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
java/COUNTER/IMAGE/ZERO.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

BIN
java/COUNTER/InFile.class Normal file

Binary file not shown.

75
java/COUNTER/Infile.java Normal file
View File

@@ -0,0 +1,75 @@
import java.net.*;
import java.io.*;
class InFile
{
private boolean mIsOkay;
private URL mInFile;
private URLConnection mConnection;
private DataInputStream mInData;
private String mStrLine;
public InFile()
{
mIsOkay=false;
}
public InFile(URL resBase,String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(resBase,strHostPathFileName);
}
public InFile(String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(strHostPathFileName);
}
public InFile(String resBase,String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(resBase,strHostPathFileName);
}
public void open(URL resBase,String strHostPathFileName)throws Exception
{
close();
try{mInFile=new URL(resBase,strHostPathFileName);}
catch(MalformedURLException exception){throw new Exception();}
try{mConnection=mInFile.openConnection();}
catch(Exception exception){throw new Exception();}
try{mInData=new DataInputStream(mConnection.getInputStream());}
catch(Exception exception){throw new Exception();}
mIsOkay=true;
}
public void open(String resBase,String strHostPathFileName)throws Exception
{
open(resBase+strHostPathFileName);
}
public void open(String strHostPathFileName)throws Exception
{
close();
try{mInFile=new URL(strHostPathFileName);}
catch(MalformedURLException exception){throw new Exception();}
try{mConnection=mInFile.openConnection();}
catch(IOException ioException){throw new Exception();}
try{mInData=new DataInputStream(mConnection.getInputStream());}
catch(Exception exception){throw new Exception();}
mIsOkay=true;
}
public void close()
{
if(!isOkay())return;
try{mInData.close();}
catch(Exception exception){;}
mIsOkay=false;
}
public String readLine()throws Exception
{
if(!isOkay())throw new Exception();
try{mStrLine=new String(mInData.readLine());}
catch(IOException ioException){throw new Exception();}
return mStrLine;
}
public boolean isOkay()
{
return mIsOkay;
}
};

View File

@@ -0,0 +1,2 @@
000930

BIN
java/COUNTER/Led.class Normal file

Binary file not shown.

110
java/COUNTER/Led.java Normal file
View File

@@ -0,0 +1,110 @@
import java.awt.*;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Date;
import java.awt.Frame;
import java.awt.image.*;
import java.io.*;
import java.net.*;
public class Led extends Thread
{
private Thread mThread=null;
private InFile mInFile;
private final int smImageCount=12;
private Image[] mLedImages=new Image[smImageCount];
private String mStrParam=null;
private java.applet.Applet mApplet=null;
private final int TimeOut=300000;
Led(java.applet.Applet applet)
{
init(applet);
}
public void init(java.applet.Applet applet)
{
mApplet=applet;
mLedImages[0]=mApplet.getImage(mApplet.getCodeBase(),"image/zero.gif");
mLedImages[1]=mApplet.getImage(mApplet.getCodeBase(),"image/one.gif");
mLedImages[2]=mApplet.getImage(mApplet.getCodeBase(),"image/two.gif");
mLedImages[3]=mApplet.getImage(mApplet.getCodeBase(),"image/three.gif");
mLedImages[4]=mApplet.getImage(mApplet.getCodeBase(),"image/four.gif");
mLedImages[5]=mApplet.getImage(mApplet.getCodeBase(),"image/five.gif");
mLedImages[6]=mApplet.getImage(mApplet.getCodeBase(),"image/six.gif");
mLedImages[7]=mApplet.getImage(mApplet.getCodeBase(),"image/seven.gif");
mLedImages[8]=mApplet.getImage(mApplet.getCodeBase(),"image/eight.gif");
mLedImages[9]=mApplet.getImage(mApplet.getCodeBase(),"image/nine.gif");
mLedImages[10]=mApplet.getImage(mApplet.getCodeBase(),"image/dash.gif");
mLedImages[11]=mApplet.getImage(mApplet.getCodeBase(),"image/blank.gif");
MediaTracker mediaTracker=new MediaTracker(mApplet);
for(int imageIndex=0;imageIndex<smImageCount;imageIndex++)mediaTracker.addImage(mLedImages[imageIndex],imageIndex);
try{mediaTracker.waitForAll();}
catch(InterruptedException exception){;}
}
public void run()
{
while(true)
{
mStrParam=new String("......");
try{mInFile=new InFile(mApplet.getCodeBase(),"log/access.cnt");}
catch(Exception exception){continue;}
if(mInFile.isOkay())
{
try{mStrParam=new String(mInFile.readLine());}
catch(Exception exception){;}
}
mInFile.close();
mApplet.repaint();
try {sleep(TimeOut);}
catch(InterruptedException exception){break;}
mStrParam=new String("......");
mApplet.repaint();
}
}
public void paint(Graphics graphics)
{
drawLEDString(mStrParam,graphics);
}
private void drawLEDString(String strLED,Graphics graphics)
{
int strLength=strLED.length();
int imageWidth;
int imageHeight;
Point ptLoc;
if(null==mStrParam)return;
ptLoc=new Point(4,4);
imageWidth=mLedImages[0].getWidth(mApplet);
imageHeight=mLedImages[0].getHeight(mApplet);
for(int strIndex=0;strIndex<strLength;strIndex++)
{
char strChar=strLED.charAt(strIndex);
if('0'==strChar)graphics.drawImage(mLedImages[0],ptLoc.x,ptLoc.y,mApplet);
else if('1'==strChar)graphics.drawImage(mLedImages[1],ptLoc.x,ptLoc.y,mApplet);
else if('2'==strChar)graphics.drawImage(mLedImages[2],ptLoc.x,ptLoc.y,mApplet);
else if('3'==strChar)graphics.drawImage(mLedImages[3],ptLoc.x,ptLoc.y,mApplet);
else if('4'==strChar)graphics.drawImage(mLedImages[4],ptLoc.x,ptLoc.y,mApplet);
else if('5'==strChar)graphics.drawImage(mLedImages[5],ptLoc.x,ptLoc.y,mApplet);
else if('6'==strChar)graphics.drawImage(mLedImages[6],ptLoc.x,ptLoc.y,mApplet);
else if('7'==strChar)graphics.drawImage(mLedImages[7],ptLoc.x,ptLoc.y,mApplet);
else if('8'==strChar)graphics.drawImage(mLedImages[8],ptLoc.x,ptLoc.y,mApplet);
else if('9'==strChar)graphics.drawImage(mLedImages[9],ptLoc.x,ptLoc.y,mApplet);
else if('.'==strChar)graphics.drawImage(mLedImages[10],ptLoc.x,ptLoc.y,mApplet);
else graphics.drawImage(mLedImages[11],ptLoc.x,ptLoc.y,mApplet);
ptLoc.x+=imageWidth;
}
graphics.setColor(new Color(48,64,0));
graphics.drawLine(3,3,ptLoc.x,3);
graphics.drawLine(3,3,3,imageHeight+4);
graphics.setColor(new Color(175,192,224));
graphics.drawLine(3,imageHeight+4,ptLoc.x,imageHeight+4);
graphics.drawLine(ptLoc.x,3,ptLoc.x,imageHeight+4);
graphics.setColor(new Color(96,143,208));
graphics.drawRect(2,2,(ptLoc.x+1)-2,imageHeight+3);
graphics.setColor(new Color(175,192,224));
graphics.drawLine(1,1,ptLoc.x+2,1);
}
}

110
java/COUNTER/Led.java~ Normal file
View File

@@ -0,0 +1,110 @@
import java.awt.*;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.util.Date;
import java.awt.Frame;
import java.awt.image.*;
import java.io.*;
import java.net.*;
public class Led extends Thread
{
private Thread mThread=null;
private InFile mInFile;
private final int smImageCount=12;
private Image[] mLedImages=new Image[smImageCount];
private String mStrParam=null;
private java.applet.Applet mApplet=null;
private final int TimeOut=300000;
Led(java.applet.Applet applet)
{
init(applet);
}
public void init(java.applet.Applet applet)
{
mApplet=applet;
mLedImages[0]=mApplet.getImage(mApplet.getCodeBase(),"image/zero.gif");
mLedImages[1]=mApplet.getImage(mApplet.getCodeBase(),"image/one.gif");
mLedImages[2]=mApplet.getImage(mApplet.getCodeBase(),"image/two.gif");
mLedImages[3]=mApplet.getImage(mApplet.getCodeBase(),"image/three.gif");
mLedImages[4]=mApplet.getImage(mApplet.getCodeBase(),"image/four.gif");
mLedImages[5]=mApplet.getImage(mApplet.getCodeBase(),"image/five.gif");
mLedImages[6]=mApplet.getImage(mApplet.getCodeBase(),"image/six.gif");
mLedImages[7]=mApplet.getImage(mApplet.getCodeBase(),"image/seven.gif");
mLedImages[8]=mApplet.getImage(mApplet.getCodeBase(),"image/eight.gif");
mLedImages[9]=mApplet.getImage(mApplet.getCodeBase(),"image/nine.gif");
mLedImages[10]=mApplet.getImage(mApplet.getCodeBase(),"image/dash.gif");
mLedImages[11]=mApplet.getImage(mApplet.getCodeBase(),"image/blank.gif");
MediaTracker mediaTracker=new MediaTracker(mApplet);
for(int imageIndex=0;imageIndex<smImageCount;imageIndex++)mediaTracker.addImage(mLedImages[imageIndex],imageIndex);
try{mediaTracker.waitForAll();}
catch(InterruptedException exception){;}
}
public void run()
{
while(true)
{
mStrParam=new String("......");
try{mInFile=new InFile(mApplet.getCodeBase(),"log/access.cnt");}
catch(Exception exception){continue;}
if(mInFile.isOkay())
{
try{mStrParam=new String(mInFile.readLine());}
catch(Exception exception){;}
}
mInFile.close();
mApplet.repaint();
try {sleep(TimeOut);}
catch(InterruptedException exception){break;}
mStrParam=new String("......");
mApplet.repaint();
}
}
public void paint(Graphics graphics)
{
drawLEDString(mStrParam,graphics);
}
private void drawLEDString(String strLED,Graphics graphics)
{
int strLength=strLED.length();
int imageWidth;
int imageHeight;
Point ptLoc;
if(null==mStrParam)return;
ptLoc=new Point(4,4);
imageWidth=mLedImages[0].getWidth(mApplet);
imageHeight=mLedImages[0].getHeight(mApplet);
for(int strIndex=0;strIndex<strLength;strIndex++)
{
char strChar=strLED.charAt(strIndex);
if('0'==strChar)graphics.drawImage(mLedImages[0],ptLoc.x,ptLoc.y,mApplet);
else if('1'==strChar)graphics.drawImage(mLedImages[1],ptLoc.x,ptLoc.y,mApplet);
else if('2'==strChar)graphics.drawImage(mLedImages[2],ptLoc.x,ptLoc.y,mApplet);
else if('3'==strChar)graphics.drawImage(mLedImages[3],ptLoc.x,ptLoc.y,mApplet);
else if('4'==strChar)graphics.drawImage(mLedImages[4],ptLoc.x,ptLoc.y,mApplet);
else if('5'==strChar)graphics.drawImage(mLedImages[5],ptLoc.x,ptLoc.y,mApplet);
else if('6'==strChar)graphics.drawImage(mLedImages[6],ptLoc.x,ptLoc.y,mApplet);
else if('7'==strChar)graphics.drawImage(mLedImages[7],ptLoc.x,ptLoc.y,mApplet);
else if('8'==strChar)graphics.drawImage(mLedImages[8],ptLoc.x,ptLoc.y,mApplet);
else if('9'==strChar)graphics.drawImage(mLedImages[9],ptLoc.x,ptLoc.y,mApplet);
else if('.'==strChar)graphics.drawImage(mLedImages[10],ptLoc.x,ptLoc.y,mApplet);
else graphics.drawImage(mLedImages[11],ptLoc.x,ptLoc.y,mApplet);
ptLoc.x+=imageWidth;
}
graphics.setColor(new Color(48,64,0));
graphics.drawLine(3,3,ptLoc.x,3);
graphics.drawLine(3,3,3,imageHeight+4);
graphics.setColor(new Color(175,192,224));
graphics.drawLine(3,imageHeight+4,ptLoc.x,imageHeight+4);
graphics.drawLine(ptLoc.x,3,ptLoc.x,imageHeight+4);
graphics.setColor(new Color(96,143,208));
graphics.drawRect(2,2,(ptLoc.x+1)-2,imageHeight+3);
graphics.setColor(new Color(175,192,224));
graphics.drawLine(1,1,ptLoc.x+2,1);
}
}

BIN
java/COUNTER/OutFile.class Normal file

Binary file not shown.

108
java/COUNTER/Outfile.java Normal file
View File

@@ -0,0 +1,108 @@
import java.net.*;
import java.io.*;
class OutFile
{
private boolean mIsOkay;
private URL mOutFile;
private URLConnection mConnection;
private DataOutputStream mOutData;
private String mStrLine;
public OutFile()
{
mIsOkay=false;
}
public OutFile(URL resBase,String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(resBase,strHostPathFileName);
}
public OutFile(String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(strHostPathFileName);
}
public OutFile(String resBase,String strHostPathFileName)throws Exception
{
mIsOkay=false;
open(resBase,strHostPathFileName);
}
public void open(URL resBase,String strHostPathFileName)throws Exception
{
close();
try{mOutFile=new URL(resBase,strHostPathFileName);}
catch(MalformedURLException exception){throw new Exception();}
try{mConnection=mOutFile.openConnection();}
catch(Exception exception){throw new Exception();}
mConnection.setDoOutput(true);
try{mOutData=new DataOutputStream(mConnection.getOutputStream());}
catch(Exception exception){throw new Exception();}
mIsOkay=true;
}
public void open(String resBase,String strHostPathFileName)throws Exception
{
open(resBase+strHostPathFileName);
}
public void open(String strHostPathFileName)throws Exception
{
close();
try{mOutFile=new URL(strHostPathFileName);}
catch(MalformedURLException exception){throw new Exception();}
try{mConnection=mOutFile.openConnection();}
catch(IOException ioException){throw new Exception();}
mConnection.setDoOutput(true);
try{mOutData=new DataOutputStream(mConnection.getOutputStream());}
catch(Exception exception){throw new Exception();}
mIsOkay=true;
}
public void close ()
{
if(!isOkay())return;
try{mOutData.close();}
catch(Exception exception){;}
mIsOkay=false;
}
public void flush()throws Exception
{
if(!isOkay())throw new Exception();
mOutData.flush();
}
public void write(String strLine)throws Exception
{
if(!isOkay())throw new Exception();
mOutData.writeBytes(strLine);
}
public void write(double value)throws Exception
{
if(!isOkay())throw new Exception();
mOutData.writeDouble(value);
}
public void write(int value)throws Exception
{
if(!isOkay())throw new Exception();
mOutData.writeInt(value);
}
public int size()
{
if(!isOkay())return 0;
return mOutData.size();
}
public boolean isOkay()
{
return mIsOkay;
}
};
// public String readLine()throws Exception
// {
// if(!isOkay())throw new Exception();
// try{mStrLine=new String(mInData.readLine());}
// catch(IOException ioException){throw new Exception();}
// return mStrLine;
// }
// public boolean isOkay()
// {
// return mIsOkay;
// }
//};

5
java/COUNTER/VJPROJS.SRG Normal file
View File

@@ -0,0 +1,5 @@
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\6.0]
"DefaultProjectTreeSelection"="Applications"
"DefaultProjectListSelection"="Windows Application"
"DefaultProjItemTreeSelection"="Form"
"DefaultProjItemListSelection"="Form"