📄 frmmain.cs
字号:
if (frm.ShowDialog()==DialogResult.OK )
{
if (frm.frmGroupName != Module1.GroupName)
{
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ServerHandle µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
if (YFOPCSDK.OPC_SetGroupName(Module1.ServerHandle, Module1.GroupHandle, frm.frmGroupName)!=0)
{
Module1.GroupName = frm.frmGroupName;
}
}
YFOPCSDK.OPC_SetGroupStat(Module1.ServerHandle, Module1.GroupHandle, frm.UpdateRate, frm.Active, frm.TimeBias, frm.DeadBand, 0);
}
}
public void mnuHelpAbout_Click(object eventSender, System.EventArgs eventArgs)
{
//VB6.ShowForm(frmAbout, VB6.FormShowConstants.Modal, this);
frmAbout frm = new frmAbout();
frm.ShowDialog();
}
public void mnuItemStatus_Click(object eventSender, System.EventArgs eventArgs)
{
if (lvListView.FocusedItem == null) return; // TODO: might not be correct. Was : Exit Sub
frmItemStatus frm = new frmItemStatus();
frm.ItemName = lvListView.FocusedItem.Text;
frm.ShowDialog();
}
public void mnuReadItem_Click(object eventSender, System.EventArgs eventArgs)
{
System.Windows.Forms.ListViewItem lvItem;
if (lvListView.FocusedItem == null) return; // TODO: might not be correct. Was : Exit Sub
object Var=new object();
double Ft=0.0;
Module1.FILETIME ftdt=new Module1.FILETIME();
short Quality=0;
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ServerHandle µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
if (YFOPCSDK.OPC_ReadItem(Module1.ServerHandle, Module1.GroupHandle, Module1.ItemArr[int.Parse(lvListView.FocusedItem.Tag.ToString())].Handle, ref Var, ref Ft, ref Quality)!=0)
{
ftdt = Module1.DoubleToFileTime(Ft);
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó Var µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ItemArr().Value µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
Module1.ItemArr[int.Parse(lvListView.FocusedItem.Tag.ToString())].Value = Var;
Module1.ItemArr[int.Parse(lvListView.FocusedItem.Tag.ToString())].Quality = Quality;
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ItemArr().Ft µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
Module1.ItemArr[int.Parse(lvListView.FocusedItem.Tag.ToString())].Ft = ftdt;
if (lvListView.FocusedItem.SubItems.Count > 1)
{
lvListView.FocusedItem.SubItems[1].Text = Var.ToString();
}
else
{
lvListView.FocusedItem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Var.ToString()));
}
//UPGRADE_WARNING: ¼¯ºÏ lvListView.SelectedItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvListView.FocusedItem.SubItems.Count > 2)
{
lvListView.FocusedItem.SubItems[2].Text = Quality.ToString();
}
else
{
lvListView.FocusedItem.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Quality.ToString()));
}
//UPGRADE_WARNING: ¼¯ºÏ lvListView.SelectedItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvListView.FocusedItem.SubItems.Count > 3)
{
lvListView.FocusedItem.SubItems[3].Text = Module1.FileTimeToDate(ftdt).ToString();
}
else
{
lvListView.FocusedItem.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Module1.FileTimeToDate(ftdt).ToString()));
}
}
}
public void mnuGroupRefresh_Click(object eventSender, System.EventArgs eventArgs)
{
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ServerHandle µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
YFOPCSDK.OPC_RefreshGroup(Module1.ServerHandle, Module1.GroupHandle, 1);
}
public void mnuRemoveItem_Click(object eventSender, System.EventArgs eventArgs)
{
System.Windows.Forms.ListViewItem lvItem;
if (lvListView.FocusedItem == null) return; // TODO: might not be correct. Was : Exit Sub
if (Module1.RemoveItem(int.Parse(lvListView.FocusedItem.Tag.ToString())))
{
lvListView.Items.RemoveAt(lvListView.FocusedItem.Index);
}
}
public void AddItem( string ItemName)
{
int Index;
System.Windows.Forms.ListViewItem lvItem;
Index = Module1.AddItemM(ref ItemName);
if (Index > 0)
{
//UPGRADE_WARNING: ¼¯ºÏ lvListView.ListItems µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
lvItem = lvListView.Items.Insert(0, "K" + Index.ToString(), ItemName, "");
// Debug.Print "K" + CStr(Index)
lvItem.Tag = Index.ToString();
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvItem.SubItems.Count > 1)
{
lvItem.SubItems[1].Text = "Bad";
}
else
{
lvItem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "Bad"));
}
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvItem.SubItems.Count > 2)
{
lvItem.SubItems[2].Text = "";
}
else
{
lvItem.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, ""));
}
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvItem.SubItems.Count > 3)
{
lvItem.SubItems[3].Text = "";
}
else
{
lvItem.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, ""));
}
}
}
public void RefreshItem(ref short Index)
{
// ERROR: Not supported in C#: OnErrorStatement
System.Windows.Forms.ListViewItem lvItem;
// Debug.Print Index
lvItem = lvListView.Items["K" + Index.ToString()];
//Index
if (lvItem == null) return; // TODO: might not be correct. Was : Exit Sub
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ItemArr().Value µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
if (lvItem.SubItems.Count > 1)
{
lvItem.SubItems[1].Text = Module1.ItemArr[Index].Value.ToString();
}
else
{
lvItem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Module1.ItemArr[Index].Value.ToString()));
}
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvItem.SubItems.Count > 2)
{
lvItem.SubItems[2].Text = Module1.ItemArr[Index].Quality.ToString();
}
else
{
lvItem.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Module1.ItemArr[Index].Quality.ToString()));
}
//UPGRADE_WARNING: ¼¯ºÏ lvItem µÄÏÂÏÞÒÑÓÉ 1 ¸ü¸ÄΪ 0¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"¡±
if (lvItem.SubItems.Count > 3)
{
lvItem.SubItems[3].Text = Module1.FileTimeToDate(Module1.ItemArr[Index].Ft).ToString();
}
else
{
lvItem.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Module1.FileTimeToDate(Module1.ItemArr[Index].Ft).ToString()));
}
}
public void mnuServerStatus_Click(object eventSender, System.EventArgs eventArgs)
{
double ftStart=0.0;
double ftCurrent=0.0;
double ftUpdate=0.0;
int BandWidth=0;
int GroupCount=0;
short MajorVersion=0;
short State=0;
short MinorVersion=0;
short BuildNumber=0;
string vendor=new string(' ',128);
if (YFOPCSDK.OPC_GetServerStatus(Module1.ServerHandle, ref ftStart, ref ftCurrent, ref ftUpdate, ref State, ref BandWidth,ref GroupCount, ref MajorVersion, ref MinorVersion, ref BuildNumber, vendor, 128)!=0)
{
frmServerStatus frm=new frmServerStatus();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ftStart µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text1.Text = Module1.FileTimeToDate(Module1.DoubleToFileTime(ftStart)).ToString();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ftCurrent µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text2.Text = Module1.FileTimeToDate(Module1.DoubleToFileTime(ftCurrent)).ToString();
frm.Text3.Text = Module1.FileTimeToDate(Module1.DoubleToFileTime(ftUpdate)).ToString();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó BandWidth µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text4.Text = BandWidth.ToString();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó State µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text5.Text = State.ToString();
frm.Text6.Text = GroupCount.ToString();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó MajorVersion µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text7.Text = MajorVersion.ToString();
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó MinorVersion µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
frm.Text8.Text = MinorVersion.ToString();
frm.Text9.Text = BuildNumber.ToString();
frm.ShowDialog();
}
}
public void mnuWriteItem_Click(object eventSender, System.EventArgs eventArgs)
{
int Index;
object Value;
if (lvListView.FocusedItem == null) return; // TODO: might not be correct. Was : Exit Sub
frmItemWrite frm = new frmItemWrite();
if (frm.ShowDialog()!= DialogResult.OK ) return; // TODO: might not be correct. Was : Exit Sub
if (frm.Value == "") return; // TODO: might not be correct. Was : Exit Sub
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó lvListView.SelectedItem.Tag µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
Index = int.Parse(lvListView.FocusedItem.Tag.ToString());
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó Value µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
Value = frm.Value;
//UPGRADE_WARNING: δÄܽâÎö¶ÔÏó ServerHandle µÄĬÈÏÊôÐÔ¡£ µ¥»÷ÒÔ»ñµÃ¸ü¶àÐÅÏ¢:¡°ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"¡±
if (YFOPCSDK.OPC_WriteItem(Module1.ServerHandle, Module1.GroupHandle, Module1.ItemArr[Index].Handle, Value, frm.Async)!=0)
{
Module1.ItemArr[Index].Value = Value;
if (lvListView.FocusedItem.SubItems.Count > 1)
{
lvListView.FocusedItem.SubItems[1].Text = Value.ToString();
}
else
{
lvListView.FocusedItem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Value.ToString()));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -