private void LoadPublicElectricInfo() { PublicElectricControl electricControl = new PublicElectricControl(); electricControl.Name = "electricControl"; if (!DicPublicElectricInfo.ContainsKey(electricControl.Name)) { DicPublicElectricInfo.Add(electricControl.Name, electricControl); } }
public void MeasurePowerVoltageandCurrent(Object pc) { PowerControl.PowerInit(PowerSourceName); PowerControl.PowerOutput(12, true); StringBuilder PowerVal = new StringBuilder(); CurrentElectricValue value = new CurrentElectricValue(); // Random rd1 = new Random(); int count = 0; while (true) { PowerControl.MeasurePowerOutput(out PowerVoltage, out PowerCurrent); // PowerVoltage=rd1.Next(1,100); // PowerCurrent = rd1.Next(1, 100); // foreach (var item in DicMeasurTempSwitch) if (MeasurePowerSwitch) { // if (item.Value) { count++; PowerVal.Append(PowerVoltage.ToString() + "," + PowerCurrent.ToString() + Environment.NewLine); if (count > 120) { count = 0; FileOperation.createFile(PowerFilePath, PowerFileName, PowerVal.ToString()); PowerVal.Clear(); } } } Thread.Sleep(1000); value.now = DateTime.Now; value.currentValue = (float)PowerCurrent; value.voltageValue = (float)PowerVoltage; PublicElectricControl pc2 = new PublicElectricControl(); pc2 = (PublicElectricControl)pc; pc2.ChartValueFill(value); } }