public void Fn_CircleEle(object sender, EventArgs e) { switch (cireEleNum) { case 4: volNum4.Value = (decimal)1.2; cireEleNum--; break; case 3: volNum4.Value = (decimal)1.08; cireEleNum--; break; case 2: volNum4.Value = (decimal)1.2; cireEleNum--; break; case 1: volNum4.Value = (decimal)1.32; cireEleNum = 4; break; } int error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, 4, (double)volNum4.Value, ""); }
private void closeAllBtn_Click(object sender, EventArgs e) { int error = 0; string strMsg = ""; for (int ChanID = 1; ChanID <= 4; ChanID++) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, 0, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { switch (ChanID) { case 1: // SPC1.Value = false; break; case 2: // SPC2.Value = false; break; case 3: // SPC3.Value = false; break; case 4: // SPC4.Value = false; break; } } } }
private void runCurBtn_Click(object sender, EventArgs e) { string strMsg = ""; int error = 0; if (pupleFirstCB.Checked == true) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, 1, 1, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { //SPC1.Value = true; } } if (pupleSecondCB.Checked == true) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, 2, 1, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { //SPC2.Value = true; } } if (pupleThirdCB.Checked == true) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, 3, 1, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { //SPC3.Value = true; } } if (pupleFourthCB.Checked == true) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, 4, 1, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { //SPC4.Value = true; } } }
/****************************************************************************************** * 函数原型:CloseSpecificInstrument(string strInstruName) * 函数功能:断开指定的仪器的网络连接 * 输入参数:strInstruName,仪器名字 * 输出参数: * 创 建 者:yzx * 创建日期:2016.7.27 * 修改说明: * */ public static int CloseSpecificInstrument(string strInstruName) { int error = 0; if (strInstruName == "电源") { if (CGloabal.g_InstrPowerModule.nHandle > 0) { error = Power_Driver.Close(CGloabal.g_InstrPowerModule.nHandle, 0, strError); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, "电源断开失败"); } else//断开成功,要将此时的连接状态更新到仪器参数中 { CGloabal.g_InstrPowerModule.bInternet = false; } } } else if (strInstruName == "示波器") { if (CGloabal.g_InstrScopeModule.nHandle > 0) { error = Oscilloscope_Driver.Close(CGloabal.g_InstrScopeModule.nHandle, 0, ref strError); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, "示波器断开失败"); } else//断开成功,要将此时的连接状态更新到仪器参数中 { CGloabal.g_InstrScopeModule.bInternet = false; } } } else if (strInstruName == "万用表") { if (CGloabal.g_InstrPowerModule.nHandle > 0) { error = Multimeter_Driver.Close(); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, "信号发生器断开失败"); } else//断开成功,要将此时的连接状态更新到仪器参数中 { CGloabal.g_InstrPowerModule.bInternet = false; } } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.error, "错误的仪器名"); return(-1); } return(error); }
private void btnOff_Click(object sender, EventArgs e) { int error = 0; string strMsg = ""; //btnLight1.BackColor = Color.WhiteSmoke; //btnLight2.BackColor = Color.WhiteSmoke; //btnLight3.BackColor = Color.WhiteSmoke; //btnLight4.BackColor = Color.WhiteSmoke; //btnLight5.BackColor = Color.WhiteSmoke; //btnLight6.BackColor = Color.WhiteSmoke; //btnLight7.BackColor = Color.WhiteSmoke; //btnLight8.BackColor = Color.WhiteSmoke; for (int ChanID = 1; ChanID <= 4; ChanID++) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, ChanID, 0, ref strMsg); if (error < 0) { CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); } else { switch (ChanID) { case 1: btnLight1.BackColor = Color.WhiteSmoke; btnLight2.BackColor = Color.WhiteSmoke; break; case 2: btnLight3.BackColor = Color.WhiteSmoke; btnLight4.BackColor = Color.WhiteSmoke; break; case 3: btnLight5.BackColor = Color.WhiteSmoke; btnLight6.BackColor = Color.WhiteSmoke; break; case 4: btnLight7.BackColor = Color.WhiteSmoke; btnLight8.BackColor = Color.WhiteSmoke; break; } } } }
private void openAllBtn_Click(object sender, EventArgs e) { int error = 0; string strMsg = ""; for (int ChanID = 1; ChanID <= 4; ChanID++) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, 1, ref strMsg); if (error < 0) { strMsg = string.Format("电源通道{0}打开失败", ChanID); CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); return; } else { switch (ChanID) { case 1: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)volOut1.Value, strMsg); error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)eleOut1.Value, strMsg); //SPC1.Value = true; break; case 2: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)volOut2.Value, strMsg); error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)eleOut2.Value, strMsg); //SPC2.Value = true; break; case 3: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)volOut3.Value, strMsg); error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)eleOut3.Value, strMsg); //SPC3.Value = true; break; case 4: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)volOut4.Value, strMsg); error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, ChanID, (double)eleOut4.Value, strMsg); // SPC4.Value = true; break; } } } }
public void Fn_ReadVolAndEle(object sender, EventArgs e) { string strErrMsg = ""; int error; double voltage1 = 0, eletage1 = 0; double voltage2 = 0, eletage2 = 0; if (btnElect.Text == "关闭") { error = Power_Driver.ReadVoltage(CGloabal.g_InstrPowerModule.nHandle, 3, strErrMsg, ref voltage1); error = Power_Driver.ReadCurrent(CGloabal.g_InstrPowerModule.nHandle, 3, strErrMsg, ref eletage1); vol1.Text = voltage1.ToString("0.00000"); ele1.Text = eletage1.ToString("0.00000"); error = Power_Driver.ReadVoltage(CGloabal.g_InstrPowerModule.nHandle, 4, strErrMsg, ref voltage2); error = Power_Driver.ReadCurrent(CGloabal.g_InstrPowerModule.nHandle, 4, strErrMsg, ref eletage2); vol2.Text = voltage2.ToString("0.00000"); ele2.Text = eletage2.ToString("0.00000"); } }
/****************************************************************************************** * 函数原型:ConnectSpecificInstrument(string strInstruName,string resourceName) * 函数功能:根据输入的仪器名进行连接。连接后的句柄存储在相应的句柄参数中 * 输入参数:strInstruName,仪器名字;resourceName,资源名字,用于VISA连接 * 输出参数: * 创 建 者:yzx * 创建日期:2016.7.27 * 修改说明: * */ public static int ConnectSpecificInstrument(string strInstruName, string resourceName) { int error = 0; if (strInstruName == "电源") { if (CGloabal.g_InstrPowerModule.nHandle == 0) { error = Power_Driver.Init(resourceName, ref CGloabal.g_InstrPowerModule.nHandle, CGloabal.g_nSimulteFlag, strError); if (error < 0) { CGloabal.g_InstrPowerModule.bInternet = false; CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrPowerModule.strInstruName + "连接失败"); } else { CGloabal.g_InstrPowerModule.bInternet = true; } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrPowerModule.strInstruName + "已经处于连接状态"); } } else if (strInstruName == "示波器") { if (CGloabal.g_InstrScopeModule.nHandle == 0) { error = Oscilloscope_Driver.Init(resourceName, CGloabal.g_nSimulteFlag, ref CGloabal.g_InstrScopeModule.nHandle, ref strError); if (error < 0) { CGloabal.g_InstrScopeModule.bInternet = false; CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrScopeModule.strInstruName + "连接失败"); } else { CGloabal.g_InstrScopeModule.bInternet = true; } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrScopeModule.strInstruName + "已经处于连接状态"); } } else if (strInstruName == "信号发生器") { if (CGloabal.g_InstrSignalModule.nHandle == 0) { error = Signal_Driver.Init(resourceName, ref CGloabal.g_InstrSignalModule.nHandle, strError); if (error < 0) { CGloabal.g_InstrPowerModule.bInternet = false; CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrN5751AModule.strInstruName + "连接失败"); } else { CGloabal.g_InstrPowerModule.bInternet = true; } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrPowerModule.strInstruName + "已经处于连接状态"); } } else if (strInstruName == "N5751A") { if (CGloabal.g_InstrN5751AModule.nHandle == 0) { error = N5751A_Driver.Init(resourceName, ref CGloabal.g_InstrN5751AModule.nHandle, CGloabal.g_nSimulteFlag, strError); if (error < 0) { CGloabal.g_InstrPowerModule.bInternet = false; CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrN5751AModule.strInstruName + "连接失败"); } else { CGloabal.g_InstrPowerModule.bInternet = true; } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrPowerModule.strInstruName + "已经处于连接状态"); } } else { CCommonFuncs.ShowHintInfor(eHintInfoType.error, "错误的仪器名"); return(-1); } return(error); }
private void btnSet_Click(object sender, EventArgs e) { int error; string strMsg = ""; //btnLight1.BackColor = Color.LightGreen; //btnLight2.BackColor = Color.LightGreen; //btnLight3.BackColor = Color.LightGreen; //btnLight4.BackColor = Color.LightGreen; //btnLight5.BackColor = Color.LightGreen; //btnLight6.BackColor = Color.LightGreen; //btnLight7.BackColor = Color.LightGreen; //btnLight8.BackColor = Color.LightGreen; if (btnElect.Text == "关闭")//用户要连接仪器 { for (int ChanID = 1; ChanID <= 4; ChanID++) { error = Power_Driver.isEnableChannel(CGloabal.g_InstrPowerModule.nHandle, ChanID, 1, ref strMsg); if (error < 0) { strMsg = string.Format("电源通道{0}打开失败", ChanID); CCommonFuncs.ShowHintInfor(eHintInfoType.error, strMsg); return; } else { switch (ChanID) { case 1: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)volNum1.Value, strMsg); btnLight1.BackColor = Color.LightGreen; error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)eleNum1.Value, strMsg); btnLight2.BackColor = Color.LightGreen; break; case 2: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)volNum2.Value, strMsg); btnLight3.BackColor = Color.LightGreen; error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)eleNum2.Value, strMsg); btnLight4.BackColor = Color.LightGreen; break; case 3: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)volNum3.Value, strMsg); btnLight5.BackColor = Color.LightGreen; error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)eleNum3.Value, strMsg); btnLight6.BackColor = Color.LightGreen; break; case 4: error = Power_Driver.SetOutputVoltage(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)volNum4.Value, strMsg); btnLight7.BackColor = Color.LightGreen; error = Power_Driver.SetMaxElectricityVal(CGloabal.g_InstrPowerModule.nHandle, ChanID, (double)eleNum4.Value, strMsg); btnLight8.BackColor = Color.LightGreen; break; } } } } else { MessageBox.Show("请先打开电源"); } }