You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

482 lines
21 KiB

using Microsoft.AspNetCore.Mvc.ApplicationModels;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Service.PlcAfrica.Client;
using Service.PlcAfrica.Msg;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
namespace WinFormStarter
{
public partial class FrmAfrica : Form
{
//一直到24
public FrmAfrica()
{
InitializeComponent();
PlcAfricaMgr.PlcInit();
}
PlcAfricaClient PlcAfricaClient
{
get
{
return PlcAfricaMgr.PlcAfricaClient;
}
}
PlcAfricaMsg PlcAfricaMsg = PlcAfricaMgr.PlcAfricaMsg;
#region 1
private void button6_Click(object sender, EventArgs e)
{
if (!PlcAfricaMgr.PlcAfricaClient.Connected) return;
PlcAfricaMsg.TrafficLightFunction.Value = Convert.ToUInt16(tct11.Text);
bool bv= PlcAfricaMgr.PlcAfricaClient.WriteValue(PlcAfricaMsg.TrafficLightFunction);
}
private void BtnWrite01_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ModelCalibration.Value = Convert.ToUInt16(txt12.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ModelCalibration);
}
private void BtnWrite02_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryLocationCodeIn.Value = Convert.ToUInt16(txt13.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryLocationCodeIn);
}
private void BtnWrite03_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryLocationCodeUp.Value = Convert.ToUInt16(txt14.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryLocationCodeUp);
}
#endregion
#region 2
private void BtnWrite04_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.OperationInstruction.Value = Convert.ToUInt16(txt21.Text);
bool bv= PlcAfricaClient.WriteValue(PlcAfricaMsg.OperationInstruction);
}
/// <summary>
/// 换电模式切换
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnWrite05_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChangePowerMode.Value = Convert.ToUInt16(txt22.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChangePowerMode);
}
private void BtnWrite06_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryHeight.Value = Convert.ToUInt16(txt23.Text);
bool bv= PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryHeight);
}
private void BtnWrite07_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryLength.Value = Convert.ToUInt16(txt24.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryLength);
}
#endregion
#region 3
private void BtnWrite08_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryWidth.Value = Convert.ToUInt16(txt31.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryWidth);
}
private void BtnWrite09_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby01.Value = Convert.ToBoolean(txt32.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby01);
}
private void BtnWrite10_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby02.Value = Convert.ToBoolean(txt33.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby02);
}
private void BtnWrite11_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby03.Value = Convert.ToBoolean(txt34.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby03);
}
#endregion
#region 4
private void BtnWrite14_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby04.Value = Convert.ToBoolean(txt41.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby04);
}
private void BtnWrite15_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerCoolingFan1.Value = Convert.ToBoolean(txt42.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerCoolingFan1);
}
private void BtnWrite16_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerCoolingFan2.Value = Convert.ToBoolean(txt43.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerCoolingFan2);
}
private void BtnWrite17_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerCoolingFan3.Value = Convert.ToBoolean(txt44.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerCoolingFan3);
}
#endregion
#region 5
private void BtnWrite18_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerCoolingFan4.Value = Convert.ToBoolean(txt51.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerCoolingFan4);
}
private void button3_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby05.Value = Convert.ToBoolean(txt52.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby05);
}
private void button2_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby06.Value = Convert.ToBoolean(txt53.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby06);
}
private void button1_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby07.Value = Convert.ToBoolean(txt54.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby07);
}
#endregion
#region 6
private void button5_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.standby08.Value = Convert.ToBoolean(txt61.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.standby08);
}
private void button4_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BoardStatus1.Value = Convert.ToByte(txt62.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BoardStatus1);
}
private void button8_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.TboxUnlock.Value = Convert.ToUInt16(txt63.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
}
private void button7_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn1.Value = Convert.ToUInt16(txt64.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn1);
}
#endregion
#region 7
private void button12_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut1.Value = Convert.ToUInt16(txt71.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut1);
}
private void button11_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn2.Value = Convert.ToUInt16(txt72.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn2);
}
private void button10_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut2.Value = Convert.ToUInt16(txt73.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut2);
}
private void button9_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn3.Value = Convert.ToUInt16(txt74.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn3);
}
#endregion
#region 8
private void button16_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut3.Value = Convert.ToUInt16(txt81.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut3);
}
private void button15_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn4.Value = Convert.ToUInt16(txt82.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn4);
}
private void button14_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut4.Value = Convert.ToUInt16(txt83.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut4);
}
private void button13_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn5.Value = Convert.ToUInt16(txt84.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn5);
}
#endregion
#region 9
private void button20_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut5.Value = Convert.ToUInt16(txt91.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut5);
}
private void button19_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn6.Value = Convert.ToUInt16(txt92.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn6);
}
private void button18_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut6.Value = Convert.ToUInt16(txt93.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut6);
}
private void button17_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn7.Value = Convert.ToUInt16(txt94.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn7);
}
#endregion
#region 10
private void button24_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut7.Value = Convert.ToUInt16(txt101.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut7);
}
private void button23_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempIn8.Value = Convert.ToUInt16(txt102.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempIn8);
}
private void button22_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.ChargerTempOut8.Value = Convert.ToUInt16(txt103.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.ChargerTempOut8);
}
private void button21_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.FireAlarmSignal.Value = Convert.ToUInt16(txt104.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.FireAlarmSignal);
}
#endregion
#region 11
private void button28_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizeTakeLength.Value = Convert.ToUInt16(txt111.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizeTakeLength);
}
private void button27_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizeTakeWidth.Value = Convert.ToUInt16(txt112.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizeTakeWidth);
}
private void button26_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizeTakeHigh.Value = Convert.ToUInt16(txt113.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizeTakeHigh);
}
private void button25_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryTakeWeight.Value = Convert.ToUInt16(txt114.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryTakeWeight);
}
#endregion
#region 12
private void button32_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizePutLength.Value = Convert.ToUInt16(txt121.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizePutLength);
}
private void button31_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizePutWidth.Value = Convert.ToUInt16(txt122.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizePutWidth);
}
private void button30_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatterySizePutHigh.Value = Convert.ToUInt16(txt123.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatterySizePutHigh);
}
private void button29_Click(object sender, EventArgs e)
{
if (!PlcAfricaClient.Connected) return;
PlcAfricaMsg.BatteryWeight.Value = Convert.ToUInt16(txt124.Text);
PlcAfricaClient.WriteValue(PlcAfricaMsg.BatteryWeight);
}
#endregion
public void setvalue()
{
#region 1
lbl11.Text = PlcAfricaMgr.PlcAfricaMsg.PowerChangeMode.Value.ToString();
lbl21.Text = PlcAfricaMgr.PlcAfricaMsg.BatteryPositioning.Value.ToString();
lbl31.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode3.Value.ToString();
lbl41.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode9.Value.ToString();
lbl51.Text = PlcAfricaMgr.PlcAfricaMsg.RasterState.Value.ToString();
lbl61.Text = PlcAfricaMgr.PlcAfricaMsg.SlingDatteryAvailable.Value.ToString();
lbl71.Text = PlcAfricaMgr.PlcAfricaMsg.Loader1SeatSensor1.Value.ToString();
lbl81.Text = PlcAfricaMgr.PlcAfricaMsg.Loader4SeatSensor1.Value.ToString();
lbl91.Text = PlcAfricaMgr.PlcAfricaMsg.Loader7SeatSensor1.Value.ToString();
lbl101.Text = PlcAfricaMgr.PlcAfricaMsg.PlcHardwareVersion.Value.ToString();
lbl111.Text = PlcAfricaMgr.PlcAfricaMsg.OriginPositionState.Value.ToString();
#endregion
#region 2
lbl12.Text = PlcAfricaMgr.PlcAfricaMsg.PowerChangeModeRobot.Value.ToString();
lbl22.Text = PlcAfricaMgr.PlcAfricaMsg.YDisplacement.Value.ToString();
lbl32.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode4.Value.ToString();
lbl42.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode10.Value.ToString();
lbl52.Text = PlcAfricaMgr.PlcAfricaMsg.VehiclePositionSensor.Value.ToString();
lbl62.Text = PlcAfricaMgr.PlcAfricaMsg.AllWarehouseDoorsClosed.Value.ToString();
lbl72.Text = PlcAfricaMgr.PlcAfricaMsg.Loader1SeatSensor2.Value.ToString();
lbl82.Text = PlcAfricaMgr.PlcAfricaMsg.Loader4SeatSensor2.Value.ToString();
lbl92.Text = PlcAfricaMgr.PlcAfricaMsg.Loader7SeatSensor2.Value.ToString();
lbl102.Text = PlcAfricaMgr.PlcAfricaMsg.XAxisServoFaultCode.Value.ToString();
lbl112.Text = PlcAfricaMgr.PlcAfricaMsg.BackOriginState.Value.ToString();
#endregion
#region 3
lbl13.Text = PlcAfricaMgr.PlcAfricaMsg.SuspendedState.Value.ToString();
lbl23.Text = PlcAfricaMgr.PlcAfricaMsg.XDisplacement.Value.ToString();
lbl33.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode5.Value.ToString();
lbl43.Text = PlcAfricaMgr.PlcAfricaMsg.TwistlockSensor1.Value.ToString();
lbl53.Text = PlcAfricaMgr.PlcAfricaMsg.TwistlockSensor3.Value.ToString();
lbl63.Text = PlcAfricaMgr.PlcAfricaMsg.AllBarnDoorsOpen.Value.ToString();
lbl73.Text = PlcAfricaMgr.PlcAfricaMsg.Loader2SeatSensor1.Value.ToString();
lbl83.Text = PlcAfricaMgr.PlcAfricaMsg.Loader5SeatSensor1.Value.ToString();
lbl93.Text = PlcAfricaMgr.PlcAfricaMsg.Loader8SeatSensor1.Value.ToString();
lbl103.Text = PlcAfricaMgr.PlcAfricaMsg.Loader8SeatSensor2.Value.ToString();
lbl113.Text = PlcAfricaMgr.PlcAfricaMsg.TransferBinSeatSensor1.Value.ToString();
#endregion
#region 4
lbl14.Text = PlcAfricaMgr.PlcAfricaMsg.StationCommandFeedback.Value.ToString();
lbl24.Text = PlcAfricaMgr.PlcAfricaMsg.ZDisplacement.Value.ToString();
lbl34.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode6.Value.ToString();
lbl44.Text = PlcAfricaMgr.PlcAfricaMsg.TwistlockSensor2.Value.ToString();
lbl54.Text = PlcAfricaMgr.PlcAfricaMsg.TwistlockSensor4.Value.ToString();
//lbl64.Text =
lbl74.Text = PlcAfricaMgr.PlcAfricaMsg.Loader2SeatSensor2.Value.ToString();
lbl84.Text = PlcAfricaMgr.PlcAfricaMsg.Loader5SeatSensor2.Value.ToString();
lbl94.Text = PlcAfricaMgr.PlcAfricaMsg.Loader8SeatSensor2.Value.ToString();
lbl104.Text = PlcAfricaMgr.PlcAfricaMsg.YAxisServoFaultCode.Value.ToString();
lbl114.Text = PlcAfricaMgr.PlcAfricaMsg.TransferBinSeatSensor2.Value.ToString();
#endregion
#region 5
lbl15.Text = PlcAfricaMgr.PlcAfricaMsg.SendShutdown.Value.ToString();
lbl25.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode1.Value.ToString();
lbl35.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode7.Value.ToString();
lbl45.Text = PlcAfricaMgr.PlcAfricaMsg.SpreaderSeatSensor1.Value.ToString();
lbl55.Text = PlcAfricaMgr.PlcAfricaMsg.SpreaderSeatSensor3.Value.ToString();
//lbl65.Text =
lbl75.Text = PlcAfricaMgr.PlcAfricaMsg.Loader3SeatSensor1.Value.ToString();
lbl85.Text = PlcAfricaMgr.PlcAfricaMsg.Loader6SeatSensor1.Value.ToString();
lbl95.Text = PlcAfricaMgr.PlcAfricaMsg.ZAxisServoFaultCode.Value.ToString();
lbl105.Text = PlcAfricaMgr.PlcAfricaMsg.ZAxisServoFaultCode.Value.ToString();
#endregion
#region 6
lbl16.Text = PlcAfricaMgr.PlcAfricaMsg.ActionCode.Value.ToString();
lbl26.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode2.Value.ToString();
lbl36.Text = PlcAfricaMgr.PlcAfricaMsg.FaultCode8.Value.ToString();
lbl46.Text = PlcAfricaMgr.PlcAfricaMsg.SpreaderSeatSensor2.Value.ToString();
lbl56.Text = PlcAfricaMgr.PlcAfricaMsg.SpreaderSeatSensor4.Value.ToString();
//lbl76.Text =
lbl86.Text = PlcAfricaMgr.PlcAfricaMsg.Loader3SeatSensor2.Value.ToString();
lbl96.Text = PlcAfricaMgr.PlcAfricaMsg.Loader6SeatSensor2.Value.ToString();
lbl106.Text = PlcAfricaMgr.PlcAfricaMsg.PlcSoftwareVersion.Value.ToString();
lbl116.Text = PlcAfricaMgr.PlcAfricaMsg.BatteryLocationFaultCode.Value.ToString();
#endregion
}
private void button2_Click_1(object sender, EventArgs e)
{
setvalue();
}
}
}