📄 inittermserver.java
字号:
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
case 2:
sendBuffer("su\n", 0);
m_TelNet.m_buffer = ("Password>");
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
case 3:
sendBuffer("iolan\n", 0);
m_TelNet.m_buffer = (">");
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
default:
CFunction.writeToSystem(this.m_CommDebug,
"### logon terminal server over ...");
retvalue = 1;
break;
}
m_Count++;
return (retvalue);
}
int colseTs() {
int m_success_flag = -1;
while (true) {
if (m_ErroeCount > 1) {
CFunction.writeToSystem(this.m_CommDebug, "Cannot initial");
break;
}
analyseReceivedData();
int m_RetCode = decideCloseCommand();
if (m_RetCode == 1) {
CFunction.writeToSystem(this.m_CommDebug, "Succeed in initializing");
}
if (m_RetCode < 0 || m_RetCode == 1) {
m_success_flag = 1;
break;
}
}
return m_success_flag;
}
int decideCloseCommand() {
String buf2;
m_Count = 1;
int retvalue = 0;
switch (m_Count) {
default:
try {
Thread.sleep(500);
}
catch (InterruptedException m_InterruptedException) {
CFunction.writeToSystem(this.m_CommDebug, "sleep error !!!...");
}
sendBuffer("logout\n", 1); //new_ts
try {
Thread.sleep(500);
}
catch (InterruptedException m_InterruptedException) {
CFunction.writeToSystem(this.m_CommDebug, "sleep error !!!...");
}
sendBuffer("\n", 1); //new_ts
retvalue = 1;
break;
}
m_Count++;
return (retvalue);
}
int modiConfig() {
int m_success_flag = -1;
while (true) {
if (m_ErroeCount > 1) {
CFunction.writeToSystem(this.m_CommDebug, "Cannot initial");
break;
}
analyseReceivedData();
int m_RetCode = decideNextModification(this.m_PortNo);
if (m_RetCode < 0 || m_RetCode == 1) {
m_success_flag = 1;
break;
}
}
return m_success_flag;
}
int decideNextModification(int m_PortNum) {
int i, m_PortNo, retvalue;
String buf2;
if (m_TelNet.m_flag == 0) {
return (0);
}
retvalue = 0;
switch (m_Count) {
case 0: {
CFunction.writeToSystem(this.m_CommDebug,
"### begin to send SET PORT HARDWARE report ...");
buf2 = "set port "
+ (new Integer(m_PortNum + 1)).toString()
+ " hardware\n";
sendBuffer(buf2, 0);
m_TelNet.m_buffer = "Speed";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 1: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi speed .....");
int baud = (int) m_PortConfig.getBaudRate();
String m_str = "\b\b\b\b\b\b\b" + new Integer(baud).toString() + "\n";
CollectorDefine.SystemPrintln(m_str);
sendBuffer(m_str, 1);
m_TelNet.m_buffer = "Parity";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 2: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi parity .....");
switch ( (int) m_PortConfig.getParityBit()) {
case 0:
buf2 = "None";
break;
case 1:
buf2 = "Odd";
break;
case 2:
buf2 = "Even";
break;
default:
buf2 = "";
break;
}
String m_str = "\b\b\b\b\b" + buf2 + "\n";
CollectorDefine.SystemPrintln(m_str);
sendBuffer(m_str, 1);
m_TelNet.m_buffer = ("Bit");
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 3: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi databit .....");
int m_data_bit = m_PortConfig.getDataBit();
CollectorDefine.SystemPrintln("m_data_bit " + m_data_bit);
String m_str = "\b\b" + (new Integer(m_data_bit)).toString() + "\n";
CollectorDefine.SystemPrintln(m_str);
// sendBuffer("\n",1);
sendBuffer(m_str, 1);
m_TelNet.m_buffer = "Stop";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 4: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi stopbit .....");
int stop = m_PortConfig.getStopBit();
switch (stop) {
case 0:
buf2 = "1";
break;
case 1:
buf2 = "1.5";
break;
case 2:
buf2 = "2";
break;
default:
buf2 = "1";
break;
}
String m_str = "\b\b\b" + buf2 + "\n";
CollectorDefine.SystemPrintln(m_str);
sendBuffer(m_str, 1);
m_TelNet.m_buffer = ("Break");
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 5: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi Moitor DSR .....");
sendBuffer("\n", 1);
m_TelNet.m_buffer = "Monitor DSR";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 6: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi Moitor DCD .....");
sendBuffer("\n", 1);
m_TelNet.m_buffer = "Monitor DCD";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
case 7: {
CFunction.writeToSystem(this.m_CommDebug,
"### ready to modi Over .....");
sendBuffer("\n", 1);
m_TelNet.m_buffer = ">";
m_TelNet.m_type = STRING;
m_TelNet.m_flag = 0;
break;
}
default:
CFunction.writeToSystem(this.m_CommDebug, "### config OVER....");
try {
Thread.sleep(100);
retvalue = 1;
}
catch (InterruptedException m_InterruptedException) {
CollectorDefine.SystemPrintln("sleep error !!! ...");
}
break;
}
m_Count++;
return (retvalue);
}
public int connectTerminalConfig() {
clearFlag("password", 1);
return connectTs();
}
public int modiTerminalConfigure(PortConfig m_PortConfig, int m_PortNum) {
setPortConfig(m_PortConfig, m_PortNum);
clearFlag("", 0);
return modiConfig();
}
public int closeTerminlConfigure() {
clearFlag("", 0);
colseTs();
return closeTcp();
}
/**********************************************************************/
/**** THIS MAIN PROCESS IS ONLY FOR TEST !!!!!
***********************************************************************/
/*
public static void main(String args[]) {
String dbHost = "localhost";
String buf2;
String orderbuf;
try {
if (args.length > 0) {
dbHost = args[0];
}
InitTermServer m_InitTermServer = new InitTermServer("chase", 1);
int m_flag = m_InitTermServer.initTcp("chase", 23);
if (m_flag <= 0) {
// CollectorDefine.SystemPrintln("init m_PortNo 23 failed ......");
return;
}
PortConfig m_PortConfig = new PortConfig(0, 7, 300, 2, 2);
m_InitTermServer.setPortConfig(m_PortConfig, 0);
m_InitTermServer.clearFlag("password", 1);
m_InitTermServer.connectTs();
m_InitTermServer.clearFlag("", 0);
m_InitTermServer.readConfig(0);
m_InitTermServer.clearFlag("", 0);
m_InitTermServer.modiConfig();
m_InitTermServer.clearFlag("", 0);
m_InitTermServer.colseTs();
m_InitTermServer.closeTcp();
}
catch (Exception e) {
CFunction.putHintString(1,
"sendString in CommSocket Error #1 " + "IP地址:" + this.m_IpAddress +
"端口号:" + this.m_PortNo + m_IOException.getMessage());
}
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -