connectserver.java
来自「此文件为OPC Client IsVJTrend源代码,在VJ++开发环境下调试」· Java 代码 · 共 238 行
JAVA
238 行
/////////////////////////////////////////////////////////////////////////////
//
// OPC Trend VJ Client: ConnectServer.java
// (Source File)
//
/////////////////////////////////////////////////////////////////////////////
//
// Author: Raphael Imhof
// Initial Date: 11/04/98
// $Workfile: ConnectServer.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 server list class.
//
//
/////////////////////////////////////////////////////////////////////////////
//
// History of Changes (Please remove very old comments and blank lines!)
// $Log: /IDK/OPCServer/clients/VJ++/ISVjTrend/ConnectServer.java $
//
// 1 7/27/99 5:09p Imhof
//
// 1 7/27/99 4:39p Imhof
//
// 1 7/27/99 4:33p Imhof
//
// 2 1/23/99 9:50a Imhof
// If server list is empty no item is selected.
//
// 1 1/21/99 10:12a Imhof
//
//
// $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.html.*;
import opcdaauto.*;
import com.ms.com.*;
/**
* 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 'ConnectServer'
* created in the main() method.
*/
public class ConnectServer extends Form
{
public OPCServer server;
public String sOPCServer;
public int count = 0;
public ConnectServer()
{
super();
// Required for Visual J++ Form Designer support
initForm();
// TODO: Add any constructor code after initForm call
}
/**
* ConnectServer overrides dispose so it can clean up the
* component list.
*/
public void dispose()
{
super.dispose();
components.dispose();
}
private void Find_click(Object source, Event e)
{
Find();
}
private void Find()
{
ServerList.removeAll();
Variant Servers = new Variant();
Variant node = new Variant();
node.putString(ServerComputer.getText());
Servers = server.GetOPCServers(node);
SafeArray DA_Server = Servers.toSafeArray();
for(int i = 0; i < DA_Server.getUBound(); i++)
{
ServerList.addItem(DA_Server.getString(i + Server.vbArrayOffset));
}
if (ServerList.getItemCount() > 0)
ServerList.setSelected(0, true);
}
private void ServerList_selectedIndexChanged(Object source, Event e)
{
sOPCServer = (String)ServerList.getSelectedItem();
ServerName.setText(sOPCServer);
}
private void OnActivate(Object source, Event e)
{
// TODO: How many time is this called during activation ?
Find();
}
/**
* NOTE: The following code is required by the Visual J++ form
* designer. It can be modified using the form editor. Do not
* modify it using the code editor.
*/
Container components = new Container();
Button Cancel = new Button();
Button OK = new Button();
Edit ServerName = new Edit();
Label label1 = new Label();
Label label2 = new Label();
Edit ServerComputer = new Edit();
Label label3 = new Label();
ListBox ServerList = new ListBox();
Button Find = new Button();
private void initForm()
{
Cancel.setLocation(new Point(472, 48));
Cancel.setSize(new Point(80, 24));
Cancel.setTabIndex(0);
Cancel.setText("Cancel");
Cancel.setDialogResult(DialogResult.CANCEL);
OK.setLocation(new Point(472, 16));
OK.setSize(new Point(80, 24));
OK.setTabIndex(1);
OK.setText("OK");
OK.setDialogResult(DialogResult.OK);
this.setText("Connect to OPC Server");
this.setAcceptButton(OK);
this.setAutoScaleBaseSize(new Point(7, 16));
this.setBorderStyle(FormBorderStyle.FIXED_DIALOG);
this.setCancelButton(Cancel);
this.setClientSize(new Point(567, 241));
this.setMaximizeBox(false);
this.setMinimizeBox(false);
this.setShowInTaskbar(false);
this.addOnActivate(new EventHandler(this.OnActivate));
ServerName.setLocation(new Point(128, 16));
ServerName.setSize(new Point(328, 23));
ServerName.setTabIndex(3);
ServerName.setText("");
label1.setLocation(new Point(8, 16));
label1.setSize(new Point(64, 16));
label1.setTabIndex(4);
label1.setTabStop(false);
label1.setText("Server:");
label2.setLocation(new Point(8, 56));
label2.setSize(new Point(112, 16));
label2.setTabIndex(5);
label2.setTabStop(false);
label2.setText("Server Computer:");
ServerComputer.setLocation(new Point(128, 56));
ServerComputer.setSize(new Point(328, 23));
ServerComputer.setTabIndex(6);
ServerComputer.setText("");
label3.setLocation(new Point(8, 96));
label3.setSize(new Point(80, 16));
label3.setTabIndex(7);
label3.setTabStop(false);
label3.setText("Server List:");
ServerList.setLocation(new Point(128, 96));
ServerList.setSize(new Point(328, 132));
ServerList.setTabIndex(8);
ServerList.setText("listBox1");
ServerList.setUseTabStops(true);
ServerList.addOnSelectedIndexChanged(new EventHandler(this.ServerList_selectedIndexChanged));
Find.setLocation(new Point(472, 96));
Find.setSize(new Point(80, 24));
Find.setTabIndex(2);
Find.setText("&Find");
Find.addOnClick(new EventHandler(this.Find_click));
this.setNewControls(new Control[] {
Find,
ServerList,
label3,
ServerComputer,
label2,
label1,
ServerName,
OK,
Cancel});
}
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/
public static void main(String args[])
{
Application.run(new ConnectServer());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?