📄 isvjtrend.java
字号:
/////////////////////////////////////////////////////////////////////////////
//
// OPC Trend VJ Client: ISVjTrend.java
// (Source File)
//
/////////////////////////////////////////////////////////////////////////////
//
// Author: Raphael Imhof
// Initial Date: 11/04/98
// $Workfile: ISVjTrend.Java $
// $Revision: 1 $
// $Date: 7/27/99 5:09p $
// Target System: Microsoft Windows NT 4.0
// Environment: Visual J++ 6.0 / OPC DataAccess 2.0
// Remarks:
//
/////////////////////////////////////////////////////////////////////////////
//
// Description: implementation of the main form class.
//
//
/////////////////////////////////////////////////////////////////////////////
//
// History of Changes (Please remove very old comments and blank lines!)
// $Log: /IDK/OPCServer/clients/VJ++/ISVjTrend/ISVjTrend.Java $
//
// 1 7/27/99 5:09p Imhof
//
// 1 7/27/99 4:39p Imhof
//
// 1 7/27/99 4:33p Imhof
//
// 6 1/20/99 3:17p Imhof
// Updated header
//
//
// $Nokeywords:$ (To avoid useless search while checking in.)
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1999, Siemens Building Technologies, Inc. Landis Division
//
// SIEMENS BUILDING TECHNOLOGIES, INC. IS PROVIDING THE FOLLOWING EXAMPLES
// OF CODE AS SAMPLE ONLY.
// SIEMENS BUILDING TECHNOLOGIES, INC. MAKES NO REPRESENTATIONS OR WARRANTIES
// OF ANY KIND WITH RESPECT TO THE VALIDTY OF THE CODES OR DESIRED RESULTS
// AND DISCLAIMS ALL SUCH REPRESENTATIONS AND WARRANTIES, INCLUDING FOR EXAMPLE,
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// SIEMENS BUILIDNG TECHNOLOGIES, INC. DOES NOT REPRESENT OR WARRANT THAT
// THE FOLLOWING CODE SAMPLES ARE ACCURATE, VALID, COMPLETE OR CURRENT.
//
/////////////////////////////////////////////////////////////////////////////
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.io.*;
import com.ms.com.*;
import java.util.Date;
import java.text.*;
import java.util.TimeZone;
import java.util.Locale;
/**
* @author: Application Wizard
* @version: 1.0
* This class can take a variable number of parameters on the command
* line. Program execution begins with the main() method. The class
* constructor is not invoked unless an object of type 'ISVjTrend'
* created in the main() method.
*/
public class ISVjTrend extends Form
{
private String m_sFileName = new String("");
private boolean m_bIsDirty = false;
private Server server;
private void doOpen(Object sender, Event e)
{
// Open
if(server.IsConnected())
{
if(server.SelectTag())
{
//options dialog (for samples)
int iSamples = 20;
OptionsDlg fOptions = new OptionsDlg();
fOptions.SetSamples(iSamples);
if(fOptions.showDialog() == DialogResult.OK)
{
//clear views
TrendGraphView.setRowCount((short)1);
TrendListView.removeAllItems();
iSamples = fOptions.GetSamples();
SafeArray Values = new SafeArray(Variant.VariantVariant, iSamples + Server.vbArrayOffset); //out
SafeArray Errors = new SafeArray(Variant.VariantInt , iSamples + Server.vbArrayOffset);//out
Variant Qualities = new Variant(); //out
Variant TimeStamps = new Variant(); //out
m_sFileName = server.GetTagName();
if(server.ReadTrend(iSamples, Values, Errors, Qualities, TimeStamps))
{
//update list and graph
TrendGraphView.setColumnCount((short)1);
TrendGraphView.setRowCount((short)iSamples);
for(int i = 0; i < iSamples; i++)
{
boolean bAlarm;
boolean bNotValid;
boolean bDataLoss;
long wQuality;
long wPriority;
String sPriority;
String[] SubItems = new String[4];
SafeArray quality = Qualities.toSafeArray();
wQuality = quality.getInt(i + Server.vbArrayOffset);
if((wQuality & 0x4000) > 0)
bDataLoss = true;
else
bDataLoss = false;
if((wQuality & 0x2000) > 0)
bAlarm = true;
else
bAlarm = false;
if((wQuality & 0x8000) > 0)
bNotValid = true;
else
bNotValid = false;
if(!bNotValid)
{
//time stamp handling
SafeArray time = TimeStamps.toSafeArray();
Date TimeOfValue = new Date(time.getString(i + Server.vbArrayOffset));
TimeOfValue.setMinutes(TimeOfValue.getMinutes() - TimeOfValue.getTimezoneOffset());
String sTimeOfValue = new String();
DateFormat formatter = new SimpleDateFormat("M/dd/yy HH:mm:ss");
formatter.setTimeZone(TimeZone.getDefault());
sTimeOfValue = formatter.format(TimeOfValue);
//graph
TrendGraphView.setRow((short)(i+1));
TrendGraphView.setData(Values.getString(i + Server.vbArrayOffset));
TrendGraphView.setRowLabel(sTimeOfValue);
//list
SubItems[0] = Values.getString(i + Server.vbArrayOffset);
wPriority = wQuality & 0x0F00; //retrieve the priority bits
wPriority = wPriority >> 8;
switch((int)wPriority)
{
case 0:
sPriority = "NONE";
break;
case 1:
sPriority = "PDL";
break;
case 2:
sPriority = "EMER";
break;
case 3:
sPriority = "SMOKE";
break;
case 4:
sPriority = "OPER";
break;
case 5:
sPriority = "TECOVRD";
break;
case 6:
sPriority = "HOST_2";
break;
case 7:
sPriority = "HOST_3";
break;
case 8:
sPriority = "HOST_4";
break;
case 9:
sPriority = "HOST_5";
break;
case 10:
sPriority = "HOST_6";
break;
case 12-15:
sPriority = "NONE";
break;
case 11:
sPriority = "UNKNOWN";
break;
default:
sPriority = "UNKNOWN";
break;
}
SubItems[1] = sPriority; //Priority
if(bAlarm) //Alarm
SubItems[2] = "Yes";
else
SubItems[2] = "No";
if(bDataLoss) //Dataloss
SubItems[3] = "Yes";
else
SubItems[3] = "No";
TrendListView.addItem(sTimeOfValue, 1, SubItems);
} //end if not valid
} //end for
} //end if readtrend
} //end if options
} //end if selecttag
} //end if connect
else
{
MessageBox.show("You must first connect to an OPC server!", "IsVjTrend");
}
} //end func
public void doPaste(Object sender, Event e)
{
// Paste
try
{
DataObject myDObj = new DataObject (Clipboard.getDataObject ());
//...
}
catch (Exception ecx)
{
}
}
public void doCopy(Object sender, Event e)
{
// Copy
}
public void doCut(Object sender, Event e)
{
// Cut
}
public void exitMenu_click(Object sender, Event e)
{
// Exit
Application.exit();
}
private void aboutMenu_click(Object sender, Event e)
{
About myAbout = new About();
myAbout.showDialog ();
}
private void toolBar_buttonClick(Object source, ToolBarButtonClickEvent e)
{
if (e.button == openToolBarButton) {
// Open
doOpen(source,e);
}
else if (e.button == ConnecttoolBarButton) {
// Connect
menuConnect_click(source,e);
}
else if (e.button == DisconnecttoolBarButton) {
// Disconnect
menuDisconnect_click(source,e);
}
else {
; //nop
}
}
public ISVjTrend()
{
super();
//Required for Visual J++ Form Designer support
initForm();
//TODO: Add any constructor code after initForm call
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -