/// <summary> /// 设置可以交由用户设置的过功率保护的相关值 /// </summary> /// <param name="target_oppsignal">目标OPP信号值</param> /// <param name="species_name">产品种类</param> /// <param name="sp_mcu">使用到的串口</param> /// <returns></returns> public string McuControl_vSetOPPSignal(ushort target_oppsignal, Product.SpeciesName species_name, ref SerialPort sp_mcu) { string strInformation = string.Empty; byte[] value_1; switch (species_name) { case Product.SpeciesName.IG_M1102F: //1U 10A case Product.SpeciesName.IG_M1202F: //1U 20A case Product.SpeciesName.IG_M1302F: //1U 30A byte[] temp = BitConverter.GetBytes(target_oppsignal); value_1 = new byte[10]; //通用协议的设置方式 value_1[0] = 0x68; value_1[1] = 0x00; value_1[2] = 0x21; value_1[3] = 0xDE; value_1[4] = 0x03; value_1[5] = 0x00; value_1[6] = temp[0]; value_1[7] = temp[1]; value_1[8] = Convert.ToByte(value_1[5] + value_1[6] + value_1[7]); value_1[9] = 0x16; strInformation = McuControl_vCommandSend(value_1, ref sp_mcu); break; default: break; } return(strInformation); }
/// <summary> /// 对电源设置过功率点 /// </summary> /// <param name="product_Model">产品型号</param> /// <param name="op_signal_value">过功率信号对应值</param> /// <param name="sp_mcu">使用的串口</param> /// <returns>可能存在的异常</returns> public string McuControl_vSetOverpowrSignal(Product.SpeciesName product_Model, decimal op_signal_value, ref SerialPort sp_mcu) { string strInformation = string.Empty; byte[] value_1; int index = 0; int last_recount = 0; int temp = Convert.ToInt32(op_signal_value); switch (product_Model) { case Product.SpeciesName.IG_Z2071F: case Product.SpeciesName.IG_Z2102F: case Product.SpeciesName.IG_Z2102L: case Product.SpeciesName.IG_Z2121F: case Product.SpeciesName.IG_Z2181F: case Product.SpeciesName.IG_Z2182F: case Product.SpeciesName.IG_Z2182L: case Product.SpeciesName.IG_Z2272F: case Product.SpeciesName.IG_Z2272L: //应急照明电源的蜂鸣器工作时间 value_1 = new byte[9]; //通用协议的设置方式 value_1[0] = 0x68; value_1[1] = 0x00; value_1[2] = 0x03; value_1[3] = 0x68; value_1[4] = 0x22; value_1[5] = Convert.ToByte(((temp / 1000) << 4) | ((temp % 1000) / 100)); value_1[6] = Convert.ToByte((((temp % 100) / 10) << 4) | (temp % 10)); value_1[7] = Convert.ToByte(value_1[2] + value_1[4] + value_1[5] + value_1[6]); value_1[8] = 0x16; strInformation = McuControl_vCommandSend(value_1, ref sp_mcu); //等待回码之后将接收到的缓存数据清除 do { if ((sp_mcu.BytesToRead == last_recount) && (last_recount != 0) && (index > 20)) { break; } Thread.Sleep(15); last_recount = sp_mcu.BytesToRead; } while (++index < 100); if (sp_mcu.BytesToRead == 0) { return("过功率点设置异常"); } byte[] data = new byte[sp_mcu.BytesToRead]; sp_mcu.Read(data, 0, sp_mcu.BytesToRead); if (!((data[0] == 0x68) && (data[4] == 0x10))) { return("过功率点设置异常"); } break; default: break; } return(strInformation); }
public string McuControl_vSetBatUnderVoltage(ushort under_voltage, Product.SpeciesName species_name, ref SerialPort sp_mcu) { int index = 0; int last_recount = 0; string strInformation = string.Empty; byte[] value_1; if ((species_name >= Product.SpeciesName.IG_Z2071F) && (species_name <= Product.SpeciesName.IG_Z2272L)) { //应急照明电源的蜂鸣器工作时间 value_1 = new byte[9]; //通用协议的设置方式 value_1[0] = 0x68; value_1[1] = 0x00; value_1[2] = 0x03; value_1[3] = 0x68; value_1[4] = 0x28; value_1[5] = Convert.ToByte(((under_voltage / 1000) << 4) | ((under_voltage % 1000) / 100)); value_1[6] = Convert.ToByte((((under_voltage % 100) / 10) << 4) | (under_voltage % 10)); value_1[7] = Convert.ToByte(value_1[2] + value_1[4] + value_1[5] + value_1[6]); value_1[8] = 0x16; strInformation = McuControl_vCommandSend(value_1, ref sp_mcu); //等待回码之后将接收到的缓存数据清除 do { if ((sp_mcu.BytesToRead == last_recount) && (last_recount != 0) && (index > 20)) { break; } Thread.Sleep(15); last_recount = sp_mcu.BytesToRead; } while (++index < 100); if (sp_mcu.BytesToRead == 0) { return("备电欠压点设置异常"); } byte[] data = new byte[sp_mcu.BytesToRead]; sp_mcu.Read(data, 0, sp_mcu.BytesToRead); if (!((data[0] == 0x68) && (data[4] == 0x10))) { return("备电欠压点设置异常"); } } return(strInformation); }
public string McuControl_vSetBeepTime(ushort target_beeptime, Product.SpeciesName species_name, ref SerialPort sp_mcu) { int index = 0; int last_recount = 0; string strInformation = string.Empty; byte[] value_1; sp_mcu.ReadExisting(); if ((species_name >= Product.SpeciesName.IG_Z2071F) && (species_name <= Product.SpeciesName.IG_Z2272L)) { //应急照明电源的蜂鸣器工作时间 value_1 = new byte[9]; //通用协议的设置方式 value_1[0] = 0x68; value_1[1] = 0x00; value_1[2] = 0x03; value_1[3] = 0x68; value_1[4] = 0x2A; value_1[5] = Convert.ToByte(((target_beeptime / 1000) << 4) | ((target_beeptime % 1000) / 100)); value_1[6] = Convert.ToByte((((target_beeptime % 100) / 10) << 4) | (target_beeptime % 10)); value_1[7] = Convert.ToByte(value_1[2] + value_1[4] + value_1[5] + value_1[6]); value_1[8] = 0x16; strInformation = McuControl_vCommandSend(value_1, ref sp_mcu); //等待回码之后将接收到的缓存数据清除 do { if ((sp_mcu.BytesToRead == last_recount) && (last_recount != 0) && (index > 20)) { break; } Thread.Sleep(15); last_recount = sp_mcu.BytesToRead; } while (++index < 100); if (sp_mcu.BytesToRead == 0) { return("蜂鸣器工作时间设置异常"); } byte[] data = new byte[sp_mcu.BytesToRead]; sp_mcu.Read(data, 0, sp_mcu.BytesToRead); if (!((data[0] == 0x68) && (data[4] == 0x10))) { return("蜂鸣器工作时间设置异常"); } } else if ((species_name == Product.SpeciesName.IG_M1202F) || (species_name == Product.SpeciesName.IG_M1102F) || (species_name == Product.SpeciesName.IG_M1302F)) { value_1 = new byte[9]; //通用协议的设置方式 value_1[0] = 0x68; value_1[1] = 0x00; value_1[2] = 0x2C; value_1[3] = 0xD3; value_1[4] = 0x02; Byte[] temp = BitConverter.GetBytes(target_beeptime); value_1[5] = temp[0]; if (temp.Length > 1) { value_1[6] = temp[1]; } else { value_1[6] = 0; } value_1[7] = Convert.ToByte(value_1[5] + value_1[6]); value_1[8] = 0x16; strInformation = McuControl_vCommandSend(value_1, ref sp_mcu); } return(strInformation); }
/// <summary> /// 为单片机发送金手指命令,将通讯协议更换为管理员模式 /// </summary> /// <param name="species_name">电源产品的类型的枚举</param> /// <param name="sp_mcu">信号测试单片机使用到的串口</param> /// <returns>可能存在的异常信息</returns> public string McuControl_vInitialize(Product.SpeciesName species_name, ref SerialPort sp_mcu) { string strInformation = string.Empty; byte[] golden_finger; switch (species_name) { case Product.SpeciesName.IG_B1031F__IG_B03S01: break; case Product.SpeciesName.IG_X1032F: /*3A箱式电源*/ golden_finger = new byte[] { 0xA5, 0x77, 0x30, 0x01, 0x4D }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_X1041F: /*海湾箱式5A*/ case Product.SpeciesName.IG_X1061F: /*海湾箱式6A*/ case Product.SpeciesName.IG_X1101F: /*海湾箱式10A*/ case Product.SpeciesName.IG_X1101H: /*海湾箱式10A*/ case Product.SpeciesName.IG_X1201F: /*海湾箱式20A*/ case Product.SpeciesName.IG_X1301F: /*海湾箱式30A*/ case Product.SpeciesName.IG_B1061F__IG_B06S01: /*海湾壁挂式6A*/ case Product.SpeciesName.IG_B1032F: case Product.SpeciesName.IG_B2032F: /*声讯电子 12V3A*/ case Product.SpeciesName.IG_B2032H: case Product.SpeciesName.IG_B2022F: /*24V 2A*/ case Product.SpeciesName.IG_M1102H: /*泛海三江1U电源改10A*/ case Product.SpeciesName.IG_M1202H: /*泛海三江1U电源改20A*/ case Product.SpeciesName.GST_LD_D02H: case Product.SpeciesName.IG_M2121F: case Product.SpeciesName.IG_B2108: case Product.SpeciesName.IG_M3201F__20A主机电源: case Product.SpeciesName.GST_LD_D06H: case Product.SpeciesName.IG_M2202F: /*泰和安20A*/ case Product.SpeciesName.IG_M3302F: /*泰和安30A*/ golden_finger = new byte[] { 0xA5, 0x30, 0x01, 0xD6 }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_M3202F: //泰和安通讯版本 golden_finger = new byte[] { 0xE6, 0x03, 0xDF, 0x5F, 0xD1 }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_X1101K: //泰和安 需求10A箱式 case Product.SpeciesName.IG_M2102F: //1U 2A 8A case Product.SpeciesName.IG_M2132F: case Product.SpeciesName.IG_M3242F: //1U 8A 8A 8A case Product.SpeciesName.IG_M1102F: //1U 10A case Product.SpeciesName.IG_M1202F: //1U 20A case Product.SpeciesName.IG_M1302F: //1U 30A case Product.SpeciesName.IG_B2053F: //兼容2055电源 case Product.SpeciesName.IG_B2053H: case Product.SpeciesName.IG_B2053K: case Product.SpeciesName.IG_B2073F: case Product.SpeciesName.IG_B1051H: case Product.SpeciesName.IG_M1101H: //尼特所需1U 10A电源 golden_finger = new byte[] { 0x68, 0x00, 0xAB, 0x54, 0x01, 0x00, 0x00, 0x16 }; //通用协议的校准方式 strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_M2131H: golden_finger = new byte[] { 0x02, 0x30, 0x01, 0x33 }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_M1101F__IG_M10S01: break; case Product.SpeciesName.IG_B2031F__IG_B03D01: break; case Product.SpeciesName.IG_B2031G__IG_B03D02: break; case Product.SpeciesName.IG_B2031H__IG_B03D03: break; case Product.SpeciesName.J_EI8212: /*依爱两路隔离10A电源*/ golden_finger = new byte[] { 0x68, 0x09, 0x09, 0x68, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x10, 0x30, 0x01, 0x01, 0x40, 0x16 }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_B1061H: golden_finger = new byte[] { 0x55, 0x88, 0x01, 0x89, 0xED }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; case Product.SpeciesName.IG_Z2071F: //应急照明电源 3节电池 300W case Product.SpeciesName.IG_Z2102F: //应急照明电源 2节电池 300W case Product.SpeciesName.IG_Z2121F: //应急照明电源 3节电池 500W case Product.SpeciesName.IG_Z2182F: //应急照明电源 2节电池 500W case Product.SpeciesName.IG_Z2181F: //应急照明电源 3节电池 750W case Product.SpeciesName.IG_Z2272F: //应急照明电源 2节电池 750W case Product.SpeciesName.IG_Z2102L: //赋安专用应急照明电源 2节电池 300W case Product.SpeciesName.IG_Z2182L: //赋安专用应急照明电源 2节电池 500W case Product.SpeciesName.IG_Z2272L: //赋安专用应急照明电源 2节电池 750W case Product.SpeciesName.IG_Z1203F: //海湾应急照明电源 2节电池 800W 升压 case Product.SpeciesName.IG_Z2244F: //其他用户应急照明电源 3节电池 1000W golden_finger = new byte[] { 0x68, 0x00, 0x01, 0x68, 0xA9, 0xAA, 0x16 }; strInformation = McuControl_vCommandSend(golden_finger, ref sp_mcu); break; default: break; } return(strInformation); }