机缘
我最初的创作初心是:
- 实战项目中的经验分享
- 日常学习过程中的记录
- 通过文章进行技术交流
收获
在创作的过程中都有哪些收获
- 学习到了很多知识,和记录在自己博客里
- 帮助了很多人
- 有了一些固定的粉丝(虽然很少)
成就
自己负责的一个设备项目,当它在自己面前调试,运行,并且无差错的到运行结束,就是自己最大的成就。
运用简易版的状态机模式实现:
private void ControlQueryDeviceThread()
{
try
{
m_controlCmd = new Controlcommand();
while (true)
{
int nold;
int nnew;
if (DealSpecialCmd(false, 0) == 9494)//结束
{
m_ZTMCD.DealnProcess(true);
m_ZTMCD.DealnAction(true);
m_ZTMCD.DealnSAction(true);
OperateCmdQueue(3, ref m_controlCmd, out nold, out nnew);
}
else if (DealSpecialCmd(false, 0) == 2100)//暂停
{
m_ZTMCD.m_bProcessPause = true;
}
else if (DealSpecialCmd(false, 0) == 2101)//继续
{
m_ZTMCD.m_bProcessPause = false;
}
DealSpecialCmd(true, 0);
m_ZTMInform.m_nInformType = 2;
if (m_ZTMCD.m_nFaultCode != 0)
{
m_ZTMCD.DealnProcess(true);
m_ZTMCD.DealnAction(true);
m_ZTMCD.DealnSAction(true);
m_ZTMCD.m_nMoveForInform = 0;
OperateCmdQueue(3, ref m_controlCmd, out nold, out nnew);
m_ZTMInform.m_nInformType = 1;
if (m_ZTMCD.m_nFaultCode != 7)
{
m_nFaultTimes++;
if (m_nFaultTimes > 200)
{
m_nFaultTimes = 0;
m_ZTMCD.m_nFaultCode = 0;
}
}
}
else if (m_ZTMCD.DealnProcess(false) == 0)
{
OperateCmdQueue(2, ref m_controlCmd, out nold, out nnew);
if (nold - nnew == 1)
{
m_ZTMCD.DealnProcess(true, m_controlCmd.m_ControlCmdValue);
}
}
else if (m_ZTMCD.DealnProcess(false) == 120)//加血清
{
int x = (int)m_controlCmd.m_ControlCmdParam[0];//血清x坐标
int y = (int)m_controlCmd.m_ControlCmdParam[1];//血清y坐标
int z = (int)m_controlCmd.m_ControlCmdParam[2];//血清Z坐标
int row = (int)m_controlCmd.m_ControlCmdParam[3];//稀释板行
int cell = (int)m_controlCmd.m_ControlCmdParam[4];//稀释板列
int dyl = (int)m_controlCmd.m_ControlCmdParam[5];//血清液量
int xs_vl = (int)m_controlCmd.m_ControlCmdParam[6];//稀释液量
int xs_gs = (int)m_controlCmd.m_ControlCmdParam[7];//稀释管数,1.2.3.4.5。。。。300
m_ZTMCD.ProcessXQGtoXSG(x, y, z, row, cell, dyl, xs_vl, xs_gs);
}
else if (m_ZTMCD.DealnProcess(false) == 121)//稀释动作
{
int r = (int)m_controlCmd.m_ControlCmdParam[0];
int c = (int)m_controlCmd.m_ControlCmdParam[1];
int v = (int)m_controlCmd.m_ControlCmdParam[2];
m_ZTMCD.ProcessXS(r, c, v);
}
else if (m_ZTMCD.DealnProcess(false) == 122)//稀释板到抗原片
{
int bid = (int)m_controlCmd.m_ControlCmdParam[0];
int r = (int)m_controlCmd.m_ControlCmdParam[1];
int c = (int)m_controlCmd.m_ControlCmdParam[2];
int k_p = (int)m_controlCmd.m_ControlCmdParam[3];
int dyl = (int)m_controlCmd.m_ControlCmdParam[4];
int kong = (int)m_controlCmd.m_ControlCmdParam[5];
m_ZTMCD.ProcessXSBtoKYP(bid, r, c, k_p, dyl, kong);
}
else if (m_ZTMCD.DealnProcess(false) == 123)//试剂到抗原片
{
int sjType = (int)m_controlCmd.m_ControlCmdParam[0];
int k_p = (int)m_controlCmd.m_ControlCmdParam[1];
int sjGS = (int)m_controlCmd.m_ControlCmdParam[2];
int dyl = (int)m_controlCmd.m_ControlCmdParam[3];
int vnum = (int)m_controlCmd.m_ControlCmdParam[4];
m_ZTMCD.ProcessSJtoKYP(sjType, k_p, sjGS, dyl, vnum);
}
else if (m_ZTMCD.DealnProcess(false) == 130)//二次稀释,稀释A到稀释B
{
int row = (int)m_controlCmd.m_ControlCmdParam[0];
int cell = (int)m_controlCmd.m_ControlCmdParam[1];
int dyl = (int)m_controlCmd.m_ControlCmdParam[2];
int xs_vl = (int)m_controlCmd.m_ControlCmdParam[3];
m_ZTMCD.ProcessXSGAtoXSGB(row, cell, dyl, xs_vl);
}
else if (m_ZTMCD.DealnProcess(false) == 100)//小z轴的运动
{
bool bpos = false;
if (m_controlCmd.m_ControlCmdParam[0] >= 1.0)
{
bpos = true;
}
int bum = (int)m_controlCmd.m_ControlCmdParam[1];
m_ZTMCD.ProcessAdjustZ2(bpos, bum);
}
else if (m_ZTMCD.DealnProcess(false) == 101)//大z轴的运动
{
bool bpos = false;
if (m_controlCmd.m_ControlCmdParam[0] >= 1.0)
{
bpos = true;
}
int bum = (int)m_controlCmd.m_ControlCmdParam[1];
m_ZTMCD.ProcessAdjustZ1(bpos, bum);
}
else if (m_ZTMCD.DealnProcess(false) == 102)//X1Y1轴的运动
{
bool bpos2 = false;//运动方式true为绝对。false为相对
if (m_controlCmd.m_ControlCmdParam[0] >= 1.0)
{
bpos2 = true;
}
int tumc = (int)m_controlCmd.m_ControlCmdParam[1];
int tumd = (int)m_controlCmd.m_ControlCmdParam[2];
bool bmz = false;
if (m_controlCmd.m_ControlCmdParam[3] >= 1.0)
{
bmz = true;
}
m_ZTMCD.ProcessAdjustDCD(bpos2, tumc, tumd, bmz);
}
else if (m_ZTMCD.DealnProcess(false) == 103)//X2Y2轴的运动
{
bool bpos2 = false;//运动方式true为绝对。false为相对
if (m_controlCmd.m_ControlCmdParam[0] >= 1.0)
{
bpos2 = true;
}
int tumc = (int)m_controlCmd.m_ControlCmdParam[1];
int tumd = (int)m_controlCmd.m_ControlCmdParam[2];
bool bmz = false;
if (m_controlCmd.m_ControlCmdParam[3] >= 1.0)
{
bmz = true;
}
m_ZTMCD.ProcessAdjustXCD(bpos2, tumc, tumd, bmz);
}
else if (m_ZTMCD.DealnProcess(false) == 104)//大x,y,z移动到标定位置
{
int nc = (int)m_controlCmd.m_ControlCmdParam[0];
int nd = (int)m_controlCmd.m_ControlCmdParam[1];
int nz = (int)m_controlCmd.m_ControlCmdParam[2];
m_ZTMCD.ProcessMovePosCDZ(nc, nd, nz);
}
else if (m_ZTMCD.DealnProcess(false) == 105)//小x,y,z移动到标定位置
{
int nc = (int)m_controlCmd.m_ControlCmdParam[0];
int nd = (int)m_controlCmd.m_ControlCmdParam[1];
int nz = (int)m_controlCmd.m_ControlCmdParam[2];
m_ZTMCD.ProcessMovePosXCDZ(nc, nd, nz);
}
else if (m_ZTMCD.DealnProcess(false) == 9999)//回原点
{
m_ZTMCD.BigAxisProcessHome();//大三轴回原点
}
m_ZTMInform.m_nInformProcess = m_ZTMCD.DealnProcess(false);
if (m_ZTMCD.m_bProcessPause)
{
m_ZTMInform.m_nInformProcess = 2100;
}
m_ZTMInform.m_nInformMove = m_ZTMCD.m_nMoveForInform;
m_ZTMInform.m_nInformFaultCode = m_ZTMCD.m_nFaultCode;
if (m_nWorkID != 0)
{
m_autoThreadResetEvent.Set();
}
Thread.Sleep(20);
}
}
catch (Exception ex)
{
m_errorMessage = $"设备程序故障:{ex.Message}";
}
}
憧憬
感谢csdn记录我的第一次!
后面会继续抽时间,分享自己的技能知识。可能工作占比时间比较多。
Tips