private void TcpServer_DataReceived(object sender, AsyncEventArgs e) { byte[] a = e._state.Buffer; int length = e._state.RecLength; var Temp = a.Skip(0).Take(length).ToArray(); if (Encoding.Default.GetString(Temp) == "Flag") { SendBytcp(new byte[] { (byte)Flag }); } SendDataToclient(); string jsondata = JsonSoltion.Getjsonstr(Temp, ref Flag); if (null != jsondata && Flag == -1) { RefreshUi(jsondata); WorkingSets.local.updateJob(); StartTcptest(jsondata); } else { SendBytcp(new byte[] { (byte)Flag }); } }
/// <summary> /// 测试用例Location /// </summary> public void SendDataToclient() { var temp = TcpTask.TcpServer._clients.ToArray(); foreach (var p in temp) { #region Transformer ts = new Transformer() { SerialNo = "SerialNo", Location = "方巷", ApparatusID = "ApparatusID", Manufacturer = "Manufacturer", ProductionYear = "ProductionYear", AssetSystemCode = "AssetSystemCode", MethonID = "MethonID", WindingNum = 3, WindingConfig = new TransformerWindingConfigStruct { HV = TransformerWindingConfigName.Yn, MV = TransformerWindingConfigName.Yn, LV = TransformerWindingConfigName.D, MVLabel = 0, LVLabel = 11 }, RatingFrequency = 50, PhaseNum = 3, VoltageRating = new TransformerRatingStruct { HV = 220, MV = 110, LV = 35 }, PowerRating = new TransformerRatingStruct { HV = 240, MV = 240, LV = 120 }, Bushing = new BushingStruct { HVContained = true, MVContained = true }, OLTC = new OLTCStruct { Contained = true, TapMainNum = 1, WindingPositions = 0, TapNum = 1, SerialNo = "SerialNo", ModelType = "ModelType", Manufacturer = "Manufacturer", ProductionYear = "ProductionYear", Step = 0.02 }, Coupling = false }; var trs = Encoding.Default.GetBytes("Transformer" + JsonSoltion.GetJsonByclass(ts)); var q = Encoding.Default.GetBytes("Location" + JsonSoltion.GetJsonByclass(new Location() { company = "上海思创", address = "鹿吉路401", name = "变压器001", operatorName = "xw" })); var job = Encoding.Default.GetBytes("JobList" + JsonSoltion.GetJsonByclass( new JobList { Name = "testname", Transformer = ts, DCInsulation = new WindingJobList { HVEnabled = true, MVEnabled = true, LVEnabled = true, ZcEnable = true, Enabled = false }, Capacitance = new WindingJobList { HVEnabled = true, MVEnabled = true, LVEnabled = true, ZcEnable = true, Enabled = true }, DCResistance = new WindingJobList { HVEnabled = true, MVEnabled = true, LVEnabled = true, ZcEnable = true, Enabled = true }, Bushing = new BushingJobList { DCInsulation = true, Capacitance = true }, OLTC = new OLTCJobList { Range = 1, DCResistance = true, SwitchingCharacter = true, Enabled = true }, Parameter = new JobParameter { DCInsulationVoltage = 1000, DCInsulationResistance = 3, DCInsulationAbsorptionRatio = 1.3, CapacitanceVoltage = 1000, DCResistanceCurrent = 15, DCHvResistanceCurrent = 5, DCLvResistanceCurrent = 5, DCMvResistanceCurrent = 5, BushingCapacitanceVoltage = 1000, BushingDCInsulationVoltage = 1000 }, Information = new JobInformation { testingTime = DateTime.Now, oilTemperature = 20.6, testingName = "InformationtestingName", tester = "xuwei", testingAgency = "testingAgency", auditor = "auditor", approver = "approver", weather = "weather", temperature = "25", humidity = "50", principal = "principal" } } )); #endregion var str = Encoding.Default.GetBytes("JobTest" + JsonSoltion.GetJsonByclass(new TcpJobTest { TransformerID = ts.SerialNo, JobName = "testname", Information = new JobInformation { testingTime = DateTime.Now, oilTemperature = 20.6, testingName = "InformationtestingName", tester = "xuwei", testingAgency = "testingAgency", auditor = "auditor", approver = "approver", weather = "weather", temperature = "25", humidity = "50", principal = "principal" } })); TcpTask.TcpServer.Send((TCPClientState)p, trs); TcpTask.TcpServer.Send((TCPClientState)p, q); TcpTask.TcpServer.Send((TCPClientState)p, job); TcpTask.TcpServer.Send((TCPClientState)p, str); } }