Commit 90c6b431 LN

1

1 个父辈 b7962bf7
正在显示 31 个修改的文件 包含 606 行增加254 行删除
......@@ -15,6 +15,7 @@ namespace OnlineStore.AssemblyLine
{
internal static string GetVersion(bool IsShow=false)
{
string str = "";
string version = "";
DateTime newData = DateTime.Parse("2000-01-01");
......@@ -53,7 +54,8 @@ namespace OnlineStore.AssemblyLine
}
internal FrmBase()
{
InitializeComponent();
}
InitializeComponent();
}
}
}
......@@ -135,7 +135,62 @@ namespace OnlineStore.AssemblyLine
}
}
internal virtual void FormStatus(bool status)
{
{
}
protected List<Control> doList = new List<Control>();
protected void LoadDOBtn(GroupBox group)
{
doList = new List<Control>();
foreach (Control c in group.Controls)
{
if (c is Button)
{
if (equipBase.baseConfig.DOList.ContainsKey(c.Name))
{
doList.Add(c);
}
else if (c.Name.ToUpper().StartsWith("BTN"))
{
c.Visible = true;
}
else
{
c.Visible = false;
}
}
}
}
protected void ReadBtnDO()
{
foreach (Control labl in doList)
{
IO_VALUE value = IOManager.DOValue(labl.Name, equipBase.DeviceID);
if (value.Equals(IO_VALUE.HIGH))
{
labl.BackColor = Color.Lime;
}
else
//else if (value.Equals(IO_VALUE.LOW))
{
labl.BackColor = labl.Parent.BackColor;
}
}
}
protected void DoBtnClick(object sender)
{
Control c = (Control)sender;
string ioType = c.Name;
IO_VALUE value = IOManager.IOValue(c.Name,equipBase.DeviceID);
if (value.Equals(IO_VALUE.HIGH))
{
equipBase.IOMove(ioType, IO_VALUE.LOW);
c.BackColor = c.Parent.BackColor;
}
else
{
equipBase.IOMove(ioType, IO_VALUE.HIGH);
c.BackColor = Color.LawnGreen;
}
}
}
}
......@@ -111,9 +111,10 @@ namespace OnlineStore.AssemblyLine
{
return;
}
if (chbAutoRead.Checked && this.Visible)
if ( this.Visible)
{
ReadIOList();
ReadIOList();
ReadBtnDO();
}
lblName.BackColor = equipBean.GetShowColor();
if (equipBean.runStatus > LineRunStatus.Wait)
......@@ -244,26 +245,27 @@ namespace OnlineStore.AssemblyLine
axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis, equipBean.BatchAxis });
cmbSizeList.Items.Clear();
cmbSizeList.Items.Add("0=默认位置");
foreach(int heigth in LineManager.GetTrayList())
cmbSizeList.Items.Add("0=默认位置");
foreach (int heigth in LineManager.GetTrayList())
{
cmbSizeList.Items.Add(heigth);
}
}
cmbSizeList.SelectedIndex = 0;
lblStoreStatus.Text = KTK_Store.GetRunStr( equipBean.runStatus);
lblStoreStatus.Text = KTK_Store.GetRunStr(equipBean.runStatus);
lblThisSta.Text = equipBean.WarnMsg;
txtP1.Text = equipBean.Config.UpDownAxisP1.ToString();
txtUpdownP3.Text = equipBean.Config.UpDownAxisP3.ToString();
if (equipBean.Config.DOList.ContainsKey(IO_Type.SL_RollerLine_Run) )
if (equipBean.Config.DOList.ContainsKey(IO_Type.SL_RollerLine_Run))
{
btnRollerRun.Visible = true;
SL_RollerLine_Run.Visible = true;
}
else
{
btnRollerRun.Visible = false;
SL_RollerLine_Run.Visible = false;
}
LoadDP2();
LoadDOBtn(groupDO);
txtBp1.Text = equipBean.Config.BatchAxisP1.ToString();
txtBP2.Text = equipBean.Config.BatchAxisP2.ToString();
txtBP3.Text = equipBean.Config.BatchAxisP3.ToString();
......@@ -376,11 +378,11 @@ namespace OnlineStore.AssemblyLine
private void btnLocationCylinder_Click(object sender, EventArgs e)
{
BtnMove(btnLocationCylinder, "SL定位气缸上升", "SL定位气缸下降", IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
equipBean.CylinderMove(null, IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
}
private void btnOutTopCylinder_Click(object sender, EventArgs e)
{
BtnMove(btnOutTopCylinder, "SL出口顶升上升", "SL出口顶升下降", IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
equipBean.CylinderMove(null, IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
}
......@@ -388,7 +390,7 @@ namespace OnlineStore.AssemblyLine
{
if (equipBean.UpdownIsUp())
{
BtnMove(btnFeedSideWayCylinder, "上料横移气缸取料端", "上料横移气缸放料端", IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
equipBean.CylinderMove(null, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
}
else
{
......@@ -396,20 +398,16 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnTrayLocationCylinder_Click(object sender, EventArgs e)
{
//判断伺服位置是否正确
//int currP = equipBean.BatchAxis.GetAclPosition();
//int chaz = equipBean.Config.BatchAxisP1 - currP;
//if (!(Math.Abs(chaz) < equipBean.Config.Height_ChangeValue*3))
{
if(!equipBean.TrayLCylinderCanAfter())
{
DialogResult result = MessageBox.Show("提升轴当前不在待机点P2,是否确定" + btnTrayLocationCylinder.Text+"?","确认操作 ",MessageBoxButtons.YesNo);
DialogResult result = MessageBox.Show("提升轴当前不在待机点P2,是否确定" + SL_TrayLocation_Before.Text+"?","确认操作 ",MessageBoxButtons.YesNo);
if (!result.Equals(DialogResult.Yes))
{
return;
}
}
BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocation_After, IO_Type.SL_TrayLocation_Before);
equipBean.CylinderMove(null,IO_Type.SL_TrayLocation_After, IO_Type.SL_TrayLocation_Before);
}
private void cmbSizeList_SelectedIndexChanged(object sender, EventArgs e)
......@@ -446,7 +444,7 @@ namespace OnlineStore.AssemblyLine
private void btnCloseAll_Click(object sender, EventArgs e)
{
foreach (Control con in groupBox5.Controls)
foreach (Control con in groupDO.Controls)
{
if (con is Button)
{
......@@ -484,27 +482,27 @@ namespace OnlineStore.AssemblyLine
private void btnLineRun_Click(object sender, EventArgs e)
{
BtnMove(btnLineRun, "SL进料线体运转", "SL进料线体停止", IO_Type.SL_Line_Run);
DoBtnClick(sender);
}
private void btnLSWRun_Click(object sender, EventArgs e)
{
BtnMove(btnLSWRun, "SL定位横移电机运转", "SL定位横移电机停止", IO_Type.SL_LocationSideWay_Run);
DoBtnClick(sender);
}
private void btnOSWRun_Click(object sender, EventArgs e)
{
BtnMove(btnOSWRun, "SL出口横移电机运转", "SL出口横移电机停止", IO_Type.SL_OutSideWay_Run);
DoBtnClick(sender);
}
private void btnEStopDown_Click(object sender, EventArgs e)
{
BtnMove(btnEStopDown, "SL进料阻挡下降", "SL进料阻挡上升", IO_Type.SL_Entry_StopDown);
DoBtnClick(sender);
}
private void btnBStopDown_Click(object sender, EventArgs e)
{
BtnMove(btnBStopDown, "SL缓冲阻挡下降", "SL缓冲阻挡上升", IO_Type.SL_Buffer_StopDown);
DoBtnClick(sender);
}
private void btnBP1_Click(object sender, EventArgs e)
......@@ -583,7 +581,7 @@ namespace OnlineStore.AssemblyLine
private void btnOLine_Click(object sender, EventArgs e)
{
BtnMove(btnOLine, "SL出料线体运转", "SL出料线体停止", IO_Type.SL_OutLine_Run);
DoBtnClick(sender);
}
......@@ -599,8 +597,7 @@ namespace OnlineStore.AssemblyLine
private void btnOutStopDown_Click(object sender, EventArgs e)
{
BtnMove(btnOutStopDown, "SL出料阻挡下降", "SL出料阻挡上升", IO_Type.SL_Out_StopDown);
DoBtnClick(sender);
}
private void btnUpdateShelf_Click(object sender, EventArgs e)
......@@ -715,23 +712,73 @@ namespace OnlineStore.AssemblyLine
}
private void btnGuding_Click(object sender, EventArgs e)
{
BtnMove(btnGuding , "SL固定气缸上升", "SL固定气缸下降", IO_Type.SL_FixedCylinder_Down, IO_Type.SL_FixedCylinder_Up);
{
equipBean.CylinderMove(null, IO_Type.SL_FixedCylinder_Down, IO_Type.SL_FixedCylinder_Up);
}
private void btnTopUp_Click(object sender, EventArgs e)
{
BtnMove(btnTopUp, "SL顶升上升", "SL顶升下降", IO_Type.SL_TopCylinder_Down, IO_Type.SL_TopCylinder_Up);
equipBean.CylinderMove(null, IO_Type.SL_TopCylinder_Down, IO_Type.SL_TopCylinder_Up);
}
private void btnRollerRun_Click(object sender, EventArgs e)
{
BtnMove(btnRollerRun, "SL过渡滚筒运转", "SL过渡滚筒停止", IO_Type.SL_RollerLine_Run);
DoBtnClick(sender);
}
private void btnFeedCylinder_Click(object sender, EventArgs e)
{
BtnMove(btnFeedCylinder, "夹料气缸放松", "夹料气缸夹紧", IO_Type.SL_ClampCylinder_Relax, IO_Type.SL_ClampCylinder_Work);
equipBean.CylinderMove(null,IO_Type.SL_ClampCylinder_Relax, IO_Type.SL_ClampCylinder_Work);
}
private void SL_TopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.SL_OutTopCylinder_Up, IO_Type.SL_TopCylinder_Down);
}
private void SL_FixedCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.SL_FixedCylinder_Up, IO_Type.SL_FixedCylinder_Down);
}
private void SL_LocationCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
}
private void SL_MoveCylinder_Give_Click(object sender, EventArgs e)
{
if (equipBean.UpdownIsUp())
{
equipBean.CylinderMove(null, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
}
else
{
MessageBox.Show("升降轴不在P1位置", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void SL_ClampCylinder_Work_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.SL_ClampCylinder_Work, IO_Type.SL_ClampCylinder_Relax);
}
private void SL_OutTopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.SL_OutTopCylinder_Up, IO_Type.SL_OutTopCylinder_Down);
}
private void SL_TrayLocation_After_Click(object sender, EventArgs e)
{
if (!equipBean.TrayLCylinderCanAfter())
{
DialogResult result = MessageBox.Show("提升轴当前不在待机点P2,是否确定" + SL_TrayLocation_Before.Text + "?", "确认操作 ", MessageBoxButtons.YesNo);
if (!result.Equals(DialogResult.Yes))
{
return;
}
}
equipBean.CylinderMove(null, IO_Type.SL_TrayLocation_After, IO_Type.SL_TrayLocation_After);
}
}
......
......@@ -58,6 +58,7 @@ namespace OnlineStore.AssemblyLine
this.Text = equipBean.Name;
txtP1.Text = equipBean.Config.UpDownAxisP1.ToString();
lblHyInfo.Text = equipBean.GetHYDesc();
LoadDOBtn(groupDo);
IsLoad = true;
}
......@@ -116,7 +117,7 @@ namespace OnlineStore.AssemblyLine
if (this.Visible)
{
ReadIOList();
//lblTrayNum.Text = "托盘编码:" + TrayManager.GetTrayNum(equipBean.DeviceID);
ReadBtnDO();
}
lblName.BackColor = equipBean.GetShowColor();
if (equipBean.runStatus > LineRunStatus.Wait)
......@@ -320,51 +321,10 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnLineRun_Click(object sender, EventArgs e)
{
if (equipBean.Config.DOList.ContainsKey(IO_Type.HY_LineBackRun))
{
equipBean.IOMove(IO_Type.HY_LineBackRun, IO_VALUE.LOW);
}
BtnMove(btnLineRun, "横移电机正转>>", "横移电机停止", IO_Type.HY_LineRun);
}
private void btnStopDown_Click(object sender, EventArgs e)
{
BtnMove(btnStopDown, "阻挡下降", "阻挡上升", IO_Type.HY_StopDown);
}
private void btnLineBackRun_Click(object sender, EventArgs e)
{
equipBean.IOMove(IO_Type.HY_LineRun, IO_VALUE.LOW);
BtnMove(btnLineBackRun, "横移电机反转<<", "横移电机停止", IO_Type.HY_LineBackRun);
}
private void btnTopCylinder_Up_Click(object sender, EventArgs e)
{
BtnMove(btnTopCylinder_Up, "横移顶升上升", "横移顶升下降", IO_Type.HY_TopCylinder_Down, IO_Type.HY_TopCylinder_Up);
}
private void btnFrontStopDown_Click(object sender, EventArgs e)
{
BtnMove(btnFrontStopDown, "托盘前阻挡下降", "托盘前阻挡上升", IO_Type.HY_FrontStopDown);
}
private void btnLocation_Up_Click(object sender, EventArgs e)
{
BtnMove(btnLocation_Up, "横移定位上升", "横移定位下降", IO_Type.HY_LocationCylinder_Down, IO_Type.HY_LocationCylinder_Up);
}
private void btnMoveTake_Click(object sender, EventArgs e)
{
BtnMove(btnMoveTake, "接驳台取料", "接驳台放料", IO_Type.HY_MoveCylinder_Give, IO_Type.HY_MoveCylinder_Take);
}
private void btnClampWork_Click(object sender, EventArgs e)
{
BtnMove(btnClampWork, "夹料气缸夹紧", "夹料气缸放松", IO_Type.HY_MoveCylinder_Give, IO_Type.HY_MoveCylinder_Take);
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
foreach (Control con in groupBox5.Controls)
foreach (Control con in groupDo.Controls)
{
if (con is Button)
{
......@@ -538,6 +498,93 @@ namespace OnlineStore.AssemblyLine
{
this.Close();
}
private void btnLineRun_Click(object sender, EventArgs e)
{
equipBean.LineRun();
}
private void btnStopDown_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void btnLineBackRun_Click(object sender, EventArgs e)
{
equipBean.LineStop();
}
private void btnFrontStopDown_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void btnTopCylinder_Up_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_TopCylinder_Down, IO_Type.HY_TopCylinder_Up);
}
private void btnLocation_Up_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_LocationCylinder_Down, IO_Type.HY_LocationCylinder_Up);
}
private void btnMoveTake_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_MoveCylinder_Give, IO_Type.HY_MoveCylinder_Take);
}
private void btnClampWork_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_ClampCylinder_Relax, IO_Type.HY_ClampCylinder_Work);
}
private void HY_ShortL_StopDown_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void HY_LongL_StopDown_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void HY_StopCylinder_Up_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_StopCylinder_Down, IO_Type.HY_StopCylinder_Up);
}
private void HY_StopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_StopCylinder_Up, IO_Type.HY_StopCylinder_Down);
}
private void HY_OL_StopCylinder_Up_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_OL_StopCylinder_Down, IO_Type.HY_OL_StopCylinder_Up);
}
private void HY_OL_StopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_OL_StopCylinder_Up, IO_Type.HY_OL_StopCylinder_Down);
}
private void HY_TopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_TopCylinder_Up, IO_Type.HY_TopCylinder_Down);
}
private void HY_LocationCylinder_Down1_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_LocationCylinder_Up, IO_Type.HY_LocationCylinder_Down);
}
private void HY_MoveCylinder_Give_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_MoveCylinder_Take, IO_Type.HY_MoveCylinder_Give);
}
private void HY_ClampCylinder_Relax_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.HY_ClampCylinder_Work, IO_Type.HY_ClampCylinder_Relax);
}
}
}
......
......@@ -106,7 +106,7 @@ namespace OnlineStore.AssemblyLine
private void timer1_Tick(object sender, EventArgs e)
{
if (chbAutoRead.Checked && this.Visible)
if ( this.Visible)
{
ReadIOList();
// lblTrayNum.Text = "托盘编码:" + TrayManager.GetTrayNum(0);
......
......@@ -19,9 +19,7 @@ using System.Windows.Forms;
namespace OnlineStore.AssemblyLine
{
internal partial class FrmLineStore : Form
{
//internal static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
{
private LineBean lineBean = null;
private List<TabPage> tabPageList = new List<TabPage>();
private bool LoadOk = false;
......@@ -1099,25 +1097,25 @@ namespace OnlineStore.AssemblyLine
}
else if (lineBean.HYEquipMap.ContainsKey(deviceId))
{
seleEquip=lineBean.HYEquipMap[deviceId];
seleEquip=lineBean.HYEquipMap[deviceId];
}
if (seleEquip.runStatus > LineRunStatus.Wait)
{
control_StartDebug.Text = "复位[" + seleEquip.Name+"]";
control_StartDebug.Text = seleEquip.Name + "复位 " + "";
}
else
{
control_StartDebug.Text = "启动调试[" + seleEquip.Name + "]";
control_StartDebug.Text = seleEquip.Name + "启动调试" + "";
}
string name = "打开[" + seleEquip.Name + "]";
string name = seleEquip.Name + "打开详情";
if (control_InDetial.Text.Equals(name))
{
return;
}
control_InDetial.Text = name;
control_Stop.Text= "停止[" + seleEquip.Name + "]";
control_Stop.Text = seleEquip.Name + "停止";
if (seleEquip.IsDebug)
{
control_Debug.Text = "✘ 未启用";
......@@ -1160,7 +1158,7 @@ namespace OnlineStore.AssemblyLine
{
if (seleEquip.runStatus > LineRunStatus.Wait)
{
LogUtil.info(Name + "点击:复位[" + seleEquip.Name + "]");
LogUtil.info(Name + "点击:模块复位[" + seleEquip.Name + "]");
bool result = seleEquip.Reset();
if (!result)
{
......@@ -1185,7 +1183,7 @@ namespace OnlineStore.AssemblyLine
{
if (seleEquip.runStatus > LineRunStatus.Wait)
{
LogUtil.info(Name + "点击:停止[" + seleEquip.Name + "]");
LogUtil.info(Name + "点击:停止运行[" + seleEquip.Name + "]");
seleEquip.Reset();
}
}
......
......@@ -39,12 +39,12 @@ namespace OnlineStore.AssemblyLine
if (equipBean.UseAxis)
{
axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis });
btnUpDownUp.Visible = false;
UpDownCylinder_Up.Visible = false;
}
else
{
tabControl1.TabPages.Remove(tabPage2);
btnUpDownUp.Visible = true;
UpDownCylinder_Up.Visible = true;
}
cmbSizeList.Items.Clear();
cmbSizeList.Items.Add("0=默认位置");
......@@ -59,6 +59,7 @@ namespace OnlineStore.AssemblyLine
lblName.Text = equipBean.Name;
this.Text = equipBean.Name;
LoadDP2();
LoadDOBtn(groupDO);
IsLoad = true;
}
......@@ -117,7 +118,8 @@ namespace OnlineStore.AssemblyLine
}
if ( this.Visible)
{
ReadIOList();
ReadIOList();
ReadBtnDO();
}
lblName.BackColor = equipBean.GetShowColor();
if (equipBean.runStatus > LineRunStatus.Wait)
......@@ -386,41 +388,8 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnStop1Up_Click(object sender, EventArgs e)
{
BtnMove(btnStop1Up, "阻挡1下降", "阻挡1上升", IO_Type.StopDown1);
}
private void btnStop2Up_Click(object sender, EventArgs e)
{
BtnMove(btnStop2Up, "阻挡2下降", "阻挡2上升", IO_Type.StopDown2);
}
private void btnTopUp_Click(object sender, EventArgs e)
{
BtnMove(btnTopUp, "顶升上升", "顶升下降", IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
if (equipBean.CanBeforeAfter())
{
BtnMove(btnBeforeAfterBefore, "横移前进", "横移后退", IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else
{
MessageBox.Show("升降气缸不在上升端 或 升降轴不在待机点P1", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnUpDownUp_Click(object sender, EventArgs e)
{
BtnMove(btnUpDownUp, "升降上升", "升降下降", IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
private void btnClampSlack_Click(object sender, EventArgs e)
{
BtnMove(btnClampSlack, "夹料夹紧", "夹料放松", IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Work);
}
private void cmbSizeList_SelectedIndexChanged(object sender, EventArgs e)
{
......@@ -464,7 +433,7 @@ namespace OnlineStore.AssemblyLine
private void btnCloseAll_Click(object sender, EventArgs e)
{
foreach (Control con in groupBox5.Controls)
foreach (Control con in groupDO.Controls)
{
if (con is Button)
{
......@@ -613,6 +582,75 @@ namespace OnlineStore.AssemblyLine
{
this.Close();
}
private void StopCheck1_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void StopCheck2_Click(object sender, EventArgs e)
{
DoBtnClick(sender);
}
private void TopCylinder_Down_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private void btnTopUp_Click(object sender, EventArgs e)
{
equipBean.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
if (equipBean.CanBeforeAfter())
{
equipBase.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else
{
MessageBox.Show("升降气缸不在上升端 或 升降轴不在待机点P1", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnUpDownUp_Click(object sender, EventArgs e)
{
equipBase.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
private void button4_Click(object sender, EventArgs e)
{
equipBase.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
}
private void BeforeAfterCylinder_After_Click(object sender, EventArgs e)
{
if (equipBean.CanBeforeAfter())
{
equipBase.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
}
else
{
MessageBox.Show("升降气缸不在上升端 或 升降轴不在待机点P1", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ClampCylinder_Check_Click(object sender, EventArgs e)
{
equipBase.CylinderMove(null, IO_Type.ClampCylinder_Work, IO_Type.ClampCylinder_Relax);
}
private void btnClampSlack_Click(object sender, EventArgs e)
{
equipBase.CylinderMove(null, IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Work);
}
private void lblInstoreList_Click(object sender, EventArgs e)
{
}
}
}
......
......@@ -12,6 +12,7 @@ using OnlineStore.Common;
using System.Threading;
using OnlineStore.LoadCSVLibrary;
using HuichuanLibrary;
using System.Net.Sockets;
namespace OnlineStore.AssemblyLine
{
......@@ -352,6 +353,10 @@ namespace OnlineStore.AssemblyLine
public void StopTimer()
{
this.timer1.Stop();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Clipboard.SetText(lblCountPulse.Text);
}
}
}
......@@ -93,7 +93,7 @@ namespace OnlineStore.AssemblyLine
BoxInfo box = LineServer.GetBoxInfo(equip.DeviceID);
string online = "✘";
if (box != null)
{
{
//lvi.SubItems.Add(box.CId.ToString());
//lvi.SubItems.Add(online);
//lvi.SubItems.Add(box.SAlarmType.ToString());
......@@ -105,7 +105,7 @@ namespace OnlineStore.AssemblyLine
}
if (box.SAlarmType.Equals(LineAlarm.None))
{
lblBox.Text = "BOX[" + box.CId.ToString() + "]:" + online +" "+ box.ToShowStr();
lblBox.Text = "BOX[" + box.CId.ToString() + "]:" + online + " " + box.ToShowStr();
lblBox.BackColor = Color.Green;
}
else
......@@ -116,7 +116,7 @@ namespace OnlineStore.AssemblyLine
}
else
{
lblBox.Text = "BOX状态:" + online;
lblBox.Text = "BOX状态:" + online;
lblBox.BackColor = Color.Gray;
}
}
......@@ -124,7 +124,14 @@ namespace OnlineStore.AssemblyLine
}
else
{
lblMoveInfo.Text = "暂无托盘横移";
if (equip.MoveInfo.MoveType.Equals(LineMoveType.CheckFixture))
{
lblMoveInfo.Text = "托盘["+equip.currTrayNum+"]处理中";
}
else
{
lblMoveInfo.Text = "暂无托盘横移";
}
}
this.BackColor = equip.GetShowColor();
//SetItemColor(equip.runStatus, equip.alarmType);
......
......@@ -14,12 +14,14 @@ namespace OnlineStore.DeviceLibrary
public abstract class EquipBase : KTK_Store
{
public LineMoveInfo SecondMoveInfo = null;
public bool IsDebug = false;
public bool UseAxis = false;
public ConcurrentQueue<InOutParam> waitOutStoreList = new ConcurrentQueue<InOutParam>();
public List<InOutParam> waitInStoreList = new List<InOutParam>();
internal object waitInListLock = "";
public LineMoveInfo SecondMoveInfo = null;
protected int trayCount = 0;
/// <summary>
/// 上一个盘号
......@@ -34,10 +36,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public AxisBean UpdownAxis = null;
public delegate void TrayProcessEnd(int swNum, int trayNum);
protected virtual void StopMoveProcess()
{
}
protected abstract void BaseTimerProcess();
protected abstract void CheckFixtureProcess();
......@@ -74,39 +73,8 @@ namespace OnlineStore.DeviceLibrary
{
}
public bool MoveStop = false;
protected override void BusyMoveProcess()
{
if (MoveStop)
{
return;
}
if (SecondMoveInfo.MoveType.Equals(LineMoveType.CheckFixture))
{
CheckFixtureProcess();
}
if (MoveInfo.MoveType.Equals(LineMoveType.InStore) || this.SecondMoveInfo.MoveType.Equals(LineMoveType.InStore))
{
InStoreProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.OutStore) || SecondMoveInfo.MoveType.Equals(LineMoveType.OutStore))
{
OutStoreProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.ReturnHome))
{
ResetProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.Reset))
{
ResetProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.StopMove))
{
StopMoveProcess();
}
}
public bool MoveStop = false;
private DateTime lastProTimer = DateTime.Now;
protected int TimerMaxSeconds = 3;
......@@ -187,7 +155,7 @@ namespace OnlineStore.DeviceLibrary
string canResult = LineManager.Line.CanStart();
if (String.IsNullOrEmpty(canResult).Equals(false))
{
SetWarnMsg(canResult);
SetWarnMsg(Name+ canResult);
return false;
}
return true;
......@@ -613,32 +581,20 @@ namespace OnlineStore.DeviceLibrary
}
}
}
protected void SInOutLog(string msg)
{
string posId = SecondMoveInfo.MoveParam != null ? SecondMoveInfo.MoveParam.PosId : "";
if (String.IsNullOrEmpty(posId))
{
LogUtil.info(Name + " " + msg);
}
else
{
LogUtil.info(Name + " " + "[" + posId + "] " + msg);
}
}
protected string RFIDIP="";
public virtual string GetMoveStr()
{
string msg = "";
int tLength = 15;
msg += "上个托盘:" + preTrayNum + "\n";
msg += "当前托盘:" + currTrayNum + "\n";
if (!String.IsNullOrEmpty(RFIDIP))
{
msg += "上个托盘:" + preTrayNum + "\n";
msg += "当前托盘:" + currTrayNum + "\n";
}
msg += "runS: " + runStatus + "\n";
msg += "alarm: " + alarmType +" "+LastAlarmTime.ToLongTimeString()+ "\n";
msg += "MoveT:"+ MoveInfo.MoveType+"\n";
msg += "MoveS :" + MoveInfo.SLog + "\n";
msg += "SMoveT:" + SecondMoveInfo.MoveType + "\n";
msg += "SMoveS:" + SecondMoveInfo.MoveStep + "";
msg += "Move:"+ MoveInfo.MoveType+ " " + MoveInfo.SLog + "\n";
msg += "SMove:" + SecondMoveInfo.MoveType + " " + SecondMoveInfo.MoveStep + "\n";
return msg;
}
internal void MoveEndS()
......
......@@ -28,7 +28,7 @@ namespace OnlineStore.DeviceLibrary
baseConfig = config;
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_T" + DeviceID % 100 + " ").ToUpper();
Name = (" " + "入料T" + DeviceID % 100 + " ").ToUpper();
Init();
UseAxis = true;
......@@ -36,6 +36,7 @@ namespace OnlineStore.DeviceLibrary
BatchAxis = new AxisBean(config.Batch_Axis, Name);
MoveInfo = new LineMoveInfo(DeviceID, "[" + Name.Trim() + "-Move]");
SecondMoveInfo = new LineMoveInfo(DeviceID, "[" + Name.Trim() + "-SMove]");
RFIDIP = RFIDManager.GetRFIP(DeviceID);
}
......@@ -396,17 +397,17 @@ namespace OnlineStore.DeviceLibrary
StartOutStoreP();
}
}
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None) && NoErrorAlarm())
{
if (Config.IsCanOut.Equals(0))
{
StartCheckFixture();
}
else if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{
StartCheckFixture();
}
}
//if (SecondMoveInfo.MoveType.Equals(LineMoveType.None) && NoErrorAlarm())
//{
// if (Config.IsCanOut.Equals(0))
// {
// StartCheckFixture();
// }
// else if (LineManager.Line.runStatus <= LineRunStatus.Wait)
// {
// StartCheckFixture();
// }
//}
if (NoErrorAlarm())
{
if (IOValue(IO_Type.SL_Out_Check).Equals(IO_VALUE.HIGH))
......@@ -964,8 +965,8 @@ namespace OnlineStore.DeviceLibrary
msg += "alarm: " + alarmType + "\n";
msg += "MoveT:" + MoveInfo.MoveType + "\n";
msg += "MoveS :" + MoveInfo.SLog + "\n";
msg += "SMoveT:" + SecondMoveInfo.MoveType + "\n";
msg += "SMoveS:" + SecondMoveInfo.MoveStep + "\n";
//msg += "SMoveT:" + SecondMoveInfo.MoveType + "\n";
//msg += "SMoveS:" + SecondMoveInfo.MoveStep + "\n";
// msg += "" + LastWidth + "X" + LastHeight + "="+ lastcode + "";
return msg;
......
......@@ -51,7 +51,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config;
baseConfig = config;
IsDebug = config.IsDebug.Equals(1);
Name = ("_HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();
Name = (" HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + " ").ToUpper();
Init();
MoveInfo = new LineMoveInfo(DeviceID, "[" + Name.Trim() + "-Move]");
......@@ -115,6 +115,7 @@ namespace OnlineStore.DeviceLibrary
{
HyInDeviceId = 218;
}
RFIDIP = RFIDManager.GetRFIP(DeviceID);
}
......
......@@ -20,7 +20,7 @@ namespace OnlineStore.DeviceLibrary
{
public HY_C1Line(string cid, HYEquip_Config config) : base(cid, config)
{
Name = ("_C1线HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();
Name = (" C1HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + " ").ToUpper();
}
public override bool StartRun(bool isDebug = false)
......
......@@ -17,7 +17,7 @@ namespace OnlineStore.DeviceLibrary
{
public HY_C1_SLStation(string cid, HYEquip_Config config) : base(cid, config)
{
Name = ("_C1线THY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();
Name = (" C1THY" + (DeviceID % 100).ToString().PadLeft(2, '0') + " ").ToUpper();
}
public override bool StartRun(bool isDebug = false)
......
......@@ -7,11 +7,14 @@ using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 接驳台横移
/// </summary>
public class HY_Coveryor:HYEquipBase
{
public HY_Coveryor(string cid, HYEquip_Config config) : base(cid, config)
{
Name = ("_接驳台HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();
Name = (" JHY" + (DeviceID % 100).ToString().PadLeft(2, '0') + " ").ToUpper();
}
......@@ -45,8 +48,7 @@ namespace OnlineStore.DeviceLibrary
{
return false;
}
LogInfo("开始重置: 升降轴回原点,阻挡气缸上升 ");
LogInfo("开始重置: 升降轴回原点,阻挡气缸上升 ");
runStatus = LineRunStatus.Reset;
SecondMoveInfo.EndMove();
MoveInfo.NewMove(LineMoveType.Reset);
......
......@@ -14,10 +14,8 @@ namespace OnlineStore.DeviceLibrary
{
public HY_OutLine(string cid, HYEquip_Config config) : base(cid, config)
{
Name = ("_"+config.LineName+"线HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + "_").ToUpper();
}
Name = (" "+config.LineName+"HY" + (DeviceID % 100).ToString().PadLeft(2, '0') + " ").ToUpper();
}
public override bool StartRun(bool isDebug = false)
{
if (CanStartRun().Equals(false))
......@@ -308,10 +306,7 @@ namespace OnlineStore.DeviceLibrary
CheckLog("出料线横移(短线)" + MoveInfo.SLog + " 等待托盘离开");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_TrayCheck, IO_VALUE.LOW));
}
#endregion
#endregion
else if (MoveInfo.IsStep(LineMoveStep.OHY21_WaitTrayLeave))
{
MoveInfo.NextMoveStep(LineMoveStep.OHY22_TrayLeave);
......
......@@ -23,7 +23,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config;
baseConfig = config;
IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_"+ GetNByID() + "_进仓" + DeviceID.ToString().PadLeft(2, '0') + "_" ).ToUpper();
Name = (" " + ""+ GetNByID() + "进仓" + DeviceID.ToString().PadLeft(2, '0') + " " ).ToUpper();
Init();
......@@ -32,6 +32,7 @@ namespace OnlineStore.DeviceLibrary
UseAxis = config.UpDownUseAxis.Equals(1);
UpdownAxis = new AxisBean(config.UpDown_Axis, Name);
RFIDIP = RFIDManager.GetRFIP(DeviceID);
}
private string GetNByID()
{
......@@ -221,8 +222,34 @@ namespace OnlineStore.DeviceLibrary
CheckAndMove(IO_Type.ClampCylinder_Relax, IO_VALUE.LOW);
runStatus = LineRunStatus.Wait;
}
protected override void BusyMoveProcess()
{
if (MoveStop)
{
return;
}
if (SecondMoveInfo.MoveType.Equals(LineMoveType.CheckFixture))
{
CheckFixtureProcess();
}
if (MoveInfo.MoveType.Equals(LineMoveType.InStore) || this.SecondMoveInfo.MoveType.Equals(LineMoveType.InStore))
{
InStoreProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.OutStore) || SecondMoveInfo.MoveType.Equals(LineMoveType.OutStore))
{
OutStoreProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.ReturnHome))
{
ResetProcess();
}
else if (MoveInfo.MoveType.Equals(LineMoveType.Reset))
{
ResetProcess();
}
}
protected override void BaseTimerProcess()
{
if (isInSuddenDown || isNoAirCheck)
......
......@@ -200,7 +200,7 @@ namespace OnlineStore.DeviceLibrary
{
// 减去需要的盘数
// TrayManager.DelNeedEmptyTrayNum();
SInOutLog("出库 :移栽完成,放行托盘");
OutLog("出库 :移栽完成,放行托盘");
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
......@@ -330,9 +330,10 @@ namespace OnlineStore.DeviceLibrary
{
int num = MoveInfo.MoveParam.TrayNumber;
MoveInfo.NextMoveStep(LineMoveStep.MI_10_WaitBox);
LogInfo("入库【" + posId + "】 " + MoveInfo.SLog + ": 等待box可入库,更新托盘【" + num + "】为空盘");
LogInfo("入库【" + posId + "】 " + MoveInfo.SLog + ": 等待box可入库,更新托盘【" + num + "】为空盘,删除入库任务");
MoveInfo.WaitList.Add(WaitResultInfo.WaitBoxCanReviceTray());
TrayManager.UpdateTrayInfo(num);
TrayManager.UpdateTrayInfo(num);
RemoveInStore(MoveInfo.MoveParam);
InLog("放托盘(放开阻挡): " + MoveInfo.SLog + " 物品已移走,顶升气缸1下降");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
......@@ -572,7 +573,7 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error(Name + "托盘号【" + currTrayNum + "】入库信息【" + currCode.ToStr() + "】料仓未验证成功,不拦截托盘,更新此托盘为NG,从waitInStoreList中删除,取消入库任务");
TrayManager.UpdateInStoreNG(currTrayNum, true, "Box验证入库失败");
waitInStoreList.RemoveAt(reIndex);
//waitInStoreList.RemoveAt(reIndex);
SServerManager.cancelPutInTask(Name, currCode.WareCode);
return false;
}
......@@ -584,6 +585,35 @@ namespace OnlineStore.DeviceLibrary
return false;
}
private bool RemoveInStore(InOutParam param)
{
if (waitInStoreList.Count > 0)
{
lock (waitInListLock)
{
//判断是否是自己排队列表中的入库信息
int reIndex = -1;
for (int i = 0; i < waitInStoreList.Count; i++)
{
InOutParam cc = waitInStoreList[i];
//托盘号一致,二维码一致,库位号一致
if (cc.TrayNumber.Equals(param.TrayNumber) && cc.PosId.Equals(param.PosId) && cc.WareCode.Equals(param.WareCode))
{
reIndex = i;
break;
}
}
if (reIndex >= 0)
{
waitInStoreList.RemoveAt(reIndex);
LogInfo("*******料盘已移走,清理入库任务:【" + param.ToStr() + "】");
return true;
}
}
}
return false;
}
#endregion
#region 托盘检测
......
......@@ -270,6 +270,10 @@ namespace OnlineStore.DeviceLibrary
{
if (String.IsNullOrEmpty(msg).Equals(false))
{
if (!msg.StartsWith(Name))
{
msg = Name + msg;
}
if (WarnMsg.Equals(msg))
{
if (msg.StartsWith(Name))
......
......@@ -575,18 +575,6 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 夹具检测处理
/// </summary>
CheckFixture = 5,
/// <summary>
/// 移栽装置的停止,需要先远点返回,然后停止
/// </summary>
StopMove = 6,
/// <summary>
/// 夹具横移处理
/// </summary>
HY=7,
///// <summary>
///// 移栽检测托盘
///// </summary>
//CheckFixture=6,
CheckFixture = 5,
}
}
......@@ -106,15 +106,9 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
ResetMove =13,
}
/// <summary>
/// 料仓运动状态(当料仓状态=busy时,才会有此运动状态)
/// </summary>
public enum LineMoveStep
{
/// <summary>
/// 无操作,等待状态
/// </summary>
{
Wait = 0,
......@@ -1251,7 +1245,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 横移模块 50000开始
#region C1线横移模块 50000开始
#region 横移模块复位,50001
/// <summary>
......@@ -1305,7 +1299,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 横移 C1->C1分流入口横移操作 51011
#region 横移 C1->C1分流入口横移操作 51011-51019
/// <summary>
/// 横移C1->C1分流入口:开始横移,顶升上升,定位下降
/// </summary>
......@@ -1343,7 +1337,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 横移 C1线->出料线 横移处理 51031
#region 横移 C1线->出料线 横移处理 51031-51039
/// <summary>
/// C1线->出料线:开始横移,顶升上升
/// </summary>
......@@ -1522,6 +1516,8 @@ namespace OnlineStore.DeviceLibrary
HY95_StopDownUp,
#endregion
#endregion
#region 出料线横移,52001
/// <summary>
......@@ -1584,11 +1580,55 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 出料线横移: 延迟500ms后再次等待托盘无信号
/// </summary>
OHY22_TrayLeave,
OHY22_TrayLeave,
#endregion
#region 接驳台横移, 53001
#region 接驳台横移复位
//升降轴回待机点
//升降轴回P1
//电机停止,阻挡上升,定位下降,顶升下降,接驳台取料端
//,接驳台夹料气缸放松
//等待夹爪无料
/// <summary>
/// 接驳台横移复位:升降轴回原点
/// </summary>
JHY_R01_UpdownHome = 53001,
/// <summary>
/// 接驳台横移复位:升降轴到P1
/// </summary>
JHY_R02_UpdownUp,
/// <summary>
/// 接驳台横移复位:电机停止,阻挡上升,定位气缸下降,接驳台取料端
/// </summary>
JHY_R03_LocationDown,
/// <summary>
/// 接驳台横移复位:升降气缸下降,夹紧气缸放松
/// </summary>
JHY_R04_TopDown,
/// <summary>
/// 接驳台横移复位:等待夹爪无信号
/// </summary>
JHY_R05_ClampCheck,
#endregion
#region 接驳台横移托盘处理
#endregion
#endregion
}
public enum LineAlarmType
......
......@@ -74,7 +74,12 @@ namespace OnlineStore.LoadCSVLibrary
{
throw new FileNotFoundException("未找到文件:" + filePath);
}
string[] lines = File.ReadAllLines(filePath, Encoding.UTF8);
Encoding encoding = Encoding.UTF8;
if (!FileEncoding.GetType(filePath).Equals(Encoding.UTF8))
{
encoding = Encoding.GetEncoding("gb2312");
}
string[] lines = File.ReadAllLines(filePath, encoding);
return lines;
}
/// <summary>
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class FileEncoding
{
/// <summary>
/// 给定文件的路径,读取文件的二进制数据,判断文件的编码类型
/// </summary>
/// <param name=“FILE_NAME“>文件路径</param>
/// <returns>文件的编码类型</returns>
public static System.Text.Encoding GetType(string FILE_NAME)
{
FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
Encoding r = GetType(fs);
fs.Close();
return r;
}
/// <summary>
/// 通过给定的文件流,判断文件的编码类型
/// </summary>
/// <param name=“fs“>文件流</param>
/// <returns>文件的编码类型</returns>
public static System.Text.Encoding GetType(FileStream fs)
{
byte[] Unicode = new byte[] { 0xFF, 0xFE, 0x41 };
byte[] UnicodeBIG = new byte[] { 0xFE, 0xFF, 0x00 };
byte[] UTF8 = new byte[] { 0xEF, 0xBB, 0xBF }; //带BOM
Encoding reVal = Encoding.Default;
BinaryReader r = new BinaryReader(fs, System.Text.Encoding.Default);
int i;
int.TryParse(fs.Length.ToString(), out i);
byte[] ss = r.ReadBytes(i);
if (IsUTF8Bytes(ss) || (ss[0] == 0xEF && ss[1] == 0xBB && ss[2] == 0xBF))
{
reVal = Encoding.UTF8;
}
else if (ss[0] == 0xFE && ss[1] == 0xFF && ss[2] == 0x00)
{
reVal = Encoding.BigEndianUnicode;
}
else if (ss[0] == 0xFF && ss[1] == 0xFE && ss[2] == 0x41)
{
reVal = Encoding.Unicode;
}
r.Close();
return reVal;
}
/// <summary>
/// 判断是否是不带 BOM 的 UTF8 格式
/// </summary>
/// <param name=“data“></param>
/// <returns></returns>
private static bool IsUTF8Bytes(byte[] data)
{
int charByteCounter = 1; //计算当前正分析的字符应还有的字节数
byte curByte; //当前分析的字节.
for (int i = 0; i < data.Length; i++)
{
curByte = data[i];
if (charByteCounter == 1)
{
if (curByte >= 0x80)
{
//判断当前
while (((curByte <<= 1) & 0x80) != 0)
{
charByteCounter++;
}
//标记位首位若为非0 则至少以2个1开始 如:110XXXXX...........1111110X
if (charByteCounter == 1 || charByteCounter > 6)
{
return false;
}
}
}
else
{
//若是UTF-8 此时第一位必须为1
if ((curByte & 0xC0) != 0x80)
{
return false;
}
charByteCounter--;
}
}
if (charByteCounter > 1)
{
throw new Exception("非预期的byte格式");
}
return true;
}
}
}
......@@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="FileEncoding.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\Line_Config.cs" />
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!