From b558baced5a0ac3226b71d69128cf3f1e857b0b3 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 27 Jan 2026 21:04:52 +0800 Subject: [PATCH] 1 --- DAL/MainWindowDAL.cs | 6 +- FeiYu/Data/DataBase.accdb | Bin 6344704 -> 6488064 bytes Model/InputSignal.cs | 293 ++- Model/MS_MB_API.cs | 340 +++ Model/Model.csproj | 2 + Model/MotionControl/LeiSaiCard.cs | 94 + Model/OutputSignal.cs | 322 +-- Model/StationMessage.cs | 55 + ViewModel/HandModel.cs | 175 ++ ViewModel/MainWindowVM.cs | 3520 +++++++++++++++++------------ ViewModel/Robots/EpsonRobotVM.cs | 2 - ViewModel/ViewModel.csproj | 1 + ViewModel/Vision/V_SweepCode.cs | 3 - Views/ControlPanel.xaml | 39 +- Views/MainInterface.xaml | 15 +- Views/Robot.xaml | 2 +- 16 files changed, 3111 insertions(+), 1758 deletions(-) create mode 100644 Model/MS_MB_API.cs create mode 100644 Model/StationMessage.cs create mode 100644 ViewModel/HandModel.cs diff --git a/DAL/MainWindowDAL.cs b/DAL/MainWindowDAL.cs index 90f24b1..d8e3b43 100644 --- a/DAL/MainWindowDAL.cs +++ b/DAL/MainWindowDAL.cs @@ -57,6 +57,7 @@ namespace DAL input.ToRunControlCard = (bool)row["ToRunControlCard"]; input.HightEff = (bool)row["HightEff"]; input.MyType = (int)row["MyType"]; + input.EmptySignal = (bool)row["EmptySignal"]; list.Add(input); } return list; @@ -99,6 +100,7 @@ namespace DAL Output.OutputMeaning = (string)row["OutputMeaning"]; Output.ToRunControlCard = (bool)row["ToRunControlCard"]; Output.MyType = Convert.ToInt32(row["MyType"]); + Output.EmptySignal = (bool)row["EmptySignal"]; list.Add(Output); } return list; @@ -133,7 +135,7 @@ namespace DAL c = new ZmotionCard(); break; default: - c = new LeiSaiCard(); + c = new LeiSaiMBCard(); break; } @@ -1323,8 +1325,6 @@ namespace DAL } #endregion - - #endregion #region 串口相关 diff --git a/FeiYu/Data/DataBase.accdb b/FeiYu/Data/DataBase.accdb index 82099562bc431498ef8a564209b11622c3508c66..98aeaaf71e7a287bb7a58ae31178d5ef8504182a 100644 GIT binary patch delta 9643 zcmdT~dvsIBnV)+lT|I5d@3$rSZO33qeu)qxWBiD*ELqsdHU`_|Nj49Xv%85)Xynsv z>rL7eToPv6q=}ug3vCj>PEK^srfD&Ghc;l^rj*iPbF$FpRgxwrOKBSRo0&Vh!od!E z&i=FFe4e>8-~8tB&G(oYMkoG7GdlWR&6Jp^yLseYz4_Us#B;(fN1`c75H=yjw%P;IvtP?E6!4~rvgLSozi4nd6gK2U*BK2d@MSokEePmyWdHB^c{G3i z;QWQGnLOd*MTAD7_SrA&>-;#c%VahfSku(;$=Y2T{Z( z^AGvrIZcvTs#*2sS?DhPZyL9fmplKaxmDyJKmWVt_0;krr2Q~0GK!4FkVz+*63Aqb zOethCNu~@kS<{oDgs4NiPt?&S_?ZIj>MG8Hl45+2LCNHc1F|oQIz4&H5_M_wG(sBA zuhtHwXA$nC$W6E0Fc9jz{U3*6F3>05Rjn&4vM%ssXA6sspMA@&c^@ zx*BNZUUB{!mt~pOA71SzYkv#Ewkh*3eA7t#Ntl*R*Uyu&S`wBa^bzTB|~ye zdc(CMzR6p%f2<;_0caJF52z7nHBb}K8o45?`FCM+k7+YiH-t)X!kx{YZ2ukpc1w}} zV#gmk{TTYLDbN{2o)XR+rp(J!=IVH6^QFw|DRU)?5O&(D$AQjnS_Ha> za$iMw8M8Z{c>#1cWv)<}T{H`SlzE|aiL#WzU%YL5vqc+3X%c?n-e#wmD&e_%n;jaI zB4KfRbAbjWOSp7-a`TZ%1W^(DB=~Pp#c)`e!2GbW=n^Y_0j~^~VJ4lMq{2zE)6G z!zScIRcwti5wScMzvy?nK|q(vzKG7jhn6$e3~HY#D~N})M!XRsAI`gs@unjUhXud& zNq6eK*A0;^RUSDN=B$;BH7&;KS`p9c4PFRw)~gt6N^Gz$FW(>$zEe4G1>;SPjn-Aq zc?oO$V9Ob6G8F)sn5&MkUT&~uj5SFeY%ODru!+Twwv_SO)X{=kU48S^mX7P}_iWo% zGg6=|YzbquszU{pQW?EHoUxcOCaMGVI09{G|J@~nkz58Qp=+U5K>3`<;{t(J-Y~m^ z^y%$!D18<&C<|wEyFfszZ$Ee+0Ye~IVj6s?kg=I#Y*1qkw1;-yvG@AAb#~ro3))ON z%~9EEX_o!rd#!+h8EI)hT7i;z`!!G`psd)cx~q9}-qtDMP(zC&A2}F^l`^oQa2~rf zwxgj1s8!z4(Dpq+i9UR7#~O7cwpqW+`41_$Y_zR3AydI8N|%YdTxN&7eYEYH_Gnjs zd8+LAmN{34U-+Oc0srW);*;3*Xod|>{8g0jrVHXD^1kQW&ex7l>2n-<;;EIN9bBtc z%Y=O~@?4UAh4tUBy>s_eiq^t)TR^9GK*iJ6@u_0`TCgfH33eN-`^EdV-kHhPBD%An z#kgqKWBVSs7N}j`_rTio>#t-8(T~>VZB_j3P>1Xr^3OKr1&;)u3;r;8@6nAxUob!T z_rMR5F)7bdYjyxJ41&XN%R)jof&m?`0p_WA2I=$sB$?DvDY{<97T zY34&6{wJFGKqvoTzh4kE=zSgj(E)#EE_#oQ8DcH^Ba5tTIP|U#A3NX&Gd`x3-#g%c zawcU|;iB`P`4{o#*}@DXjO+{gjXypk<~--H=Ucx$+8G@Uh&Ig!mJxjDvCedy(-}IgG{c2Yx7IPfwn)>=~`JMW+Iy!+h4zpiDIT;RH>kaqa2$C);ms zFKeHk{G%cHB^@FW_Sr@jX`gK@!^chrmL6m@< zatD;VZS`L&w;S=H{j2KbnUjI0Z)zT5V$9f;JL;A_J5zRn6gLO|9BBq|k#hrTVNyh> zmB|sIHYP~~)>hjMvP7sIG9XQa)aS z?OCRop4zR$;2^Z}Y_GIczt`t$v%wLi>y(`$(_@D$+CrzT8O$~GBQJ{oCCeA=p){ME zG}`kFID*{0Z~HdiU2HIL+@CPEXMCgwMt=x6cUq(P(P|u3U`Fwx2CB+ zRqYB;9uK{1t-M^gfRGX|2*PVt)jb{Oqe_>L9}KN*nx1<8OOwSutLqh6>sWW%E)>aU zed~(E>8Tgv*_5MK*E(73>Q0!C!}RqS9670Uh!A1BT{S#>nb~sY9^@{NFAVjZsdAcB z4hOn_U`yyv4GPwMfYj;Z;|F`n!53F+kx!mmU+d7h0JEP( z7q)Ot772RE55faVvAhy#*uuN)y5Ot9p9FELE9^6LT+@-&@#*2C^6Jq|deivS?fB@` z;SSLt;oOyBr>K{(Z)MnFL=tnC`S`(=;XM4UmEoxuhM#zz~%rI~D__aP=Ir6F8D$%(7NVL>!W_$D9B*(l-rePM?N zJ*~q}`@-2i^b~XE%$;xSy6#rv_4^-6XJSN8#(Vmzo*%D^tJDg!md!ZHVq|_=Ycps? zd2+)02zS=2!?)PAZOqTMF+bbJ{A?TZvu(w=y(xSQm#qnVb@t)^Fr^K-~k&=ps0-|UzdwbPS!i%u*2U&G3$ zcZp7mEIN7V#_CL0IqELqsAgxFq3G;}IjfThF&3A7(FY+gmzlC785@ZT z1%;9H>OfrX@oX-lZUPOw*|mWK6%TLhB0GSwMFio^I4ysh&ovjnJ-5NbzcTTOa~tYn zU-F5I8_FH#fWDbd3Df{5I0hV^2V+NCq7O7loZQuoE5T0h{m%E6>xQQ&mcN zS5uu$_zT|LROirx){q-7y!kFe8Xg|=+T`)Ff%|%6L&PU`45$OfCmxUcl205MsB>`E z0{NY}0h0}eMt*&WoX!;0i_VIo?KyGiXVxqp#qsE`1gyed0X5!)4-JOOqPC%Z)|`br z#lTZ)K#eya)8Ip<5^vNoG;K}h2s|w{;*Y;m(hzkG$<{1h$kQ@_D28sf$g{qoW7edF zT@>NaP$;lxw%-;V-e`?EPH<6?jRseSgG`BD7m*_@IqA}?0Qs{68&7UE5`#p%W&QZ1 zo%mJzraxNk+#~k6Ysl&S%%;vDbwKPqJG95P-nM6Wz!vS=bo%IWcG4u<503hubT4EU zgg4^$)(O7iu$!s|u-)9OAFl+Jpl>yz($s}AMPT=vBJl;gtOTRRS*uxwfsGA znO`T-O9ugQ?+y1T4rE$*S+GQNxcUb@=3X7HqAqjSK$csLS5ENW^Xet!pv}3!J+)dEPgiOXC0@aW!Ez;+nEJgwvY#WKh?4u zxRy<&ftGOuo)#!t)@1-KKg*;ngftw>wGmVIt$eB;eOxG^QtH^6kQkU4Hacrgy* zR~#aJl^!Kg2pjyR+Py%Wh((O0UkQ^;VF;K46E9UagYkSdObUe|UP6;K7}*qqASu&<=<;$Gr%Pd!Pz-{^Fo@MqUkKED+NCf`DMpTp0YX+W$OFb# zuSW~T$W<{w!s?Cnm90lB#mG}JK)fo3dh5N^T-qoGzrTgE4frU2%N~Dky(q?2dgTt7 z*i&Uqsq2b=by3zM>gqXR#dC8TBquR{l-olLANQkV{dwp{c%2=K3Ght_gG`S+G>>X+elpsYR+e(>E z9Y^7B1jwztW-WozMN!DcQcz+l#-9(a1SLdK%2X6kGB%^wSoq7@Vq*d6^ciZ(RS3{A z6@thoZc$FgE$#a}z^F*mLj**AF8Vi-8qK!oREWsl7m{+8czTd890<(;+m1oW`IS!@ z(c#c>YdI010QQ>%AoMu}#Hd;YRg-*-of!abT9|Y|Tok2~q70rL zi&~7OP?!PaW)$9xzvP#>-B}8S89;7E0R?u?rJngpP}b4amTjc z`+dKeGc#w-oH;Xd&e@Gb?p8$xzM_h%im41><0+@tXX%0Khqmb1BW z=6vG9g$oDH+v_|y@-tS4Z%?plBT6lVkcg$lszrU{*K7J7-?}T`KljTb6{Qx@LRw#B zjEfR3SgiWZXf$$BnWb2KiPhuyqiXKJ#I`fT>JL^uQJl2{AF(mH>N6ajkB5y~smo+% zh{?{1acm8*KS9_8n|6w^;miru;@sP{lu!9)(sz@V3Dr>>?zl{=X6$&ywCcqqO)gBU zEC%%!XRkhU2hRGNYDtnN>;9&?o=r7g{7CguM)54fy>AFdkS-4hBPH^IFj2w^gqadH zAc!Tx)R|%uH^lPt9Q^cbZgokD2U${#0uU&Two($6mMnI3@C{?k!C6&|0o#^xp)8r( z629iztD6JsZn(J}>qa_B7F6~zNc)Hk#4xk4Z07ifbUP z5nutN0nz~(fJ{IZARCYa$OX&-Ln-il2W4_dHvr-38mH_y45#|wX4vZ3pyA_uvt zXvw`#iVX9f$rD`dc~!k#fY)In%$s?qO#ANjvz>`0or%)U#L~`$voo=*Gf~!=Sl*c^ z?@V0UnOM=8SQ$&KVjadyIXa!5!zP5qs3A^X6)PC7H)_OF&cX$l&#VXsoMldDW!3U> zr*mz2`I@y=Gcntwul83~%r1xCiD(3*ZK<22=v7$ex_)I~xs)3>$gnt`uNXM|G)aywP}t zajx-#;kDXlYX@rgkb<6t*XetshYK~R9yl3PBJ;2Kd~{3g=j=Oo?TT+Xu`?f;VI+j^ z;qms})tQ_ReVNDKzpc7}{SuF-ZmX758sx+5?&{eIKq#SWLi8WO7M+sa7 zLREbQ*QMj)NKKJREz5v64z(Kl9R`W)j?~;?kHzy`0&%%&PI3gUYChQXy&4mK?62%o z*zst#hzI`4s&VUC_7O7lT+NwfebbL?(u;jae)eh!q`iecAK^GWI8r&ENKtE!@XgCR zKD*Sep}Q^zTtSBJy7J6bpFw);)Roq4$#>aaOW1ag$!!&m2+s%)3%8B8_*_1l?<4PP z-sipj=Iv&WxyVcw4tU--vWIz`H{>Y~|9~DJgVGSKpWnJOkg>HqybR?ihDC>zVT)|3 z)Ufm7a9kM{k!r^5r5A_ulwkp}Glokq4*!lv_!mQ-d^VlOr-nSsRccg#7Yuu510i9b zLfG*w3SlD;4SN^{#yI@gh$kmsEw2hbS^h5EzO5rIbsbpz@`xu3SQ&D1#Pd`f?-g`9 zFsF_g!w^6+RoRHe+q>0Q(lh#txihjZ7V)y8>N?Y{_|V>USvb!xUVf7|rAG z+r3^Z4&Uc}B%B?NFo+xbuT`^@^-|U7;0fctjum1o>SZNEkD(&DeenU4Do5wp>2Z5L zs(rC`bgDIqWq&dD{sYvvsZ!tsZLdeKZ`d%XK-}BuKXZ1EM zq5G>)-s*jj!9cGf=Y7p;k#JJoaXT}QyyL2y%Ti&Tr0320n;^mS*AdoVZ%Pos-!KNN zxf;|GlZz9shD@GnBaySAh7%^szlSP)SZ8+A`FeT*8G;HclERh*) zu;qpmLV;pdWy>iJW!uSn6Z1D56Y#Nv4MnlI|6KzfSX5{s=YHCdp22hzOGo=*p*O1O znw)MRlhao%llV(Oe7zEj#b918jScjpnX__3lXNmJi@`oSFZ@XOwtzDnL6_FBsy4Uw zPh;a`b);1TiP8;td_}O9eVfPmD}x2Bm&dM^K}n~9FheiB4d1geXvKG~3~pnqc>LkY zpqo1%bY$#{XbidZYW?jC+MA?M==ZZ8BNX zm6F^RXZc=W04K;4rqdikm4I3+Wg86y_b4N zYIS%}-5cN?ANM^o7&I)Vl*Y#6Zxas<>-KhyP9b!?j%)C&}FjLGw zum5LeMVX$!>q5Z-d5YoB+=2sd;;g3F3s}2*WLE2Qv>R!Y!GM zfqXd9GPw;O?{3cM9n4@LMA%z@E7%p+uJ|&l$|oXVY=WgBH_*)5V*b|STa8Z*+gqPdomfSd-gOs7~-$-LO^h|)g6IX z(%u+kNPJo2ReJVao}4x{nOH3T)OU)wFR1w(ONj5x-y$)q%xYo)9o`g+zR) zB;+N6qvc7t-9!X;%Y6bF^o4Bh+#eo0*XxA8L>%uZbvE4D{S0!q;zMnL;#g1akdXID zo-E)g(js@;%PM?GUsxWCW{wJJDG8}MM~6>;y|5zY*AgK&)tRbuLBu>*CPXF<*1arP zKDk6D4uk^U*hGkRfK3`@n}kd({1TM&uYYG*mHJaH3sU%`lz*Sao#0uuI+c;V+#+7K K&)@8z&g<_cGb!Bw diff --git a/Model/InputSignal.cs b/Model/InputSignal.cs index b7e156f..a530756 100644 --- a/Model/InputSignal.cs +++ b/Model/InputSignal.cs @@ -63,98 +63,149 @@ namespace Model } set { + //levelState = value; + //if (ToRunControlCard) + //{ + // if (MyCard == null) + // { + // this.InputColor = ColorStr.Gray; + // return; + // } + // switch (MyCard.Brand) + // { + // case 1: + // if (HightEff) + // { + // if (value == 0) + // { + // this.InputColor = ColorStr.Gray; + // } + // else + // { + // this.InputColor = ColorStr.Green; + // } + // } + // else + // { + // if (value == 1) + // { + // this.InputColor = ColorStr.Gray; + // } + // else + // { + // this.InputColor = ColorStr.Green; + // } + // } + // break; + // case 2: + // if (HightEff) + // { + // if (value == 0) + // { + // this.InputColor = ColorStr.Green; + // } + // else + // { + // this.InputColor = ColorStr.Gray; + // } + // } + // else + // { + // if (value == 1) + // { + // this.InputColor = ColorStr.Green; + + // } + // else + // { + // this.InputColor = ColorStr.Gray; + // } + // } + // break; + + // } + //} + //else + //{ + // if (HightEff) + // { + // if (value == 0) + // { + // this.InputColor = ColorStr.Gray; + // } + // else if (value >= 0) + // { + // this.InputColor = ColorStr.Green; + // } + // } + // else + // { + // if (value == 1) + // { + // this.InputColor = ColorStr.Gray; + // } + // else if (value >= 0) + // { + // this.InputColor = ColorStr.Green; + // }else + // { + // this.InputColor = ColorStr.Red; + // } + // } + //} + levelState = value; - if (ToRunControlCard) - { - if (MyCard == null) - { - this.InputColor = ColorStr.Gray; - return; - } - switch (MyCard.Brand) - { - case 1: - if (HightEff) - { - if (value == 0) - { - this.InputColor = ColorStr.Gray; - } - else - { - this.InputColor = ColorStr.Green; - } - } - else - { - if (value == 1) - { - this.InputColor = ColorStr.Gray; - } - else - { - this.InputColor = ColorStr.Green; - } - } - break; - case 2: - if (HightEff) - { - if (value == 0) - { - this.InputColor = ColorStr.Green; - } - else - { - this.InputColor = ColorStr.Gray; - } - } - else - { - if (value == 1) - { - this.InputColor = ColorStr.Green; - - } - else - { - this.InputColor = ColorStr.Gray; - } - } - break; - - } - } - else + if (g_handle == (IntPtr)0) { if (HightEff) { - if (value == 0) + if (value == 1) { this.InputColor = ColorStr.Gray; } - else if (value >= 0) + else { this.InputColor = ColorStr.Green; } } else { - if (value == 1) + if (value == 0) { this.InputColor = ColorStr.Gray; } - else if (value >= 0) + else { this.InputColor = ColorStr.Green; - }else - { - this.InputColor = ColorStr.Red; } } } + else + { + if (HightEff) + { + if (value == 1) + { + this.InputColor = ColorStr.Green; + } + else + { + this.InputColor = ColorStr.Gray; + } + } + else + { + if (value == 0) + { + this.InputColor = ColorStr.Green; - + } + else + { + this.InputColor = ColorStr.Gray; + } + } + } } } @@ -168,6 +219,11 @@ namespace Model /// public bool ToRunControlCard { get; set; } + /// + /// 空信号 + /// + public bool EmptySignal { get; set; } + private string inputColor; /// /// 表示显色 @@ -213,46 +269,49 @@ namespace Model //LevelState = LTSMC.smc_read_inbit(CardID, IoNumber); - if (MyCard != null) + //if (MyCard != null) + //{ + // //确认运动控制的品牌 + // switch (MyCard.Brand) + // { + // case 1: + // //根据品牌的不同,选择相应的状态获取方式 + // if (MyCard.InterfaceType == 2) + // { + // LevelState = LTSMC.smc_read_inbit(MyCard.CardID, IoNumber); + // } + // else + // { + // LevelState = LTSMC.smc_read_inbit(MyCard.CardID, IoNumber); + // } + + // break; + // case 2: + // if (MyCard.InterfaceType == 2) + // { + // uint state = 0; + // zmcaux.ZAux_Direct_GetIn(MyCard.g_handle, IoNumber, ref state); + // LevelState = Convert.ToInt32(state); + // } + // else + // { + // int state = 100; + // ADTMC.adt_read_inbit(MyCard.CardID, IoNumber, out state); + // LevelState = state; + // } + // break; + // } + //} + + if (MS_MB_API.Connect()) { - //确认运动控制的品牌 - switch (MyCard.Brand) - { - case 1: - //根据品牌的不同,选择相应的状态获取方式 - if (MyCard.InterfaceType == 2) - { - LevelState = LTSMC.smc_read_inbit(MyCard.CardID, IoNumber); - } - else - { - LevelState = LTDMC.dmc_read_inbit(MyCard.CardID, IoNumber); - } - - break; - case 2: - if (MyCard.InterfaceType == 2) - { - uint state = 0; - zmcaux.ZAux_Direct_GetIn(MyCard.g_handle, IoNumber, ref state); - LevelState = Convert.ToInt32(state); - } - else if (MyCard.InterfaceType == 0) - { - LevelState = adt8949.adt8949_read_bit(MyCard.CardID, IoNumber); - } - else - { - int state = 100; - ADTMC.adt_read_inbit(MyCard.CardID, IoNumber, out state); - LevelState = state; - } - break; - } + LevelState = MS_MB_API.Inputs[IoNumber]; } + else + { + LevelState = 0; - - + } } else { @@ -263,5 +322,25 @@ namespace Model } } + + /// + /// 将八进制整数转换为十进制整数 + /// + /// 八进制整数 + /// 十进制整数 + public int OctalToDecimal(int octal) + { + int decimalValue = 0; + int baseValue = 1; + int temp = octal; + while (temp > 0) + { + int lastDigit = temp % 10; + decimalValue += lastDigit * baseValue; + baseValue *= 8; + temp /= 10; + } + return decimalValue; + } } } diff --git a/Model/MS_MB_API.cs b/Model/MS_MB_API.cs new file mode 100644 index 0000000..2e0e089 --- /dev/null +++ b/Model/MS_MB_API.cs @@ -0,0 +1,340 @@ +using System.Runtime.InteropServices; +using System.Threading; + +namespace Model +{ + public class MS_MB_API + { + static string IP = "192.168.0.8"; + static bool s_link; + static int c_id = 0; + static Comm_Config config = new Comm_Config(); + static byte[] bit_In = new byte[64]; + static byte[] bit_Out = new byte[64]; + static byte[] zero = new byte[64]; + + public static byte[] Inputs = new byte[64]; + public static byte[] Outputs = new byte[64]; + + + static Thread IO; + static MS_MB_API() + { + IO = new Thread(IOUpdate); + IO.IsBackground = true; + IO.Start(); + + } + + public static void IOUpdate() + { + while (true) + { + Thread.Sleep(10); + + if (Connect()) + { + var errorCode = MS_ReadBits_X(c_id, 0, 64, ref bit_In[0]); + if (errorCode != MS_MB_ERR_NONE) + { + s_link = false; + return; + } + Inputs = bit_In; + bit_Out = Outputs; + errorCode = MS_WriteBits_Y(c_id, 0, 64, bit_Out); + if (errorCode != MS_MB_ERR_NONE) + { + s_link = false; + } + + + } + else + { + + Inputs = zero; + } + + } + } + + public static bool Connect() + { + + if (s_link == false) + { + + config.enet.ip = IP; + config.enet.port = 502; + config.type = COMM_TYPE_ENET; + + + if (MS_OpenComm(config, ref c_id) == MS_MB_ERR_NONE) + { + MS_CommSetSlave(c_id, 1); + s_link = true; + + } + } + + return s_link; + } + public bool Connect(string ip) + { + IP = ip; + return Connect(); + + } + + public MS_MB_API() + { + } + + [StructLayout(LayoutKind.Sequential)] + public struct MS_AIXS_INFO + { + public byte motion_state; + public byte enable; + public byte busy; + public byte limit_positive; + public byte limit_negative; + public byte home_switch; + public byte cmd_done; + public byte[] reserve; + + public int position; + public int velocity; + + public MS_AIXS_INFO(int dummy) + { + motion_state = 0; + enable = 0; + busy = 0; + limit_positive = 0; + limit_negative = 0; + home_switch = 0; + cmd_done = 0; + reserve = new byte[9]; + position = 0; + velocity = 0; + } + } + + public const byte MotionState_Idle = 0; + public const byte MotionState_Moving = 1; + public const byte MotionState_Homing = 2; + public const byte MotionState_Jogging = 3; + + public const int HomeMode_NegativeLimit = 1; //负限位查询 + public const int HomeMode_PositiveLimit = 2; //正限位查询 + public const int HomeMode_PositiveLimitHomeSw = 7; //正限位+零位查询 + public const int HomeMode_NegativeLimitHomeSw = 11; //负限位+零位查询 + public const int HomeMode_CurrentPos = 135; //当前位置值零位 + + [StructLayout(LayoutKind.Sequential)] + public struct Serial_Comm + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] + public string portName; //填入串口号:"COMxx",xx为串口序号,如:"COM0","COM12","COM23" + + public uint baudrate; + public ushort dataBits; //7,8 + public ushort stopBits; //1,2 + public ushort parity; //0-N,1-O,2-E + public ushort rts; //0-disable,1-enable + } + + [StructLayout(LayoutKind.Sequential)] + public struct Enet_Comm + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] + public string ip; //填入IP地址,如:"192.168.0.8" + + public ushort port; + } + + public const ushort COMM_TYPE_NONE = 0; + public const ushort COMM_TYPE_SER = 1; + public const ushort COMM_TYPE_ENET = 2; + + [StructLayout(LayoutKind.Sequential)] + public struct Comm_Config + { + public ushort type; + public ushort timeOut; //ms + public int c_id; + + [MarshalAs(UnmanagedType.Struct)] + public Serial_Comm serial; + + [MarshalAs(UnmanagedType.Struct)] + public Enet_Comm enet; + } + + //==== 通信 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_OpenComm", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_OpenComm(Comm_Config config, ref int c_id); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_CommSetSlave", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_CommSetSlave(int c_id, int slave); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_CloseComm", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_CloseComm(int c_id); + + //==== 读位寄存器 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_X", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_X(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_Y", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_Y(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_M", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_M(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_S", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_S(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_T", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_T(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_C", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_C(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_F", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_F(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_B", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_B(int c_id, ushort start, ushort num, ref byte pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadBits_L", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadBits_L(int c_id, ushort start, ushort num, ref byte pData); + + //==== 写位寄存器 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_Y", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_Y(int c_id, ushort start, ushort num, byte[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_M", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_M(int c_id, ushort start, ushort num, byte[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_S", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_S(int c_id, ushort start, ushort num, byte[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_F", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_F(int c_id, ushort start, ushort num, byte[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_B", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_B(int c_id, ushort start, ushort num, byte[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteBits_L", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteBits_L(int c_id, ushort start, ushort num, byte[] pData); + + //==== 读字寄存器 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_D", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_D(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_R", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_R(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_VD", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_VD(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_RD", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_RD(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_T", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_T(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_C16", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_C16(int c_id, ushort start, ushort num, ref ushort pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_ReadWord_C32", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_ReadWord_C32(int c_id, ushort start, ushort num, ref uint pData); + + //==== 写字寄存器 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteWord_D", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteWord_D(int c_id, ushort start, ushort num, ushort[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteWord_R", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteWord_R(int c_id, ushort start, ushort num, ushort[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteWord_VD", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteWord_VD(int c_id, ushort start, ushort num, ushort[] pData); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_WriteWord_RD", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_WriteWord_RD(int c_id, ushort start, ushort num, ushort[] pData); + + //==== 运动控制轴获取 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisCount", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisCount(int c_id, ref ushort axis_cnt); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisState", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisState(int c_id, int axis_idx, ref byte state); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisEnable", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisEnable(int c_id, int axis_idx, ref byte enable); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisBusy", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisBusy(int c_id, int axis_idx, ref byte busy); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisLimitPos", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisLimitPos(int c_id, int axis_idx, ref byte limit_pos); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisLimitNeg", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisLimitNeg(int c_id, int axis_idx, ref byte limit_neg); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisHomeSwitch", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisHomeSwitch(int c_id, int axis_idx, ref byte home_sw); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisCmdDone", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisCmdDone(int c_id, int axis_idx, ref byte cmd_done); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisPosition", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisPosition(int c_id, int axis_idx, ref int position); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisVelocity", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisVelocity(int c_id, int axis_idx, ref int velocity); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionGetAxisInfo", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionGetAxisInfo(int c_id, int axis_idx, ref MS_AIXS_INFO axis_info); + + //==== 运动控制轴设置 + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisEnable", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisEnable(int c_id, int axis_idx, byte enable); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisPosition", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisPosition(int c_id, int axis_idx, int position); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisMoveAbs", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisMoveAbs(int c_id, int axis_idx, int pos, int vel, int acc_ms, int dec_ms); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisMoveInc", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisMoveInc(int c_id, int axis_idx, int dis, int vel, int acc_ms, int dec_ms); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisMoveVel", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisMoveVel(int c_id, int axis_idx, int vel, int acc_ms, int dec_ms); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisHome", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisHome(int c_id, int axis_idx, int home_mode, int vel_fast, int vel_slow, int acc_ms, int dec_ms, int offset); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisJogging", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisJogging(int c_id, int axis_idx, int vel, int acc_ms, int dec_ms); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisStop", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisStop(int c_id, int axis_idx); + + [DllImport("MS_ModbusApi.dll", EntryPoint = "MS_MotionSetAxisDirReverse", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] + public extern static int MS_MotionSetAxisDirReverse(int c_id, int axis_idx, byte reverse); + + //错误码 + public const int MS_MB_ERR_NONE = 0; + public const int MS_MB_ERR_CONFIG = 1000; + public const int MS_MB_ERR_OPEN = 1001; + public const int MS_MB_ERR_NODATA = 1002; + public const int MS_MB_ERR_NOTFOUND = 1003; + public const int MS_MB_ERR_MEM = 1004; + public const int MS_MB_ERR_FUNCPARAM = 1005; + public const int MS_MB_ERR_COMM = 1006; + public const int MS_MB_ERR_AXIS_DISABLED = 1100; + } +} \ No newline at end of file diff --git a/Model/Model.csproj b/Model/Model.csproj index c0a0d27..167a3d2 100644 --- a/Model/Model.csproj +++ b/Model/Model.csproj @@ -103,11 +103,13 @@ + + diff --git a/Model/MotionControl/LeiSaiCard.cs b/Model/MotionControl/LeiSaiCard.cs index 75f83b3..ae92dec 100644 --- a/Model/MotionControl/LeiSaiCard.cs +++ b/Model/MotionControl/LeiSaiCard.cs @@ -198,4 +198,98 @@ namespace Model.MotionControl } #endregion } + + public class LeiSaiMBCard : FeiYuCard + { + + + #region 获取轴数量 + /// + /// 获取轴数量 + /// + public override bool GetCradInfo() + { + + return false; + } + #endregion + + #region 连接控制器 + public static int s_link = 0; + public static Int32 c_id = 0; + MS_MB_API.Comm_Config config = new MS_MB_API.Comm_Config(); + /// + /// 连接控制器 + /// + /// + public override bool Connect() + { + try + { + if (InterfaceType == 0) + { + config.serial.portName = PconnectString; + config.serial.baudrate = 115200; + config.serial.dataBits = 8; + config.serial.parity = 0; + config.serial.stopBits = 1; + config.type = MS_MB_API.COMM_TYPE_SER; + } + else + { + config.enet.ip = PconnectString; + config.enet.port = 502; + config.type = MS_MB_API.COMM_TYPE_ENET; + } + + + if (MS_MB_API.MS_OpenComm(config, ref c_id) == MS_MB_API.MS_MB_ERR_NONE) + { + MS_MB_API.MS_CommSetSlave(c_id, 1); + s_link = 1; + + CardID = (ushort)c_id; + return true; + } + else + { + + + return false; + + } + + } + catch (Exception) + { + return false; + } + } + #endregion + + #region 关闭控制器 + /// + /// 关闭控制器 + /// + public override void close() + { + if (s_link == 0) + return; + MS_MB_API.MS_CloseComm(c_id); + s_link = 0; + + } + #endregion + + #region 所有轴紧急停止 + /// + /// 所有轴紧急停止 + /// + /// 卡ID + public override void MoveFunction_Estop() + { + + } + #endregion + } } diff --git a/Model/OutputSignal.cs b/Model/OutputSignal.cs index 8c97df4..0d77031 100644 --- a/Model/OutputSignal.cs +++ b/Model/OutputSignal.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; namespace Model { + /// + /// 输出信号类 + /// /// /// 输出信号类 /// @@ -40,11 +43,6 @@ namespace Model /// public ushort IoNumber { get; set; } - /// - /// IO打开的时间 - /// - public DateTime SwitchsOpenTime { get; set; } - private bool switchs; /// @@ -57,47 +55,52 @@ namespace Model { switchs = value; - if (ToRunControlCard && MyCard != null) + //if (ToRunControlCard && MyCard != null) + //{ + // switch (MyCard.Brand) + // { + // case 1: + // if (value) + // { + // LevelState = 0; + // } + // else + // { + // LevelState = 1; + // } + // break; + // case 2: + // if (value) + // { + // LevelState = 0; + // } + // else + // { + // LevelState = 1; + // } + // break; + // } + //} + //else + //{ + // if (value) + // { + // LevelState = 1; + // } + // else + // { + // LevelState = 0; + // } + + //} + + if (value) { - switch (MyCard.Brand) - { - case 1: - if (value) - { - LevelState = 0; - SwitchsOpenTime = DateTime.Now; - } - else - { - LevelState = 1; - } - break; - case 2: - if (value) - { - LevelState = 0; - SwitchsOpenTime = DateTime.Now; - } - else - { - LevelState = 1; - } - break; - } + LevelState = 1; } else { - if (value) - { - LevelState = 1; - SwitchsOpenTime = DateTime.Now; - } - else - { - LevelState = 0; - SwitchsOpenTime = DateTime.Now; - } - + LevelState = 0; } this.RaisePropertyChanged("Switchs"); @@ -132,43 +135,52 @@ namespace Model { levelState = value; - if (ToRunControlCard && MyCard != null) + //if (ToRunControlCard && MyCard != null) + //{ + // switch (MyCard.Brand) + // { + // case 1: + // if (value == 1) + // { + // this.OutputColor = ColorStr.Green; + // } + // else + // { + // this.OutputColor = ColorStr.Red; + // } + // break; + // case 2: + // if (value == 0) + // { + // this.OutputColor = ColorStr.Red; + // } + // else + // { + // this.OutputColor = ColorStr.Green; + // } + // break; + // } + //} + //else + //{ + // if (value == 0) + // { + + // this.OutputColor = ColorStr.Green; + // } + // else + // { + // this.OutputColor = ColorStr.Red; + // } + //} + + if (value == 1) { - switch (MyCard.Brand) - { - case 1: - if (value == 1) - { - this.OutputColor = ColorStr.Green; - } - else - { - this.OutputColor = ColorStr.Red; - } - break; - case 2: - if (value == 0) - { - this.OutputColor = ColorStr.Red; - } - else - { - this.OutputColor = ColorStr.Green; - } - break; - } + this.OutputColor = ColorStr.Red; } else { - if (value == 0) - { - - this.OutputColor = ColorStr.Green; - } - else - { - this.OutputColor = ColorStr.Red; - } + this.OutputColor = ColorStr.Green; } OutputSwitch(value); @@ -185,6 +197,11 @@ namespace Model /// public bool ToRunControlCard { get; set; } + /// + /// 空信号 + /// + public bool EmptySignal { get; set; } + private string outputColor; /// /// 表示显色 @@ -210,100 +227,89 @@ namespace Model #region 控制卡输出信号开关 + /// + /// 控制卡输出信号开关 + /// + public void OutputSwitch1(ushort onoff) + { + + if (ToRunControlCard && MyCard != null) + { + switch (MyCard.Brand) + { + case 1: + if (MyCard.InterfaceType == 2) + { + LTSMC.smc_write_outbit(MyCard.CardID, IoNumber, onoff); + } + else + { + LTDMC.dmc_write_outbit(MyCard.CardID, IoNumber, onoff); + } + break; + case 2: + onoff = onoff == (ushort)0 ? (ushort)1 : (ushort)0; + if (MyCard.InterfaceType == 2) + { + zmcaux.ZAux_Direct_SetOp(g_handle, IoNumber, onoff); + } + else + { + ADTMC.adt_write_outbit(MyCard.CardID, IoNumber, onoff); + } + break; + + } + } + else + { + //雷赛IO卡 + //IOC0640.ioc_write_outbit(CardID, IoNumber, onoff); + //众为兴沙雕IO卡 + //adtIO3224.adtIO3224_write_bit(CardID, IoNumber, onoff); + + //雷赛IO模块 + MS_MB_API.Outputs[IoNumber] = (byte)levelState; + } + } + /// /// 控制卡输出信号开关 /// public void OutputSwitch(ushort onoff) { - - if (ToRunControlCard && MyCard != null) + if (ToRunControlCard) { - switch (MyCard.Brand) - { - case 1: - if (MyCard.InterfaceType == 2) - { - LTSMC.smc_write_outbit(MyCard.CardID, IoNumber, onoff); - } - else - { - LTDMC.dmc_write_outbit(MyCard.CardID, IoNumber, onoff); - } - break; - case 2: - onoff = onoff == (ushort)0 ? (ushort)1 : (ushort)0; - if (MyCard.InterfaceType == 2) - { - zmcaux.ZAux_Direct_SetOp(g_handle, IoNumber, onoff); - } - else if (MyCard.InterfaceType==0) - { - adt8949.adt8949_write_bit(MyCard.CardID, IoNumber, onoff); - } - else - { - ADTMC.adt_write_outbit(MyCard.CardID, IoNumber, onoff); - } - break; - - } - - - - + // LTDMC.dmc_write_outbit(CardID, IoNumber, onoff); + // LTSMC.smc_write_outbit(CardID, IoNumber, onoff); + // zmcaux.ZAux_Direct_SetOp(g_handle, IoNumber, onoff); } else { - //雷赛IO卡 - //IOC0640.ioc_write_outbit(CardID, IoNumber, onoff); - //众为兴沙雕IO卡 - adtIO3224.adtIO3224_write_bit(CardID, IoNumber, onoff); - } - } - - public void OutputSwitch(ushort IoNumber, ushort onoff) - { - - if (ToRunControlCard && MyCard != null) - { - switch (MyCard.Brand) - { - case 1: - if (MyCard.InterfaceType == 2) - { - LTSMC.smc_write_outbit(MyCard.CardID, IoNumber, onoff); - } - else - { - LTDMC.dmc_write_outbit(MyCard.CardID, IoNumber, onoff); - } - break; - case 2: - onoff = onoff == (ushort)0 ? (ushort)1 : (ushort)0; - if (MyCard.InterfaceType == 2) - { - zmcaux.ZAux_Direct_SetOp(g_handle, IoNumber, onoff); - } - else - { - ADTMC.adt_write_outbit(MyCard.CardID, IoNumber, onoff); - } - break; - - } - - - - - } - else - { - //雷赛IO卡 - //IOC0640.ioc_write_outbit(CardID, IoNumber, onoff); - //众为兴沙雕IO卡 - adtIO3224.adtIO3224_write_bit(CardID, IoNumber, onoff); + // IOC0640.ioc_write_outbit(CardID, IoNumber, onoff); } + MS_MB_API.Outputs[IoNumber] = (byte)levelState; } #endregion + + /// + /// 将八进制整数转换为十进制整数 + /// + /// 八进制整数 + /// 十进制整数 + public int OctalToDecimal(int octal) + { + int decimalValue = 0; + int baseValue = 1; + int temp = octal; + while (temp > 0) + { + int lastDigit = temp % 10; + decimalValue += lastDigit * baseValue; + baseValue *= 8; + temp /= 10; + } + return decimalValue; + } } } diff --git a/Model/StationMessage.cs b/Model/StationMessage.cs new file mode 100644 index 0000000..4195b45 --- /dev/null +++ b/Model/StationMessage.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class StationMessage + { + /// + /// 安全互锁 false时表示正在占用公共区域 + /// + public bool Safe { get; set; } + /// + /// 请求松手/拿好, + /// 取上站被物料时, 请求松手 + /// 放到下站时,请求拿好 + /// + public bool Request { get; set; } + /// + /// 确认松手/拿好 + /// 后站请求松手时,回应True + /// 前站请求拿好时,回应True + /// + public bool Confirm { get; set; } + + /// + /// 取料完成 当后站取走产品后,置位true,前站收到该信号后, 改变物料状态为ColorStr.White(无料), + /// + public bool GetDone { get; set; } + + + /// + /// 放料料完成 当产品放入后站后 ,置位true,后站收到该信号后, 改变物料状态为 ProductState , + /// + public bool PutDone { get; set; } + /// + /// 产品数量 + /// + public int ProductCount { get; set; } = 1; + + /// + /// 产品状态 ColorStr.White(无料) Blue(有料) Green(良品) Red(不良) + /// 多个产品时,用;号分割 + /// + public string ProductState { get; set; } + + /// + /// 产品条码 + /// 多个产品时,用;号分割 + /// + public string ProductSN { get; set; } + } +} diff --git a/ViewModel/HandModel.cs b/ViewModel/HandModel.cs new file mode 100644 index 0000000..fbd33aa --- /dev/null +++ b/ViewModel/HandModel.cs @@ -0,0 +1,175 @@ +using Community; +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows; +using System.Windows.Controls; + +namespace ViewModel +{ + public class HandModel : NotificationObject + { + /// + /// 序号 + /// + public int Number { get; set; } + + public Label Labels { get; set; } + + private ShowInfo state; + /// + /// 标签状态 + /// + public ShowInfo State + { + get { return state; } + set + { + state = value == null ? new ShowInfo() : value; + RaisePropertyChanged("State"); + } + } + + /// + /// 气缸 + /// + public OutputSignal QiGang { get; set; } + /// + /// 气缸原位 + /// + public InputSignal QiGangUp { get; set; } + /// + /// 气缸到位 + /// + public InputSignal QiGangDown { get; set; } + + /// + /// 顶升气缸原位 + /// + public OutputSignal YDingShengQiGangYW { get; set; } + + /// + /// 顶升气缸动位 + /// + public OutputSignal YDingShengQiGangDW { get; set; } + + /// + /// 顶升气缸原位检知 + /// + public InputSignal XDingShengQigangYW { get; set; } + + /// + /// 顶升气缸到位检知 + /// + public InputSignal XDingShengQigangDW { get; set; } + + /// + /// 伸缩气缸 + /// + public OutputSignal YShenSuoQiGangYW { get; set; } + + /// + /// 伸缩气缸 + /// + public OutputSignal YShenSuoQiGangDW { get; set; } + + /// + /// 伸缩气缸原位 + /// + public InputSignal XShenSuoQigangYW { get; set; } + + /// + /// 伸缩气缸到位 + /// + public InputSignal XShenSuoQigangDW { get; set; } + + + /// + /// 真空开关 + /// + public OutputSignal VacuumSwitch { get; set; } + + /// + /// 真空破开关 + /// + public OutputSignal VacuumPoSwitch { get; set; } + + /// + /// 真空捡知 + /// + public InputSignal VacuumCheck { get; set; } + + /// + /// 吸嘴放料点位1 + /// + public RobotPoint PutProPoint1 { get; set; } + /// + /// 吸嘴放料点位2 + /// + public RobotPoint PutProPoint2 { get; set; } + + + /// + /// 吸嘴取料点位1 + /// + public RobotPoint TakeProPoint1 { get; set; } + /// + /// 吸嘴取料点位2 + /// + public RobotPoint TakeProPoint2 { get; set; } + + public DateTime CheckVacuumTime { get; set; } + + public double OfficeX { get; set; } + public double OfficeY { get; set; } + + public double OfficeU { get; set; } + + /// + /// Label显示控件对象 + /// + public HandModel() + { + State = new ShowInfo(); + Labels = new Label(); + //数据样式 + Labels.Style = (Style)MyMessageBox.MetroWin.FindResource("Mylabel1");//LabelStyle 这个样式是引用的资源文件中的样式名称 + //绑定背景颜色 + Labels.SetBinding(Label.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatusBackground"), Mode = BindingMode.TwoWay }); + //绑定内容 + Labels.SetBinding(Label.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatuInfo"), Mode = BindingMode.TwoWay }); + + Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 + Labels.Margin = new Thickness(1); //设置边距 + } + + + /// + /// Label的双击事件 + /// + /// + /// + private void Labels_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + //如果为绿色 则不允许改其他颜色 + if (State.StatusBackground == ColorStr.White) + { + State.StatusBackground = ColorStr.Blue; + } + else if (State.StatusBackground == ColorStr.Blue) + { + State.StatusBackground = ColorStr.Green; + + } + else + { + State.StatusBackground = ColorStr.White; + } + + } + } +} diff --git a/ViewModel/MainWindowVM.cs b/ViewModel/MainWindowVM.cs index 9834f45..a8512fe 100644 --- a/ViewModel/MainWindowVM.cs +++ b/ViewModel/MainWindowVM.cs @@ -41,6 +41,104 @@ namespace ViewModel { public partial class MainWindowVM : NotificationObject { + + #region IO + int X0启动按钮 = 0; + int X1停止按钮 = 1; + int X2急停按钮 = 2; + int X3气压检知 = 3; + int X4 = 4; + int X5 = 5; + int X6 = 6; + int X7 = 7; + int X8安全门1 = 8; + int X9安全门2 = 9; + int X10安全门3 = 10; + int X11安全门4 = 11; + int X12 = 12; + int X13来料缓存位检知 = 13; + int X14左工位检知 = 14; + int X15右工位检知 = 15; + int X100流线皮带1检知1 = 16; + int X101流线皮带1检知2 = 17; + int X102流线皮带2检知1 = 18; + int X103流线皮带2检知2 = 19; + int X104NG皮带检知1 = 20; + int X105NG皮带检知2 = 21; + int X106NG皮带检知3 = 22; + int X107机械手真空检知 = 23; + int X108左笔形气缸伸出 = 24; + int X109左笔形气缸缩回 = 25; + int X110左顶升气缸下位 = 26; + int X111左顶升气缸上位 = 27; + int X112右笔形气缸伸出 = 28; + int X113右笔形气缸缩回 = 29; + int X114右顶升气缸下位 = 30; + int X115右顶升气缸上位 = 31; + int X200搬运气缸上位 = 32; + int X201搬运气缸下位 = 33; + int X202搬运真空检知 = 34; + int X203 = 35; + int X204 = 36; + int X205机械手真空检知2 = 37; + int X206机械手气缸上位1 = 38; + int X207机械手气缸下位1 = 39; + int X208机械手气缸上位2 = 40; + int X209机械手气缸下位2 = 41; + int X210 = 42; + int X211左顶升气缸下位2 = 43; + int X212左顶升气缸上位2 = 44; + int X213右顶升气缸下位2 = 45; + int X214右顶升气缸上位2 = 46; + int X215 = 47; + + int Y0绿灯 = 0; + int Y1红灯 = 1; + int Y2黄灯 = 2; + int Y3蜂鸣器 = 3; + int Y4 = 4; + int Y5 = 5; + int Y6 = 6; + int Y7 = 7; + int Y8 = 8; + int Y9 = 9; + int Y10上光源控制 = 10; + int Y11下光源控制 = 11; + int Y100流线皮带1 = 12; + int Y101流线皮带2 = 13; + int Y102NG皮带 = 14; + int Y103机械手真空吸 = 15; + int Y104机械手真空破 = 16; + int Y105左笔形气缸伸出 = 17; + int Y106左笔形气缸缩回 = 18; + int Y107左顶升气缸下位 = 19; + int Y108左顶升气缸上位 = 20; + int Y109右笔形气缸伸出 = 21; + int Y110右笔形气缸缩回 = 22; + int Y111右顶升气缸下位 = 23; + int Y112右顶升气缸上位 = 24; + int Y113 = 25; + int Y114 = 26; + int Y115 = 27; + int Y200搬运气缸上位 = 28; + int Y201搬运气缸下位 = 29; + int Y202搬运真空吸 = 30; + int Y203搬运真空破 = 31; + int Y204机械手真空吸2 = 32; + int Y205机械手真空破2 = 33; + int Y206机械手气缸上位1 = 34; + int Y207机械手气缸下位1 = 35; + int Y208机械手气缸上位2 = 36; + int Y209机械手气缸下位2 = 37; + int Y210左顶升气缸下位2 = 38; + int Y211左顶升气缸上位2 = 39; + int Y212右顶升气缸下位2 = 40; + int Y213右顶升气缸上位2 = 41; + int Y214 = 42; + int Y215 = 43; + #endregion + + #region 生产的Grid状态 private string gridWidth; /// /// Grid的宽 @@ -54,6 +152,7 @@ namespace ViewModel this.RaisePropertyChanged("GridWidth"); } } + #endregion #region 通讯服务器对象 private CommunicationServerVM serverComm; @@ -71,8 +170,6 @@ namespace ViewModel } #endregion - - #region ERP交互管理类 private ERPManageVM eRPVM; /// @@ -138,7 +235,6 @@ namespace ViewModel } #endregion - #region 串口相关 private SerialComVM sCVM; /// @@ -1138,17 +1234,20 @@ namespace ViewModel ThStateMonitoring.Start(); } - GetMachineLabelGrid();//吸嘴状态初始化 - GetVehicleGrid();//缓存载具初始化 + GetXizuiLabelGrid();//吸嘴状态初始化 + GetTestBenchGrid();//缓存载具初始化 + GetCacheLineGrid(); //缓存流线对象 + GetProduceLineGrid(); //良品流线对象 + GetStationProduceGrid(); //获取后站信息 + GetInCacheGrid(); //进料平台状态 + LogicDispatchFlow = new FlowModel("大总管"); TakeFlow = new FlowModel("取料"); DownVisionFlow = new FlowModel("测试盒取出"); BoxInPutFlow = new FlowModel("测试盒投入"); - TrayFeedFlow = new FlowModel("料盘上料"); - TrayBlankingFlow = new FlowModel("空盘回收"); - UpLineRunFlow = new FlowModel("出料流程"); - VehicleLiftRunFlow = new FlowModel("载具升降流程"); - HuiLiuFlow = new FlowModel("回流流程"); + CarryPutOutFlow = new FlowModel("机台搬运"); + ProLineFlow = new FlowModel("良品皮带运行"); + TestBoxFlow = new FlowModel("测试平台运行"); //把吸嘴给机器人 避免撞坏吸嘴 Robot.XizuiLabelPaperList = this.XizuiLabelPaperList; @@ -1219,8 +1318,6 @@ namespace ViewModel FrontStation.ReceiveCallback += FrontStation_ReceiveCallback; } - - #region 获取输出信号Grid /// /// 获取输出信号Grid @@ -1231,17 +1328,19 @@ namespace ViewModel Grid g = new Grid(); int row = 0; int column = 0; - int count = OutputList.Count; - if (count <= 13) + //int count = OutputList.Count; + var showList = OutputList.Where(w => !w.EmptySignal).ToList(); //筛选出要显示在控制卡上的输入信号,空信号不显示 + int count = showList.Count; + if (count <= 16) { row = count; column = 1; } else { - row = 13; - column = count / 13; - if (count % 13 > 0) + row = 16; + column = count / 16; + if (count % 16 > 0) { column = column + 1; } @@ -1261,7 +1360,8 @@ namespace ViewModel if (number < count) { - cb = GetCheckBox(OutputList[number]); + //cb = GetCheckBox(OutputList[number]); + cb = GetCheckBox(showList[number]); //加一个控件修饰控件 用于控制字体的大小 Viewbox vb = new Viewbox(); vb.Stretch = Stretch.Uniform; @@ -1272,9 +1372,9 @@ namespace ViewModel g.Children.Add(vb); vb.SetValue(Grid.RowProperty, j);//设置按钮所在Grid控件的行 vb.SetValue(Grid.ColumnProperty, i);//设置按钮所在Grid控件的列 - //g.Children.Add(cb); - //cb.SetValue(Grid.RowProperty, j); //设置按钮所在Grid控件的行 - //cb.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + //g.Children.Add(cb); + //cb.SetValue(Grid.RowProperty, j); //设置按钮所在Grid控件的行 + //cb.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 number++; } @@ -1293,7 +1393,7 @@ namespace ViewModel CheckBox cb = new CheckBox(); //指定样式 cb.Style = (Style)Mywindow.FindResource("CheckBoxStyle");//CheckBoxStyle 这个样式是引用的资源文件中的样式名称 - //设置数据上下文 + //设置数据上下文 cb.DataContext = os; //绑定背景颜色 cb.SetBinding(CheckBox.BackgroundProperty, new Binding() { Path = new PropertyPath("OutputColor"), Mode = BindingMode.TwoWay }); @@ -1314,6 +1414,13 @@ namespace ViewModel //设置前景色 cb.Foreground = new SolidColorBrush(Colors.White); //Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 + + //鼠标悬停显示端口号 + cb.MouseEnter += (s, e) => + { + cb.ToolTip = $"{os.IoNumber}"; + }; + cb.FontFamily = new System.Windows.Media.FontFamily("楷体"); cb.Margin = new Thickness(1); //设置边距 cb.HorizontalContentAlignment = HorizontalAlignment.Left; @@ -1332,17 +1439,19 @@ namespace ViewModel Grid g = new Grid(); int row = 0; int coloum = 0; - int count = InputList.Count; - if (count <= 15) + var showList = InputList.Where(w => !w.EmptySignal).ToList(); //筛选出要显示在控制卡上的输入信号,空信号不显示 + int count = showList.Count; + + if (count <= 16) { row = count; coloum = 1; } else { - row = 15; - coloum = count / 15; - if (count % 15 > 0) + row = 16; + coloum = count / 16; + if (count % 16 > 0) { coloum = coloum + 1; } @@ -1362,14 +1471,14 @@ namespace ViewModel if (number < count) { - label = GetLabel(InputList[number]); + //label = GetLabel(InputList[number]); + label = GetLabel(showList[number]); g.Children.Add(label); label.SetValue(Grid.RowProperty, j); //设置按钮所在Grid控件的行 label.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 - - number++; } + number++; } } return g; @@ -1379,8 +1488,8 @@ namespace ViewModel { Label Labels = new Label(); //数据样式 - Labels.Style = (Style)Mywindow.FindResource("LabelStyle");//LabelStyle 这个样式是引用的资源文件中的样式名称 - //设置数据上下文 + Labels.Style = (Style)Mywindow.FindResource("LabelStyle");//CheckBoxStyle 这个样式是引用的资源文件中的样式名称 + //设置数据上下文 Labels.DataContext = Is; //绑定背景颜色 Labels.SetBinding(Label.BackgroundProperty, new Binding() { Path = new PropertyPath("InputColor"), Mode = BindingMode.TwoWay }); @@ -1393,7 +1502,6 @@ namespace ViewModel vb.StretchDirection = StretchDirection.Both; //vb.HorizontalAlignment = HorizontalAlignment.Left; - if (Application.Current.Resources[Is.InputMeaning] != null) { vb.Child = new TextBlock() { Text = Application.Current.Resources[Is.InputMeaning].ToString() }; @@ -1408,6 +1516,12 @@ namespace ViewModel //设置前景色 Labels.Foreground = new SolidColorBrush(Colors.White); + //鼠标悬停显示端口号 + Labels.MouseEnter += (s, e) => + { + Labels.ToolTip = $"{Is.IoNumber}"; + }; + //Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 Labels.FontFamily = new System.Windows.Media.FontFamily("楷体"); @@ -1502,17 +1616,75 @@ namespace ViewModel GoHome(); //回原点 - //将输入信号集合付给每一个点位,防止撞机 - foreach (MotionPointModel item in MCVM.TrajListL[0].PointList) + //测试中,获取测试结果 + if (Testing) { - item.InputList = this.InputList; + if (TestRecStr.Contains("TESTOK")) + { + Testing = false; //测试结束 + TestFinish = true; //测试完成信号 + } + else if (TestRecStr.Contains("ALARM")) //测试机回复报错 + { + TestResultStr = "NG"; + Testing = false; //测试结束 + TestFinish = true; //测试完成信号 + } } - if (NextStation.Showmsg.StatusBackground != ColorStr.Green) + DualControlRun();//双控运行 + + GoHome(); //回原点 + + //将输入信号集合付给每一个点位,防止撞机 + //foreach (MotionPointModel item in MCVM.TrajListL[0].PointList) + //{ + // item.InputList = this.InputList; + //} + + + //前后站物料状态 + if (FrontStationReceive != null) { - ExcepStop("后站未连接"); + StationProduceList[0].State.StatusBackground = FrontStationReceive.ProductState; + if (FrontStationReceive.Safe) + { + StationProduceList[0].State.StatuInfo = "安全"; + } + else + { + StationProduceList[0].State.StatuInfo = "不安全"; + } } + if (NextStationReceive != null) + { + StationProduceList[1].State.StatusBackground = NextStationReceive.ProductState; + if (NextStationReceive != null && NextStationReceive.Safe) + { + StationProduceList[1].State.StatuInfo = "安全"; + } + else + { + StationProduceList[1].State.StatuInfo = "不安全"; + } + } + + //检查后站连接 + //if (NextStation.Showmsg.StatusBackground != ColorStr.Green) + //{ + // ExcepStop("后站断开"); + //} + + if (!PutOk) + { + NextStationSend.Request = false; + } + + SendFrontStation();//发送信息给前站 + + SendNextStation();//发送消息给下一站 + } } } @@ -1574,7 +1746,6 @@ namespace ViewModel } #endregion - #endregion #region 3、运行 @@ -1586,18 +1757,19 @@ namespace ViewModel while (true) { Thread.Sleep(10); - if (RunStatu == RunStatuEnum.Normal && !GratingSignal) + if (RunStatu == RunStatuEnum.Normal) { try { - LogicDispatch(LogicDispatchFlow);//逻辑总管 - TrayFeedRun(TrayFeedFlow); //Tray上料流程 - TrayBlankingRun(TrayBlankingFlow); //空盘回收 - UpLineRun(UpLineRunFlow); //出料流程 - VehicleLiftRun(VehicleLiftRunFlow); //载具升降运行 - HuiLiuRun(HuiLiuFlow); //回流运行 - //实时发送信息给下一站 - SendNextStation(); + if (!GRRMode) + { + LogicDispatch(LogicDispatchFlow);//逻辑总管 + //CarryPutOutRun(CarryPutOutFlow); //机台搬运 + //ProLineRun(ProLineFlow);//良品皮带 + } + TestBoxRun(TestBoxFlow);//测试平台 + //CheckXizui(); + //BadRun(); //不良皮带 } catch (Exception ex) { @@ -1613,6 +1785,8 @@ namespace ViewModel /// FlowModel LogicDispatchFlow { get; set; } + bool ClearBox { get; set; } + /// /// 大总管 //蓝色:测试中 黄色:取出不投入 绿色:取出并投入 红色:异常 /// @@ -1621,7 +1795,9 @@ namespace ViewModel switch (MyFlow.RunStep) { case GengralProcessEnum.Start: + RobotSafe = true; MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; TakeFlow = new FlowModel("取料运行"); break; case GengralProcessEnum.Step1: @@ -1629,35 +1805,82 @@ namespace ViewModel if (TakeRun(TakeFlow)) { MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; DownVisionFlow = new FlowModel("下视觉检查"); } break; case GengralProcessEnum.Step2: + RobotSafe = true; //下视觉检查 if (DownVisionRun(DownVisionFlow)) { MyFlow.RunStep++; - AnalysisFlow = new FlowModel("产品分选"); + MyFlow.RunTime = DateTime.Now; } break; case GengralProcessEnum.Step3: - //产品分选 - if (AnalysisRun(AnalysisFlow)) + //获取可以取料的测试盒 + CurrBox = TestBenchBox.Where(w => (w.State.StatusBackground == ColorStr.White && !ClearBox) || w.State.StatusBackground == ColorStr.Green || w.State.StatusBackground == ColorStr.Red).FirstOrDefault(); + if (CurrBox != null) { + //获取吸嘴 + CurrXizui = XizuiLabelPaperList[1]; MyFlow.RunStep++; - BoxInPutFlow = new FlowModel("料盘投入"); + MyFlow.RunTime = DateTime.Now; + BoxOutPutFlow = new FlowModel("测试盒取出"); } break; case GengralProcessEnum.Step4: - //投入载具 + RobotSafe = true; + //测试盒取出 + if (BoxOutPutRun(BoxOutPutFlow)) + { + if (!ClearBox) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else + { + //清料 + AnalysisFlow = new FlowModel("产品分选"); + MyFlow.RunStep = GengralProcessEnum.Step7; + MyFlow.RunTime = DateTime.Now; + } + } + break; + case GengralProcessEnum.Step5: + //获取可以投入的测试盒 + CurrBox = TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault(); + if (CurrBox != null) + { + //指定吸嘴 + CurrXizui = XizuiLabelPaperList[0]; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + BoxInPutFlow = new FlowModel("测试盒投入"); + } + break; + case GengralProcessEnum.Step6: + RobotSafe = true; + //测试盒投入 if (BoxInPutRun(BoxInPutFlow)) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + AnalysisFlow = new FlowModel("产品分选"); + } + break; + case GengralProcessEnum.Step7: + RobotSafe = true; + //产品分选 + if (AnalysisRun(AnalysisFlow)) { MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; } break; } - } #endregion @@ -1690,6 +1913,7 @@ namespace ViewModel /// 视觉定位次数 /// int VisonCount { get; set; } + /// /// 取料运行 /// @@ -1700,9 +1924,10 @@ namespace ViewModel switch (MyFlow.RunStep) { case GengralProcessEnum.Start: + RobotSafe = true; //获取可以取料的吸嘴 - CurrXizui = XizuiLabelPaperList.Where(w => w.State.StatusBackground == ColorStr.White).FirstOrDefault(); - if (CurrXizui != null) + CurrXizui = XizuiLabelPaperList[0]; + if (CurrXizui.State.StatusBackground == ColorStr.White) { MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; @@ -1712,14 +1937,195 @@ namespace ViewModel bl = true; } break; - - #region 上视觉检查 case GengralProcessEnum.Step1: - //获取可取产品 - CurrLabel = Tray1.MyLabelList.Where(w => (w.Prouct.StateColour == ColorStr.Green)).FirstOrDefault(); - if (CurrLabel != null && TrayFeedReady) + RobotSafe = true; + //获取可取产品,并且搬运轴在安全位置 + if (InCacheList[0].State.StatusBackground == ColorStr.Green || CurrentMachine.RunningMode) { - TempPoint = Coper(CurrLabel.TakeVisionPoint); + RobotSafe = false; + //获取取料点 + TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 3).FirstOrDefault()); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + //测试盒有待取料,清料 + else if (TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.Green || w.State.StatusBackground == ColorStr.Red).Count() > 0) + { + //清料模式 + ClearBox = true; + bl = true; + } + break; + case GengralProcessEnum.Step2: + RobotSafe = false; + //发送机器人点位 + Robot.RunRobotPoint(TempPoint); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step3: + RobotSafe = false; + //机器人到位 + if (Robot.RcvShowInfo.Contains("runpointok")) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) + { + MyFlow.RunStep--; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step4: + //气缸下降 + CurrXizui.QiGang.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step5: + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) + { + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangDown.InputMeaning + "异常")) + { + //气缸下降 + CurrXizui.QiGang.Switchs = true; + } + break; + case GengralProcessEnum.Step6: + //真空检知有 + if (CurrXizui.VacuumCheck.LightUp || CurrentMachine.RunningMode) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) + { + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step7: + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) + { + //二次检查真空 + if (CurrXizui.VacuumCheck.LightUp || CurrentMachine.RunningMode) + { + //机械手状态变成有料 + CurrXizui.State.StatusBackground = ColorStr.Blue; + InCacheList[0].State.StatusBackground = ColorStr.White; + MyFlow.RunStep = GengralProcessEnum.End; + MyFlow.RunTime = DateTime.Now; + bl = true; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) + { + MyFlow.RunStep = GengralProcessEnum.Step4; + MyFlow.RunTime = DateTime.Now; + } + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "超时")) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 + MyFlow.RunTime = DateTime.Now; + } + break; + //case GengralProcessEnum.Step8: + // //获取待机位 + // TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 1).FirstOrDefault()); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step9: + // //发送机器人点位 + // Robot.RunRobotPoint(TempPoint); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step10: + // //机器人到位 + // if (Robot.RcvShowInfo.Contains("runpointok")) + // { + // //机械手状态变成有料 + // CurrXizui.State.StatusBackground = ColorStr.Blue; + // InCacheList[0].State.StatusBackground = ColorStr.White; + // MyFlow.RunStep = GengralProcessEnum.End; + // MyFlow.RunTime = DateTime.Now; + // bl = true; + // } + // else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) + // { + // MyFlow.RunStep--; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + } + + return bl; + } + #endregion + + #region 缓存皮带取料运行(GRR) + private FlowModel cacheTakeFlow; + /// + /// 缓存取料流程 + /// + public FlowModel CacheTakeFlow + { + get { return cacheTakeFlow; } + set { cacheTakeFlow = value; this.RaisePropertyChanged("CacheTakeFlow"); } + } + + /// + /// 临时缓存取料对象 + /// + public HandModel CacheHand { get; set; } + + /// + /// 缓存取料运行 + /// + /// + private bool CacheTakeRun(FlowModel MyFlow) + { + bool bl = false; + switch (MyFlow.RunStep) + { + case GengralProcessEnum.Start: + //获取可以取料的吸嘴 + CurrXizui = XizuiLabelPaperList[0]; + if (CurrXizui.State.StatusBackground == ColorStr.White) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else + { + bl = true; + } + break; + case GengralProcessEnum.Step1: + CacheHand = CacheLineList.Where(w => w.State.StatusBackground == ColorStr.Green).FirstOrDefault(); + //获取可以取料的缓存产品 + if (CacheHand != null) + { + //获取取料点 + TempPoint = Coper(CacheHand.PutProPoint1); MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } @@ -1734,67 +2140,8 @@ namespace ViewModel //机器人到位 if (Robot.RcvShowInfo.Contains("runpointok")) { - OutputList[22].Switchs = true; //上光源 - //获取视觉模板 - UPRM = VisualA.VisualEngineeringList[0].VisualEngineeringItemsList[0].MyRectangleModel; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - - } - else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) - { - MyFlow.RunStep--; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step4: - //视觉定位 - VisonCount++; - if (VisualA.SweepCode(UPRM) || CurrentMachine.RunningMode) - { - TempPoint = Coper(CurrLabel.TakePutPoint1); - - //if (!CurrentMachine.RunningMode) - //{ - // //上视觉定位,超过5mm不允许取料 - // if (UPRM.MyROI.ModelFeaturePiont.DeviationX <= 5 && UPRM.MyROI.ModelFeaturePiont.DeviationY <= 5) - // { - // TempPoint.PointX -= (double)UPRM.MyROI.ModelFeaturePiont.DeviationY; - // TempPoint.PointY += (double)UPRM.MyROI.ModelFeaturePiont.DeviationX; - // } - //} - OutputList[22].Switchs = false; //上光源 - - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else - { - if (VisonCount >= 3) - { - CurrLabel.Prouct.StateColour = ColorStr.White; //料盘当前位置置为白色,取下一个产品 - MyFlow.RunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - OutputList[22].Switchs = false; //上光源 - } - } - break; - #endregion - - #region 取料 - case GengralProcessEnum.Step5: - //发送机器人点位 - Robot.RunRobotPoint(TempPoint); - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step6: - //机器人到位 - if (Robot.RcvShowInfo.Contains("runpointok")) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) { @@ -1802,36 +2149,106 @@ namespace ViewModel MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step7: - if (!CurrentMachine.RunningMode) - { - CurrXizui.VacuumSwitch.Switchs = true;//真空吸 - } + case GengralProcessEnum.Step4: + //气缸下降 + CurrXizui.QiGang.Switchs = true; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; - case GengralProcessEnum.Step8: - //真空捡知有 - if (CurrXizui.VacuumCheck.LightUp || CurrentMachine.RunningMode) + case GengralProcessEnum.Step5: + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) { - CurrXizui.State.StatusBackground = ColorStr.Blue; - MyFlow.RunStep = GengralProcessEnum.Start; + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } + MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "超时")) + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangDown.InputMeaning + "异常")) { - MyFlow.RunStep = GengralProcessEnum.Step1; + //气缸下降 + CurrXizui.QiGang.Switchs = true; + } + break; + case GengralProcessEnum.Step6: + //真空检知有 + if (CurrXizui.VacuumCheck.LightUp || CurrentMachine.RunningMode) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) + { + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step7: + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) + { + //二次检查真空 + if (CurrXizui.VacuumCheck.LightUp || CurrentMachine.RunningMode) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) + { + MyFlow.RunStep = GengralProcessEnum.Step4; + MyFlow.RunTime = DateTime.Now; + } + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "超时")) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step8: + //获取待机位 + TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 1).FirstOrDefault()); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step9: + //发送机器人点位 + Robot.RunRobotPoint(TempPoint); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step10: + //机器人到位 + if (Robot.RcvShowInfo.Contains("runpointok")) + { + //机械手状态变成有料 + CurrXizui.State.StatusBackground = ColorStr.Blue; + InCacheList[0].State.StatusBackground = ColorStr.White; + MyFlow.RunStep = GengralProcessEnum.End; + MyFlow.RunTime = DateTime.Now; + bl = true; + } + else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) + { + MyFlow.RunStep--; MyFlow.RunTime = DateTime.Now; } break; - #endregion } return bl; } #endregion - #region 分选不良品 + #region 分选产品 FlowModel AnalysisFlow { get; set; } /// @@ -1846,8 +2263,8 @@ namespace ViewModel { case GengralProcessEnum.Start: //获取需要分拣的吸嘴 - CurrXizui = XizuiLabelPaperList.Where(w => w.State.StatusBackground == ColorStr.Red).FirstOrDefault(); - if (CurrXizui != null) + CurrXizui = XizuiLabelPaperList[1]; + if (CurrXizui.State.StatusBackground == ColorStr.Green || CurrXizui.State.StatusBackground == ColorStr.Red) { MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; @@ -1858,8 +2275,16 @@ namespace ViewModel } break; case GengralProcessEnum.Step1: - //获取自己对应的放不良品点位 - TempPoint = CurrentMachine.RobotPointList.Where(w => w.PointType == 9).FirstOrDefault(); + if (CurrXizui.State.StatusBackground == ColorStr.Green) + { + //获取良品点位 + TempPoint = CurrentMachine.RobotPointList.Where(w => w.PointType == 13).FirstOrDefault(); + } + else + { + //获取不良品点位 + TempPoint = CurrentMachine.RobotPointList.Where(w => w.PointType == 14).FirstOrDefault(); + } MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; @@ -1875,6 +2300,7 @@ namespace ViewModel //机器人到位 if (Robot.RcvShowInfo.Contains("runpointok")) { + CurrXizui.QiGang.Switchs = true; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; @@ -1886,26 +2312,89 @@ namespace ViewModel } break; case GengralProcessEnum.Step4: + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, CurrXizui.QiGangDown.InputMeaning + "异常")) + { + CurrXizui.QiGang.Switchs = true; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step5: CurrXizui.VacuumSwitch.Switchs = false;//真空吸 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; - case GengralProcessEnum.Step5: + case GengralProcessEnum.Step6: //真空捡知有 - if (!CurrXizui.VacuumCheck.LightUp && MyFlow.RunTime.AddMilliseconds(100) < DateTime.Now) + if (!CurrXizui.VacuumCheck.LightUp && MyFlow.RunTime.AddMilliseconds(500) < DateTime.Now) { - CurrXizui.VacuumSwitch.Switchs = false;//真空吸 - CurrXizui.State.StatuInfo = ""; - CurrXizui.State.StatusBackground = ColorStr.White; - - MyFlow.RunStep = GengralProcessEnum.Start; + CurrXizui.QiGang.Switchs = false;//气缸上升 + MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; + } else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "超时")) { MyFlow.RunTime = DateTime.Now; } break; + case GengralProcessEnum.Step7: + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) + { + if (CurrXizui.State.StatusBackground == ColorStr.Green) + { + PutOk = true; + } + else + { + BadLineRun = true; + } + CurrXizui.State = new ShowInfo(); + ClearBox = false; //清料完成 + MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + + //MyFlow.RunStep++; + //MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "异常")) + { + CurrXizui.QiGang.Switchs = false; + MyFlow.RunTime = DateTime.Now; + } + break; + //case GengralProcessEnum.Step8: + // //获取待机位 + // TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 1).FirstOrDefault()); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step9: + // //发送机器人点位 + // Robot.RunRobotPoint(TempPoint); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step10: + // //机器人到位 + // if (Robot.RcvShowInfo.Contains("runpointok")) + // { + // ClearBox = false; //清料完成 + // MyFlow.RunStep = GengralProcessEnum.Start; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) + // { + // MyFlow.RunStep--; + // MyFlow.RunTime = DateTime.Now; + // } + // break; } return bl; @@ -2023,8 +2512,8 @@ namespace ViewModel switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - CurrXizui = XizuiLabelPaperList.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault(); - if (CurrXizui != null) + CurrXizui = XizuiLabelPaperList[0]; + if (CurrXizui.State.StatusBackground == ColorStr.Blue) { MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; @@ -2035,8 +2524,9 @@ namespace ViewModel } break; case GengralProcessEnum.Step1: + //获取下视觉扫码点 //下视觉点位 - TempPoint = Coper(CurrentMachine.RobotPointList.Where(w => w.PointType == 8).FirstOrDefault()); + TempPoint = Coper(CurrentMachine.RobotPointList.Where(w => w.PointType == 10).FirstOrDefault()); //发送机器人点位 Robot.RunRobotPoint(TempPoint); MyFlow.RunStep++; @@ -2046,10 +2536,8 @@ namespace ViewModel //机器人到位 if (Robot.RcvShowInfo.Contains("runpointok")) { - CurrLabel.Prouct.StateColour = ColorStr.Gray;//这里是把最后一个格子的颜色做变更更,避免撞击 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - } else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) { @@ -2058,32 +2546,75 @@ namespace ViewModel } break; case GengralProcessEnum.Step3: - //获取可以放料的载具 - CurrVehicle = MyVehicleBox.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault(); - if (CurrVehicle != null) + //获取下视觉模板 + RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[1].MyRectangleModel; + VisonCount = 0; + OutputList[Y11下光源控制].Switchs = true;//光源 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step4: + VisonCount++; + if (VisualB.SweepCode(RM) || CurrentMachine.RunningMode) { - if (CurrVehicle.Number == 1) - { - RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[0].MyRectangleModel; - } - else - { - RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[1].MyRectangleModel; - } - VisonCount = 0; - OutputList[23].Switchs = true;//光源 + CurrXizui.State.StatuInfo = VisualB.QrCodeStr; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } + else + { + if (VisonCount >= 3) + { + ExcepStop("下视觉扫码失败"); + MyFlow.RunStep--; + MyFlow.RunTime = DateTime.Now; + OutputList[Y11下光源控制].Switchs = false;//光源 + } + } break; - case GengralProcessEnum.Step4: + case GengralProcessEnum.Step5: + //下视觉点位 + TempPoint = Coper(CurrentMachine.RobotPointList.Where(w => w.PointType == 8).FirstOrDefault()); + //发送机器人点位 + Robot.RunRobotPoint(TempPoint); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step6: + //机器人到位 + if (Robot.RcvShowInfo.Contains("runpointok")) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) + { + MyFlow.RunStep--; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step7: + //延时0.3S + if (MyFlow.RunTime.AddMilliseconds(300) > DateTime.Now) + { + break; + } + + //获取下视觉模板 + RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[0].MyRectangleModel; + VisonCount = 0; + OutputList[Y11下光源控制].Switchs = true;//光源 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step8: VisonCount++; if (VisualB.FeatureMatchingIng(RM) || CurrentMachine.RunningMode) { //空跑不二次定位 if (CurrentMachine.RunningMode) { - OutputList[23].Switchs = false;//光源 + OutputList[Y11下光源控制].Switchs = false;//光源 CurrXizui.State.StatusBackground = ColorStr.Green; MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; @@ -2105,6 +2636,19 @@ namespace ViewModel } + //if (Math.Abs(RM.MyROI.ModelFeaturePiont.AngleU) < 10) + //{ + // CurrXizui.OfficeU = (double)RM.MyROI.ModelFeaturePiont.AngleU; + // TempPoint.PointU += (double)RM.MyROI.ModelFeaturePiont.AngleU; + // TempPoint.SpeedGear = 40; + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + //} + //else + //{ + // ExcepStop("下视觉定位偏差过大,请检查!"); + //} + } else { @@ -2113,17 +2657,17 @@ namespace ViewModel ExcepStop("下视觉定位失败"); MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; - OutputList[23].Switchs = false;//光源 + OutputList[Y11下光源控制].Switchs = false;//光源 } } break; - case GengralProcessEnum.Step5: + case GengralProcessEnum.Step9: //发送机器人点位 Robot.RunRobotPoint(TempPoint); MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; - case GengralProcessEnum.Step6: + case GengralProcessEnum.Step10: //机器人到位 if (Robot.RcvShowInfo.Contains("runpointok")) { @@ -2137,7 +2681,13 @@ namespace ViewModel MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step7: + case GengralProcessEnum.Step11: + //延时0.3S + if (MyFlow.RunTime.AddMilliseconds(300) > DateTime.Now) + { + break; + } + VisonCount++; if (VisualB.FeatureMatchingIng(RM) || CurrentMachine.RunningMode) { @@ -2145,13 +2695,13 @@ namespace ViewModel MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; - OutputList[23].Switchs = false;//光源 + OutputList[Y11下光源控制].Switchs = false;//光源 //记录补偿值 if (Math.Abs(RM.MyROI.ModelFeaturePiont.DeviationX) < 10 && Math.Abs(RM.MyROI.ModelFeaturePiont.DeviationY) < 10) { - CurrXizui.OfficeX = -(double)RM.MyROI.ModelFeaturePiont.DeviationY; - CurrXizui.OfficeY = -(double)RM.MyROI.ModelFeaturePiont.DeviationX; + CurrXizui.OfficeX = (double)RM.MyROI.ModelFeaturePiont.DeviationX; + CurrXizui.OfficeY = -(double)RM.MyROI.ModelFeaturePiont.DeviationY; } else { @@ -2165,7 +2715,7 @@ namespace ViewModel ExcepStop("下视觉定位失败"); MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; - OutputList[23].Switchs = false;//光源 + OutputList[Y11下光源控制].Switchs = false;//光源 } } break; @@ -2175,7 +2725,7 @@ namespace ViewModel } #endregion - #region 放料运行 + #region 测试盒放料运行 /// /// 投入料盘流程 /// @@ -2184,7 +2734,7 @@ namespace ViewModel /// /// 当前载具对象 /// - public HandModel CurrVehicle { get; set; } + public HandModel CurrBox { get; set; } /// /// 放料运行 @@ -2197,33 +2747,19 @@ namespace ViewModel switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - //获取可投入的产品对应的吸嘴 - CurrXizui = XizuiLabelPaperList.Where(w => w.State.StatusBackground == ColorStr.Green).FirstOrDefault(); - if (CurrXizui != null) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else - { - bl = true; - } + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step1: - //获取可放料的缓存位 - CurrVehicle = MyVehicleBox.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault(); - if (CurrVehicle != null) - { - //获取放料点 - TempPoint = Coper(CurrVehicle.PutProPoint1); + //获取放料点 + TempPoint = Coper(CurrBox.PutProPoint1); - //下视觉定位补偿 - TempPoint.PointX += CurrXizui.OfficeX; - TempPoint.PointY += CurrXizui.OfficeY; - TempPoint.PointU += CurrXizui.OfficeU; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } + //下视觉定位补偿 + TempPoint.PointX += CurrXizui.OfficeX; + TempPoint.PointY += CurrXizui.OfficeY; + TempPoint.PointU += CurrXizui.OfficeU; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step2: //发送点位 @@ -2239,7 +2775,6 @@ namespace ViewModel { MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - } else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) { @@ -2248,49 +2783,53 @@ namespace ViewModel } break; case GengralProcessEnum.Step4: - CurrXizui.VacuumSwitch.Switchs = false;//真空吸 + CurrXizui.QiGang.Switchs = true; //气缸下降 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step5: - //真空捡知有 - if (!CurrXizui.VacuumCheck.LightUp && MyFlow.RunTime.AddMilliseconds(100) < DateTime.Now) + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) { - CurrXizui.VacuumSwitch.Switchs = false;//真空吸 - CurrXizui.State.StatuInfo = ""; - + CurrXizui.VacuumSwitch.Switchs = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - - //运行到待机点 - TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 1).FirstOrDefault()); - } - else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "超时")) + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangDown.InputMeaning + "异常")) { - MyFlow.RunTime = DateTime.Now; + //气缸下降 + CurrXizui.QiGang.Switchs = true; } break; case GengralProcessEnum.Step6: - //发送点位 - if (Robot.RunRobotPoint(TempPoint)) + //真空检知有 + if (!CurrXizui.VacuumCheck.LightUp) { + CurrXizui.QiGang.Switchs = false; //气缸上升 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "关闭异常")) + { + CurrXizui.VacuumSwitch.Switchs = false; + MyFlow.RunTime = DateTime.Now; + } break; case GengralProcessEnum.Step7: - //机器人到位 - if (Robot.RcvShowInfo.Contains("runpointok")) + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) { - CurrXizui.State.StatusBackground = ColorStr.White; - CurrVehicle.State.StatusBackground = ColorStr.Green; - MyFlow.RunStep = GengralProcessEnum.Start; + //测试盒状态赋值为有料 + CurrBox.State.StatuInfo = CurrXizui.State.StatuInfo; + CurrXizui.State = new ShowInfo(); + CurrBox.State.StatusBackground = ColorStr.Yellow; + MyFlow.RunStep = GengralProcessEnum.End; MyFlow.RunTime = DateTime.Now; + bl = true; } - else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "超时")) { - MyFlow.RunStep--; + CurrXizui.QiGang.Switchs = false; //气缸上升 MyFlow.RunTime = DateTime.Now; } break; @@ -2300,621 +2839,616 @@ namespace ViewModel } #endregion - #region 出料运行 + #region 测试盒取料运行 /// - /// 出料运行流程 + /// 测试盒取出流程 /// - public FlowModel UpLineRunFlow { get; set; } + FlowModel BoxOutPutFlow { get; set; } /// - /// 上流线运行 + /// 测试盒取出运行 /// /// - public void UpLineRun(FlowModel MyFlow) + /// + private bool BoxOutPutRun(FlowModel MyFlow) { + bool bl = false; switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - OutputList[7].Switchs = false; //流线阻挡 - OutputList[24].Switchs = false; //流线顶升 - OutputList[17].Switchs = false; //上流线皮带 + //获取测试盒取料位 + TempPoint = Coper(CurrBox.TakeProPoint1); MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step1: - //流线阻挡上位 - if (InputList[29].LightUp) + //先运行点位,打开测试盒,再检查到位 + if (Robot.RunRobotPoint(TempPoint)) { - //流线顶升下位 - if (InputList[28].LightUp) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[28].InputMeaning + "异常")) - { - OutputList[24].Switchs = false; //流线顶升 - MyFlow.RunTime = DateTime.Now; - } - } - else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[29].InputMeaning + "异常")) - { - OutputList[7].Switchs = false; //流线阻挡 + MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - OutputList[17].Switchs = false; //上流线皮带 break; case GengralProcessEnum.Step2: - if (MyFlow.RunTime.AddMilliseconds(1000) <= DateTime.Now) - { - //检查流线载具状态 - if (InputList[34].LightUp) - { - if (MyVehicleBox.Where(w => w.State.StatusBackground == ColorStr.Green).Count() >= 2) - { - //等待出料 - CurrNextStr = ""; - MyFlow.RunStep = GengralProcessEnum.Step10; - MyFlow.RunTime = DateTime.Now; - } - else - { - //等待放料 - MyFlow.RunStep = GengralProcessEnum.Step20; - MyFlow.RunTime = DateTime.Now; - } - } - else - { - //进料 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - } - OutputList[17].Switchs = false; //上流线皮带 + //打开测试盒 + //顶升气缸原位 + CurrBox.YDingShengQiGangDW.Switchs = false; + CurrBox.YDingShengQiGangYW.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; break; - - #region 流线进料 case GengralProcessEnum.Step3: - //进料检知有 - if (InputList[33].LightUp) + //顶升气缸原位 + if (CurrBox.XDingShengQigangYW.LightUp || CurrentMachine.RunningMode) { - OutputList[17].Switchs = true; //上流线转动 + //伸缩气缸原位 + CurrBox.YShenSuoQiGangDW.Switchs = false; + CurrBox.YShenSuoQiGangYW.Switchs = true; + + //顶升置位 + CurrBox.YDingShengQiGangDW.Switchs = false; + CurrBox.YDingShengQiGangYW.Switchs = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } + else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + { + ExcepStop(CurrBox.XDingShengQigangYW.InputMeaning + "异常"); + CurrBox.YDingShengQiGangDW.Switchs = false; + CurrBox.YDingShengQiGangYW.Switchs = true; + MyFlow.RunTime = DateTime.Now; + } break; case GengralProcessEnum.Step4: - //到位检知有 - if (InputList[34].LightUp) + //伸缩气缸原位 + if (CurrBox.XShenSuoQigangYW.LightUp || CurrentMachine.RunningMode) { + //伸缩置位 + CurrBox.YShenSuoQiGangDW.Switchs = false; + CurrBox.YShenSuoQiGangYW.Switchs = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (TimeOutValidation(MyFlow.RunTime, 10000, "上流线载具到位异常")) + else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) { - OutputList[17].Switchs = true; //上流线转动 + ExcepStop(CurrBox.XShenSuoQigangYW.InputMeaning + "异常"); + //伸缩气缸原位 + CurrBox.YShenSuoQiGangDW.Switchs = false; + CurrBox.YShenSuoQiGangYW.Switchs = true; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step5: - //延时0.5s皮带停转 - if (MyFlow.RunTime.AddMilliseconds(500) <= DateTime.Now) - { - OutputList[17].Switchs = false; //上皮带停转 - MyFlow.RunStep = GengralProcessEnum.Step2; - MyFlow.RunTime = DateTime.Now; - } - break; - #endregion - - #region 等待出料 - case GengralProcessEnum.Step10: - //等待后站要料 - if (CurrNextStr == JiaohuModel.VehicleRequest) - { - OutputList[7].Switchs = true; //流线阻挡 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step11: - //流线阻挡下降到位 - if (InputList[30].LightUp) - { - OutputList[17].Switchs = true; //流线皮带 - CurrNextStr = ""; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (MyFlow.RunTime.AddMilliseconds(3000) <= DateTime.Now) - { - ExcepStop(InputList[30].InputMeaning + "异常"); - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step12: - //后站返回撤销要料 - if (CurrNextStr == JiaohuModel.VehicleRevoke) + //机器人到位 + if (Robot.RcvShowInfo.Contains("runpointok")) { MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (TimeOutValidation(MyFlow.RunTime, 10000, "出料超时异常")) + else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) { + Robot.RunRobotPoint(TempPoint); MyFlow.RunTime = DateTime.Now; } - OutputList[17].Switchs = true; //流线皮带 break; - case GengralProcessEnum.Step13: - OutputList[17].Switchs = false; //流线皮带 - MyFlow.RunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - break; - #endregion - - #region 等待放料 - case GengralProcessEnum.Step20: - //顶升上升 - OutputList[24].Switchs = true; //流线顶升 + case GengralProcessEnum.Step6: + CurrXizui.QiGang.Switchs = true; //气缸下降 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - OutputList[17].Switchs = false; //流线皮带 break; - case GengralProcessEnum.Step21: - //流线顶升到位 - if (InputList[27].LightUp) + case GengralProcessEnum.Step7: + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) { - //改变状态等待放料 - MyVehicleBox.ForEach(w => w.State.StatusBackground = ColorStr.Blue); + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (MyFlow.RunTime.AddMilliseconds(3000) <= DateTime.Now) + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangDown.InputMeaning + "异常")) { - ExcepStop(InputList[27].InputMeaning + "异常"); - MyFlow.RunTime = DateTime.Now; + //气缸下降 + CurrXizui.QiGang.Switchs = true; } break; - case GengralProcessEnum.Step22: - //等待放料完成 - if (MyVehicleBox.Where(w => w.State.StatusBackground == ColorStr.Green).Count() >= 2) + case GengralProcessEnum.Step8: + //真空检知有,无料不检查真空 + if (CurrXizui.VacuumCheck.LightUp || CurrBox.State.StatusBackground == ColorStr.White || CurrentMachine.RunningMode) { - //顶升下降 - OutputList[24].Switchs = false; //流线顶升 + CurrXizui.QiGang.Switchs = false; //气缸上升 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - //else if (CurrentMachine.RunningMode) - //{ - // MyVehicleBox.ForEach(w => w.State.StatusBackground = ColorStr.Green); - //} - break; - case GengralProcessEnum.Step23: - //顶升下降到位 - if (InputList[28].LightUp) + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) { - MyFlow.RunStep = GengralProcessEnum.Step2; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[28].InputMeaning + "异常")) - { - OutputList[24].Switchs = false; //流线顶升 + //真空吸 + if (!CurrentMachine.RunningMode) + { + CurrXizui.VacuumSwitch.Switchs = true; + } + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step9: + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) + { + //二次检查真空 + if (CurrXizui.VacuumCheck.LightUp || CurrBox.State.StatusBackground == ColorStr.White || CurrentMachine.RunningMode) + { + //测试盒状态赋值给吸嘴后清空测试盒状态 + if (CurrBox.State.StatusBackground == ColorStr.Green) + { + CurrXizui.State.StatusBackground = ColorStr.Green; + } + else + { + CurrXizui.State.StatusBackground = ColorStr.Red; + } + //if (CurrBox.State.StatusBackground != ColorStr.Blue) + //{ + // CurrBox.State = new ShowInfo(); + + //} + CurrBox.State = new ShowInfo(); + + if (!ClearBox) //清料 + { + CurrBox.State.StatusBackground = ColorStr.Blue; + } + + MyFlow.RunStep = GengralProcessEnum.End; + MyFlow.RunTime = DateTime.Now; + bl = true; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "异常")) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 + MyFlow.RunStep = GengralProcessEnum.Step6; + MyFlow.RunTime = DateTime.Now; + } + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "超时")) + { + CurrXizui.QiGang.Switchs = false; //气缸上升 MyFlow.RunTime = DateTime.Now; } break; - #endregion } + + return bl; } #endregion - #region 载具升降运行 - /// 载具升降运行步骤 + #region 搬运出料 + /// + /// 搬运出料流程 /// - FlowModel VehicleLiftRunFlow { get; set; } + FlowModel CarryPutOutFlow { get; set; } /// - /// 载具升降临时点位 + /// 搬运出料平台临时对象 /// - MotionPointModel VehicleLiftTempPoint { get; set; } + HandModel CarryPutOutHand { get; set; } /// - /// 载具升降运行 + /// 搬运出料临时点位 /// - private void VehicleLiftRun(FlowModel MyFlow) + MotionPointModel CarryPutOutMotionPoint { get; set; } + + /// + /// 搬运轴安全信号 + /// + bool CarryAxisSafe { get; set; } + + /// + /// 机械手安全信号 + /// + bool RobotSafe { get; set; } + + /// + /// 搬运出料运行 + /// + /// + private void CarryPutOutRun(FlowModel MyFlow) { switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - HLLiftPlatLine = 1; //升降皮带正转 + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = false; + //搬运气缸上位 + OutputList[Y201搬运气缸下位].Switchs = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step1: - //皮带转1.5秒,防止载具没有到位 - if (MyFlow.RunTime.AddMilliseconds(1500) <= DateTime.Now) + FrontStationSend.Safe = false; //本站安全状态 + //搬运气缸上位到位 + if (InputList[X200搬运气缸上位].LightUp) { - HLLiftPlatLine = 0; //升降皮带停 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X200搬运气缸上位].InputMeaning + "异常")) + { + OutputList[Y201搬运气缸下位].Switchs = false; + MyFlow.RunTime = DateTime.Now; + } break; case GengralProcessEnum.Step2: - //检查升降平台是否有载具,有载具向工作位送料,无载具等待回流 - if (InputList[39].LightUp && InputList[40].LightUp) - { - //等待送料 - MyFlow.RunStep = GengralProcessEnum.Step10; - MyFlow.RunTime = DateTime.Now; - } - else - { - //载具回流 - MyFlow.RunStep = GengralProcessEnum.Step20; - MyFlow.RunTime = DateTime.Now; - } - HLLiftPlatLine = 0; //升降皮带停 - break; - - #region 向工作区送料 - case GengralProcessEnum.Step10: - //获取升降上位 - VehicleLiftTempPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 21).FirstOrDefault()); - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = false; + //先运行到搬运待机点 + CarryPutOutMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 1).FirstOrDefault()); MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; - HLLiftPlatLine = 0; //升降皮带停 + break; + case GengralProcessEnum.Step3: + FrontStationSend.Safe = false; //本站安全状态 + //运行到待机点 + if (CarryPutOutMotionPoint.PointRun(MCVM.AllShaftList)) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, CarryPutOutMotionPoint.PointName + "运行超时")) + { + CarryPutOutMotionPoint.PointRunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step4: + FrontStationSend.Safe = true; //本站安全状态 + CarryAxisSafe = true; + //查看前站物料状态&安全状态 + if (FrontStationReceive.ProductState == ColorStr.Green && FrontStationReceive.Safe) + { + //获取前站取料点 + CarryPutOutMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 2).FirstOrDefault()); + FrontStationSend.Safe = false; //本站安全状态 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step5: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //运行到平台下料点 + if (CarryPutOutMotionPoint.PointRun(MCVM.AllShaftList)) + { + //气缸下降 + OutputList[Y201搬运气缸下位].Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, CarryPutOutMotionPoint.PointName + "运行超时")) + { + CarryPutOutMotionPoint.PointRunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step6: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //气缸下降到位 + if (InputList[X201搬运气缸下位].LightUp) + { + if (!CurrentMachine.RunningMode) + { + OutputList[Y202搬运真空吸].Switchs = true;//真空吸开 + } + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X201搬运气缸下位].InputMeaning + "异常")) + { + //气缸下降 + OutputList[Y201搬运气缸下位].Switchs = true; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step7: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //真空检知有 + if (InputList[X202搬运真空检知].LightUp || CurrentMachine.RunningMode) + { + OutputList[Y201搬运气缸下位].Switchs = false; //气缸上升 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X202搬运真空检知].InputMeaning + "异常")) + { + OutputList[Y202搬运真空吸].Switchs = true;//真空吸开 + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step8: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //搬运气缸上位到位 + if (InputList[X200搬运气缸上位].LightUp) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X200搬运气缸上位].InputMeaning + "异常")) + { + OutputList[Y201搬运气缸下位].Switchs = false; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step9: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //再次检查真空 + if (InputList[X202搬运真空检知].LightUp || CurrentMachine.RunningMode) + { + FrontStationSend.GetDone = true; //给前站传输取料完成 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X202搬运真空检知].InputMeaning + "异常")) + { + MyFlow.RunStep = GengralProcessEnum.Step5; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step10: + FrontStationSend.Safe = false; //本站安全状态 + CarryAxisSafe = true; + //等待前站产品变颜色 + if (FrontStationReceive.ProductState == ColorStr.White) + { + FrontStationSend.GetDone = false; //撤销取料完成信号 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.RunTime.AddMilliseconds(10000) <= DateTime.Now) + { + ExcepStop("前站回复信号超时"); + MyFlow.RunTime = DateTime.Now; + } break; case GengralProcessEnum.Step11: - //运行到升降上位 - if (VehicleLiftTempPoint.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, VehicleLiftTempPoint.PointName + "运行超时")) - { - MyFlow.RunTime = DateTime.Now; - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; - } - HLLiftPlatLine = 0; //升降皮带停 + FrontStationSend.Safe = false; //本站安全状态 + //先回待机点等待,避让前站机械手 + CarryPutOutMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 1).FirstOrDefault()); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step12: - //检查工作位是否无料,向工作位送料 - if (!InputList[33].LightUp && !InputList[34].LightUp) + FrontStationSend.Safe = false; //本站安全状态 + //运行到待机点 + if (CarryPutOutMotionPoint.PointRun(MCVM.AllShaftList)) { - HLLiftPlatLine = 2; //升降皮带反转 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } + else if (TimeOutValidation(MyFlow.RunTime, 10000, CarryPutOutMotionPoint.PointName + "运行超时")) + { + CarryPutOutMotionPoint.PointRunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } break; case GengralProcessEnum.Step13: - //载具到工作位,皮带停转 - if (InputList[34].LightUp) + CarryAxisSafe = true; + FrontStationSend.Safe = true; //本站安全状态 + //判断本站是否可以放料&&机械手安全状态 + if (InCacheList[0].State.StatusBackground == ColorStr.White && RobotSafe) { + //获取本站放料点 + CarryPutOutMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 3).FirstOrDefault()); + CarryAxisSafe = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else - { - HLLiftPlatLine = 2; //升降皮带反转 - } break; case GengralProcessEnum.Step14: - //等待0.5秒 - if (MyFlow.RunTime.AddMilliseconds(500) <= DateTime.Now) - { - MyFlow.RunStep = GengralProcessEnum.Step2; - MyFlow.RunTime = DateTime.Now; - } - HLLiftPlatLine = 0; //升降皮带停 - break; - #endregion - - #region 载具回流 - case GengralProcessEnum.Step20: - //获取升降下位 - VehicleLiftTempPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 22).FirstOrDefault()); - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step21: - //运行到升降下位 - if (VehicleLiftTempPoint.PointRun(MCVM.AllShaftList)) + FrontStationSend.Safe = true; //本站安全状态 + CarryAxisSafe = false; + //运行到后站放料点 + if (CarryPutOutMotionPoint.PointRun(MCVM.AllShaftList)) { + //气缸下降 + OutputList[Y201搬运气缸下位].Switchs = true; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (TimeOutValidation(MyFlow.RunTime, 10000, VehicleLiftTempPoint.PointName + "点位超时")) + else if (TimeOutValidation(MyFlow.RunTime, 10000, CarryPutOutMotionPoint.PointName + "运行超时")) { - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; + CarryPutOutMotionPoint.PointRunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step22: - //回流有载具等待出料,阻挡下位,进料 - if (InputList[37].LightUp) + case GengralProcessEnum.Step15: + FrontStationSend.Safe = true; //本站安全状态 + CarryAxisSafe = false; + //气缸下降到位 + if (InputList[X201搬运气缸下位].LightUp) { - OutputList[8].Switchs = true; + OutputList[Y202搬运真空吸].Switchs = false; //真空吸关 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - break; - case GengralProcessEnum.Step23: - //回流阻挡气缸下位 - if (InputList[32].LightUp) + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X201搬运气缸下位].InputMeaning + "异常")) { - HLLiftPlatLine = 1; //升降皮带正转 - OutputList[18].Switchs = true; //回流皮带运行 + //气缸下降 + OutputList[Y201搬运气缸下位].Switchs = true; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step16: + FrontStationSend.Safe = true; //本站安全状态 + CarryAxisSafe = false; + //延时0.2秒 真空破作用时间 + if (!InputList[X202搬运真空检知].LightUp) + { + OutputList[Y201搬运气缸下位].Switchs = false; //气缸上升 MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[32].InputMeaning + "异常")) + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X202搬运真空检知].InputMeaning + "关闭异常")) { - OutputList[8].Switchs = true; //回流阻挡气缸上位 + MyFlow.RunStep--; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step24: - //载具到位 - if (InputList[39].LightUp && InputList[40].LightUp) + case GengralProcessEnum.Step17: + FrontStationSend.Safe = true; //本站安全状态 + CarryAxisSafe = false; + //搬运气缸上位到位 + if (InputList[X200搬运气缸上位].LightUp) { - HLLiftPlatLine = 0; //升降皮带正转 - OutputList[18].Switchs = false; //回流皮带运行 - MyFlow.RunStep++; + InCacheList[0].State.StatusBackground = ColorStr.Green; + MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; } - else + else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[X200搬运气缸上位].InputMeaning + "异常")) { - HLLiftPlatLine = 1; //升降皮带正转 - OutputList[18].Switchs = true; //回流皮带运行 - } - break; - case GengralProcessEnum.Step25: - //延时0.5秒 - if (MyFlow.RunTime.AddMilliseconds(500) <= DateTime.Now) - { - OutputList[8].Switchs = false; //回流阻挡气缸上位 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - HLLiftPlatLine = 0; //升降皮带正转 - OutputList[18].Switchs = false; //回流皮带运行 - break; - case GengralProcessEnum.Step26: - //回流阻挡气缸上位 - if (InputList[31].LightUp) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[31].InputMeaning + "异常")) - { - OutputList[8].Switchs = false; //回流阻挡气缸上位 + OutputList[Y201搬运气缸下位].Switchs = false; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step27: - //上升前检查载具状态,防止撞机,升降上有,回流无,回流阻挡上位 - if (!InputList[37].LightUp && InputList[31].LightUp && InputList[39].LightUp && InputList[40].LightUp) - { - //获取升降上位 - VehicleLiftTempPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 21).FirstOrDefault()); - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, "载具回流异常,请检查")) - { - MyFlow.RunTime = DateTime.Now; - } - HLLiftPlatLine = 0; //升降皮带正转 - break; - case GengralProcessEnum.Step28: - //运行到升降上位 - if (VehicleLiftTempPoint.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep = GengralProcessEnum.Step2; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 10000, VehicleLiftTempPoint.PointName + "点位超时")) - { - VehicleLiftTempPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - HLLiftPlatLine = 0; //升降皮带正转 - break; - #endregion } } #endregion - #region 回流运行 + #region 出料运行 /// - /// 回流步骤 + /// 出料流程 /// - FlowModel HuiLiuFlow { get; set; } + FlowModel ProLineFlow { get; set; } /// - /// 平台回流进料允许 + /// 流线空闲信号 /// - public bool HuiLiuFeedOk { get; set; } - - private int hLLiftPlatLine; - /// - /// 回流升降皮带控制 - /// - public int HLLiftPlatLine - { - get { return hLLiftPlatLine; } - set - { - hLLiftPlatLine = value; - switch (value) - { - case 0://不转 - //皮带 - OutputList[19].Switchs = false; //正转 - outputList[20].Switchs = false; //反转 - break; - case 1: //正转 - //皮带 - OutputList[19].Switchs = false; //正转 - outputList[20].Switchs = true; //反转 - break; - case 2: //反转 - //皮带 - OutputList[19].Switchs = true; //正转 - outputList[20].Switchs = false; //反转 - break; - - } - } - } + public bool PutOk { get; set; } /// - /// 回流运行 + /// 良品运行 /// - private void HuiLiuRun(FlowModel MyFlow) + private void ProLineRun(FlowModel MyFlow) { switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - OutputList[8].Switchs = false; //回流阻挡气缸上位 - OutputList[18].Switchs = false; //流线皮带 + OutputList[Y100流线皮带1].Switchs = false; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step1: - //回流阻挡气缸上位 - if (InputList[31].LightUp) - { - OutputList[18].Switchs = true; //流线皮带 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 3000, InputList[31].InputMeaning + "异常")) - { - OutputList[8].Switchs = false; //回流阻挡气缸上位 - MyFlow.RunTime = DateTime.Now; - } + ////皮带检知是否有料 + //if (InputList[X101流线皮带1检知2].LightUp && PutOk) + //{ + // //出料 + // MyFlow.RunStep = GengralProcessEnum.Step10; + // MyFlow.RunTime = DateTime.Now; + //} + //else if (InputList[X101流线皮带1检知2].LightUp && !PutOk) + //{ + // ExcepStop("请取走出料口产品"); + //} + //else + //{ + // //上料 + // PutOk = false; + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + //} + //上料 + PutOk = false; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; break; case GengralProcessEnum.Step2: - if (MyFlow.RunTime.AddMilliseconds(2000) <= DateTime.Now) + //放料完成 + if (PutOk) { - //检查回流皮带是否有载具,有载具等待出料,无载具向后站求料 - if (InputList[36].LightUp || InputList[37].LightUp) - { - //出料 - MyFlow.RunStep = GengralProcessEnum.Step10; - MyFlow.RunTime = DateTime.Now; - } - else - { - //进料 - BehindSendInfo = ""; - MyFlow.RunStep = GengralProcessEnum.Step20; - MyFlow.RunTime = DateTime.Now; - } - OutputList[18].Switchs = false; //回流皮带 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; } - else - { - OutputList[18].Switchs = true; //回流皮带 - } - + OutputList[Y100流线皮带1].Switchs = false; break; - #region 回流出料 - case GengralProcessEnum.Step10: - if (InputList[36].LightUp && InputList[37].LightUp) + case GengralProcessEnum.Step3: + //后站无料 + if (NextStationReceive.ProductState == ColorStr.White && MyFlow.RunTime.AddMilliseconds(500) <= DateTime.Now) { - ExcepStop("回流载具异常"); - } - else - //载具运行到升降皮带上,阻挡上升 - if (InputList[37].LightUp) - { - OutputList[18].Switchs = false; //回流皮带停 + NextStationSend.Request = true; //送料信号 + OutputList[Y100流线皮带1].Switchs = true; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step11: - //回流阻挡气缸上位 - if (!OutputList[8].Switchs && InputList[31].LightUp) + //case GengralProcessEnum.Step11: + // //产品流出 + // if (!InputList[X101流线皮带1检知2].LightUp) + // { + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (MyFlow.RunTime.AddSeconds(10) <= DateTime.Now) + // { + // ExcepStop("产品流出超时"); + // } + // else + // { + // NextStationSend.Request = true; + // OutputList[Y100流线皮带1].Switchs = true; + // } + // break; + case GengralProcessEnum.Step4: + //产品流到后站,后站撤销请求 + if (NextStationReceive.ProductState != ColorStr.White) { + NextStationSend.Request = false; + OutputList[Y100流线皮带1].Switchs = false; MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; - OutputList[18].Switchs = false; //回流皮带停 } - else if (TimeOutValidation(MyFlow.RunTime, 8000, InputList[31].InputMeaning + "异常")) + //后站10秒未恢复,报警 + else if (MyFlow.RunTime.AddSeconds(10) <= DateTime.Now) { - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step12: - MyFlow.RunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - OutputList[18].Switchs = false; //回流皮带停 - break; - #endregion - - #region 回流进料 - case GengralProcessEnum.Step20: - //回流流入检知有 - if (InputList[36].LightUp) - { - OutputList[18].Switchs = true; //回流皮带转 - MyFlow.RunStep++; + ExcepNoStop("产品流出超时"); MyFlow.RunTime = DateTime.Now; } else { - //向后站请求回流载具 - BehindSendInfo = JiaohuModel.BackflowRequest; + NextStationSend.Request = true; + OutputList[Y100流线皮带1].Switchs = true; } break; - case GengralProcessEnum.Step21: - //回流到位检知有 - if (InputList[37].LightUp) - { - OutputList[18].Switchs = false; //回流皮带停 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else - { - OutputList[18].Switchs = true; //回流皮带转 - } - break; - case GengralProcessEnum.Step22: - MyFlow.RunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - //回流皮带 - OutputList[18].Switchs = false; - break; - #endregion } } #endregion - #region 检查产品掉落 + #region 检查吸嘴真空 /// /// 检查产品掉落 /// public void CheckXizui() { - if (!CurrentMachine.RunningMode) + if (RunStatu == RunStatuEnum.Normal) { if (XizuiLabelPaperList != null) { foreach (var item in XizuiLabelPaperList) { - if (item.State.StatusBackground != ColorStr.White && !item.VacuumCheck.LightUp) + //运行中,产品掉落,报警提示 + if (item.State.StatusBackground != ColorStr.White && item.State.StatusBackground != ColorStr.Red && item.VacuumSwitch.Switchs && !item.VacuumCheck.LightUp) { - ExcepStop("吸嘴" + item.Number + "产品掉落,请找回产品重置流程,继续生产"); + if (item.CheckVacuumTime.AddMilliseconds(1000) <= DateTime.Now) + { + ExcepStop("吸嘴" + item.Number + "产品掉落,请检查"); + } + } + else + { + item.CheckVacuumTime = DateTime.Now; } } } @@ -2922,482 +3456,479 @@ namespace ViewModel } #endregion - #region 料盘上料运行 + #region 测试平台运行 + private FlowModel testBoxFlow; /// - /// 上料起点 + /// 测试平台运行 /// - MotionPointModel FeedingStart { get; set; } - /// - /// 上料终点 - /// - MotionPointModel FeedingEnd { get; set; } - /// - /// 上料流程 - /// - FlowModel TrayFeedFlow { get; set; } - /// - /// 投料就绪 - /// - bool TouliaoReady { get; set; } - /// - /// 上料就绪 - /// - bool TrayFeedReady { get; set; } - - /// - /// 可以取空盘 - /// - bool TakeKongTray { get; set; } - /// - /// 料盘上料运行 - /// - private void TrayFeedRun(FlowModel MyFlow) + public FlowModel TestBoxFlow { - //投料区有盘 - if (InputList[11].LightUp && InputList[12].LightUp) - { - //投料完成按钮 - if (InputList[9].LightUp) - { - TouliaoReady = true; - } - } - else - { - TouliaoReady = false; - } + get { return testBoxFlow; } + set { testBoxFlow = value; this.RaisePropertyChanged("TestBoxFlow"); } + } + private HandModel currTestBox; + /// + /// 临时测试盒对象 + /// + public HandModel CurrTestBox + { + get { return currTestBox; } + set { currTestBox = value; this.RaisePropertyChanged("CurrTestBox"); } + } + + /// + /// 测试中信号 + /// + public bool Testing { get; set; } + + /// + /// 测试结果字符串 + /// + public string TestResultStr { get; set; } + + /// + /// 测试平台运行 + /// + /// + private void TestBoxRun(FlowModel MyFlow) + { switch (MyFlow.RunStep) { case GengralProcessEnum.Start: - FeedingStart = CurrentMachine.MotionPointList.Where(w => w.PointType == 1).FirstOrDefault(); - FeedingEnd = CurrentMachine.MotionPointList.Where(w => w.PointType == 2).FirstOrDefault(); - FeedingStart.PointRunStep = GengralProcessEnum.Start; - FeedingEnd.PointRunStep = GengralProcessEnum.Start; - OutputList[13].Switchs = false;//上料缓存皮带 - OutputList[14].Switchs = false;//上料皮带 - OutputList[4].Switchs = false; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step1: - //上料区必须无盘 - if (!InputList[13].LightUp && !InputList[14].LightUp) + if (CurrentMachine.RunningMode || TestMachine.Showmsg.StatusBackground == ColorStr.Green) { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (InputList[13].LightUp || InputList[14].LightUp) - { - OutputList[13].Switchs = true;//上料缓存皮带 - OutputList[14].Switchs = true;//上料皮带 - MyFlow.RunStep = GengralProcessEnum.Step5; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step2: - //移动到起始位置 - if (FeedingStart.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 100000, FeedingStart.PointName + "移动超时")) - { - FeedingStart.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step3: - //投料区捡知 - if (InputList[11].LightUp && InputList[12].LightUp && TouliaoReady) - { - OutputList[4].Switchs = true; //阻挡下降 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (MyFlow.RunTime.AddSeconds(10) < DateTime.Now) - { - if (!CurrentMachine.RunningMode) + //放满两个产品,开始测试 + if (TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.Yellow).Count() >= 2) { - ExcepNoStop("没料啦,请投料!"); + MyFlow.RunStep = GengralProcessEnum.Step10; + MyFlow.RunTime = DateTime.Now; + } + else + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; } - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step4: - //阻挡下位 - if (InputList[26].LightUp) - { - OutputList[13].Switchs = true;//上料缓存皮带 - OutputList[14].Switchs = true;//上料皮带 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, "上料仓阻挡下降异常")) - { - OutputList[4].Switchs = true; //阻挡下降 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step5: - //上料区检知 - if (InputList[14].LightUp) - { - OutputList[4].Switchs = false; //阻挡上升 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; } else { - OutputList[13].Switchs = true;//上料缓存皮带 - OutputList[14].Switchs = true;//上料皮带 + ExcepStop("测试机未连接"); } break; - case GengralProcessEnum.Step6: - //再转两秒 - if (MyFlow.RunTime.AddMilliseconds(2000) <= DateTime.Now) + case GengralProcessEnum.Step1: + //获取可以放料的测试盒 + CurrTestBox = TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault(); + //CurrTestBox = TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.White && w.Number == 1).FirstOrDefault(); + if (CurrTestBox != null && (CurrentMachine.RunningMode || TestRecStr.Contains("QUERY?"))) { - OutputList[13].Switchs = false;//上料缓存皮带 - OutputList[14].Switchs = false;//上料皮带 - MyFlow.RunStep = GengralProcessEnum.Step10; + CurrTestBox.State.StatusBackground = ColorStr.Blue; + MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step10: - //上料区检知 - if (InputList[14].LightUp) + + #region 测试盒气缸打开流程,已改为机械手流程控制 + //case GengralProcessEnum.Step2: + // //顶升气缸原位 + // CurrTestBox.YDingShengQiGangDW.Switchs = false; + // CurrTestBox.YDingShengQiGangYW.Switchs = true; + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step3: + // //顶升气缸原位 + // if (CurrTestBox.XDingShengQigangYW.LightUp) + // { + // //伸缩气缸原位 + // CurrTestBox.YShenSuoQiGangDW.Switchs = false; + // CurrTestBox.YShenSuoQiGangYW.Switchs = true; + + // //顶升置位 + // CurrTestBox.YDingShengQiGangDW.Switchs = false; + // CurrTestBox.YDingShengQiGangYW.Switchs = false; + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + // { + // ExcepStop(CurrTestBox.XDingShengQigangYW.InputMeaning + "异常"); + // CurrTestBox.YDingShengQiGangDW.Switchs = false; + // CurrTestBox.YDingShengQiGangYW.Switchs = true; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + //case GengralProcessEnum.Step4: + // //伸缩气缸原位 + // if (CurrTestBox.XShenSuoQigangYW.LightUp) + // { + // //伸缩置位 + // CurrTestBox.YShenSuoQiGangDW.Switchs = false; + // CurrTestBox.YShenSuoQiGangYW.Switchs = false; + // CurrTestBox.State.StatusBackground = ColorStr.Blue; //允许投料状态 + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + // { + // ExcepStop(CurrTestBox.XShenSuoQigangYW.InputMeaning + "异常"); + // //伸缩气缸原位 + // CurrTestBox.YShenSuoQiGangDW.Switchs = false; + // CurrTestBox.YShenSuoQiGangYW.Switchs = true; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + #endregion + + case GengralProcessEnum.Step2: + //已投料 + if (CurrTestBox.State.StatusBackground == ColorStr.Yellow) { - //向结束位移动 - if (FeedingEnd.PointRun(MCVM.AllShaftList)) + if (!CurrentMachine.RunningMode) + { + //伸缩气缸到位 + CurrTestBox.YShenSuoQiGangDW.Switchs = true; + CurrTestBox.YShenSuoQiGangYW.Switchs = false; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else //空跑模式 { MyFlow.RunStep = GengralProcessEnum.Start; MyFlow.RunTime = DateTime.Now; } - else if (InputList[19].LightUp || InputList[20].LightUp) //料盘对射感应到,轴停止 - { - FeedingEnd.PointStop();//停止轴移动 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - FeedingStart.PointRunStep = GengralProcessEnum.Start; - FeedingEnd.PointRunStep = GengralProcessEnum.Start; - } } - else + break; + case GengralProcessEnum.Step3: + //伸缩气缸到位 + if (CurrTestBox.XShenSuoQigangDW.LightUp) { - MyFlow.RunStep = GengralProcessEnum.Start; + //伸缩置位 + CurrTestBox.YShenSuoQiGangDW.Switchs = false; + CurrTestBox.YShenSuoQiGangYW.Switchs = false; + + //顶升到位 + CurrTestBox.YDingShengQiGangDW.Switchs = true; + CurrTestBox.YDingShengQiGangYW.Switchs = false; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + { + ExcepStop(CurrTestBox.XShenSuoQigangDW.InputMeaning + "异常"); + //伸缩气缸到位 + CurrTestBox.YShenSuoQiGangDW.Switchs = true; + CurrTestBox.YShenSuoQiGangYW.Switchs = false; MyFlow.RunTime = DateTime.Now; } break; - case GengralProcessEnum.Step11: - //上料料盘对射检知 - if (InputList[19].LightUp || InputList[20].LightUp) + case GengralProcessEnum.Step4: + //顶升气缸到位 + if (CurrTestBox.XDingShengQigangDW.LightUp) { - //盘中无料时 - if (Tray1.MyLabelList.Where(w => w.Prouct.StateColour == ColorStr.Green).Count() <= 0) - { - Tray1.MyLabelList.ForEach(w => w.Prouct.StateColour = ColorStr.Green); - } - TrayFeedReady = true; + CurrTestBox.State.StatusBackground = ColorStr.Yellow; //气缸到位,准备测试 + MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + { + ExcepStop(CurrTestBox.XDingShengQigangDW.InputMeaning + "异常"); + //顶升到位 + CurrTestBox.YDingShengQiGangDW.Switchs = true; + CurrTestBox.YDingShengQiGangYW.Switchs = false; + MyFlow.RunTime = DateTime.Now; + } + break; + + case GengralProcessEnum.Step10: + if (!CurrentMachine.RunningMode) + { + //发送机械手准备就绪 + TestMachine.SendInfo("READY"); MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; } else + { + TestBenchBox.ForEach(w => w.State.StatusBackground = ColorStr.Green); + MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + + break; + case GengralProcessEnum.Step11: + //接受测试机就绪信号 + if (TestRecStr.Contains("LOAD")) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.RunTime.AddMilliseconds(1000) <= DateTime.Now) { MyFlow.RunStep--; MyFlow.RunTime = DateTime.Now; } break; case GengralProcessEnum.Step12: - //盘中无料时,激活取空盘信号,取走空盘后给料盘置为白色,继续上料 - if (Tray1.MyLabelList.Where(w => w.Prouct.StateColour == ColorStr.Gray).Count() >= Tray1.MyLabelList.Count()) + if (TestBenchBox[0].XDingShengQigangDW.LightUp && TestBenchBox[0].XShenSuoQigangDW.LightUp && TestBenchBox[1].XDingShengQigangDW.LightUp && TestBenchBox[1].XShenSuoQigangDW.LightUp) { - TakeKongTray = true; - } - //盘中无料时并空料盘已被取走 - else if (Tray1.MyLabelList.Where(w => w.Prouct.StateColour == ColorStr.White).Count() >= Tray1.MyLabelList.Count() && !InputList[19].LightUp && !InputList[20].LightUp) - { - TrayFeedReady = false; + string sn1 = TestBenchBox[0].State.StatuInfo == "" ? "12345678901234567890" : TestBenchBox[0].State.StatuInfo; + string sn2 = TestBenchBox[1].State.StatuInfo == "" ? "12345678901234567890" : TestBenchBox[1].State.StatuInfo; + //string sn1 = "1234567890123"; + //string sn2 = "1234567890123"; - MyFlow.RunStep = GengralProcessEnum.Step10; + //清空测试结果 + TestResultStr = ""; + TestFinish = false; + Testing = true; //测试中 + + //发送二维码和开始信号 + TestMachine.SendInfo(sn1 + ";" + sn2 + ";LOADOK"); + TestMachine.SendInfo(sn1 + ";" + sn2 + ";LOADOK"); + TestMachine.SendInfo(sn1 + ";" + sn2 + ";LOADOK"); + TestMachine.SendInfo(sn1 + ";" + sn2 + ";LOADOK"); + TestMachine.SendInfo(sn1 + ";" + sn2 + ";LOADOK"); + + //TestMachine.SendInfo("12;34;LOADOK"); + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else + { + ExcepStop("左右工位感应器到位异常,请检查"); MyFlow.RunTime = DateTime.Now; } break; + case GengralProcessEnum.Step13: + //等待测试机回复测试完成 + //if (TestRecStr.Contains("TESTOK")) + //{ + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + //} + //else if (TestRecStr.Contains("ALARM")) //测试机回复报错,产品判定为NG + //{ + // TestBenchBox.ForEach(w => w.State.StatusBackground = ColorStr.Red); + // MyFlow.RunStep = GengralProcessEnum.Step15; + // MyFlow.RunTime = DateTime.Now; + //} + ////200秒未回复,重置流程 + //else if (MyFlow.RunTime.AddSeconds(200) <= DateTime.Now) + //{ + // MyFlow.RunStep = GengralProcessEnum.Start; + // MyFlow.RunTime = DateTime.Now; + //} + + //测试结束,测试结果字符串不为空 + if (!Testing && !string.IsNullOrEmpty(TestResultStr)) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + //200秒未回复,重置流程 + else if (MyFlow.RunTime.AddSeconds(120) <= DateTime.Now) + { + Testing = false; + ExcepStop("测试超时,请重置流程"); + MyFlow.RunStep = GengralProcessEnum.End; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step14: + #region 获取测试结果 + if (TestFinish) //测试成功 + { + if (TestResultStr != "NG") //测试机报错 + { + string[] strList = TestResultStr.Split(';'); //分割结果 + //找到TEST数组所在位置,寻找结果 + int i = 0; + foreach (var item in strList) + { + if (item.Contains("TESTOK")) + { + break; + } + + i++; + } + + if (strList[i + 1] == "OK") + { + TestBenchBox[0].State.StatusBackground = ColorStr.Green; + } + else + { + TestBenchBox[0].State.StatusBackground = ColorStr.Green; + //TestBenchBox[0].State.StatusBackground = ColorStr.Red; + } + + if (strList[i + 2] == "OK") + { + TestBenchBox[1].State.StatusBackground = ColorStr.Green; + } + else + { + TestBenchBox[1].State.StatusBackground = ColorStr.Green; + //TestBenchBox[1].State.StatusBackground = ColorStr.Red; + } + MyFlow.RunStep = MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + else + { + Testing = false; + ExcepStop("测试机报错,请重置流程"); + MyFlow.RunStep = GengralProcessEnum.End; + MyFlow.RunTime = DateTime.Now; + } + } + else + { + TestBenchBox.ForEach(w => w.State.StatusBackground = ColorStr.Red); + MyFlow.RunStep = MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + + #endregion + + break; + + #region 打开气缸,已交由机械手流程 + //case GengralProcessEnum.Step15: + // //测试结束 + // if (TestBenchBox.Where(w => w.State.StatusBackground == ColorStr.Green || w.State.StatusBackground == ColorStr.Red).Count() >= 2) + // { + // //平台顶升气缸下降 + // TestBenchBox[0].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[0].YDingShengQiGangYW.Switchs = true; + + // TestBenchBox[1].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[1].YDingShengQiGangYW.Switchs = true; + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + //case GengralProcessEnum.Step16: + // //顶升原位 + // if (TestBenchBox[0].XDingShengQigangYW.LightUp && TestBenchBox[1].XDingShengQigangYW.LightUp) + // { + // //顶升置位 + // //平台顶升气缸下降 + // TestBenchBox[0].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[0].YDingShengQiGangYW.Switchs = false; + + // TestBenchBox[1].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[1].YDingShengQiGangYW.Switchs = false; + + // //伸缩气缸原位 + // TestBenchBox[0].YShenSuoQiGangDW.Switchs = false; + // TestBenchBox[0].YShenSuoQiGangYW.Switchs = true; + + // TestBenchBox[1].YShenSuoQiGangDW.Switchs = false; + // TestBenchBox[1].YShenSuoQiGangYW.Switchs = true; + + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + // { + // ExcepStop(TestBenchBox[0].XDingShengQigangYW.InputMeaning + "\\" + TestBenchBox[1].XDingShengQigangYW.InputMeaning + "异常"); + // //平台顶升气缸下降 + // TestBenchBox[0].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[0].YDingShengQiGangYW.Switchs = true; + + // TestBenchBox[1].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[1].YDingShengQiGangYW.Switchs = true; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + //case GengralProcessEnum.Step17: + // //伸缩原位 + // if (TestBenchBox[0].XShenSuoQigangYW.LightUp && TestBenchBox[1].XShenSuoQigangYW.LightUp) + // { + // //伸缩置位 + // TestBenchBox[0].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[0].YDingShengQiGangYW.Switchs = false; + + // TestBenchBox[1].YDingShengQiGangDW.Switchs = false; + // TestBenchBox[1].YDingShengQiGangYW.Switchs = false; + + + // MyFlow.RunStep = GengralProcessEnum.Start; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (MyFlow.RunTime.AddSeconds(3) <= DateTime.Now) + // { + // ExcepStop(TestBenchBox[0].XShenSuoQigangYW.InputMeaning + "\\" + TestBenchBox[1].XShenSuoQigangYW.InputMeaning + "异常"); + // //伸缩气缸原位 + // TestBenchBox[0].YShenSuoQiGangDW.Switchs = false; + // TestBenchBox[0].YShenSuoQiGangYW.Switchs = true; + + // TestBenchBox[1].YShenSuoQiGangDW.Switchs = false; + // TestBenchBox[1].YShenSuoQiGangYW.Switchs = true; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + #endregion } } #endregion - #region 空盘回收 + #region GRR模式 + private bool gRRMode; /// - /// 空盘回收起点 + /// GRR模式 /// - MotionPointModel BlankingStart { get; set; } - /// - /// 空盘回收满盘点 - /// - MotionPointModel BlankingManPan { get; set; } - /// - /// 空盘回收下盘点 - /// - MotionPointModel BlankingEnd { get; set; } - - /// - /// 空盘回收流程 - /// - FlowModel TrayBlankingFlow { get; set; } - - /// - /// 临时点位 - /// - MotionPointModel TempMotionPoint { get; set; } - - /// - /// 空盘回收 - /// - private void TrayBlankingRun(FlowModel MyFlow) + public bool GRRMode { - switch (MyFlow.RunStep) + get { return gRRMode; } + set { gRRMode = value; this.RaisePropertyChanged("GRRMode"); } + } + + #endregion + + #region 不良传送运行 + /// + /// NG皮带运行信号 + /// + public bool BadLineRun { get; set; } + + DateTime BadLineRunTime { get; set; } + + /// + /// 不良传送运行 + /// + private void BadRun() + { + //NG满料检知 + if (!InputList[X106NG皮带检知3].LightUp) { - case GengralProcessEnum.Start: - BlankingStart = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 3).FirstOrDefault()); //空盘回收起点 - BlankingEnd = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 4).FirstOrDefault()); //空盘回收终点 - TempMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 6).FirstOrDefault()); //搬运放盘点 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step1: - //搬运移栽轴移动到放盘位待机 - if (TempMotionPoint.PointRun(MCVM.AllShaftList)) + //不良运行信号 + if (BadLineRun) + { + //NG皮带转1S + if (BadLineRunTime.AddMilliseconds(700) >= DateTime.Now) { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 10000, TempMotionPoint.PointName + "移动超时")) - { - TempMotionPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step2: - //回收光纤检知无料盘 - if (!InputList[21].LightUp && !InputList[22].LightUp) - { - //运行到空盘回收起点 - if (BlankingStart.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - } - else//有料盘 - { - BlankingStart.PointStop();//停止运行 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step3: - //向收盘终点运行 - if (BlankingEnd.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep = GengralProcessEnum.Step20; - MyFlow.RunTime = DateTime.Now; - } - else if (!InputList[21].LightUp && !InputList[22].LightUp)//回收光纤检知无 - { - BlankingEnd.PointStop();//停止运行 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - break; - - #region 空盘移栽 - case GengralProcessEnum.Step4: - //有空盘需要移栽 - if (Tray1.MyLabelList.Where(w => w.Prouct.StateColour == ColorStr.Gray).Count() >= Tray1.MyLabelList.Count() && TakeKongTray) - { - TempMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 7).FirstOrDefault()); - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step5: - //空盘搬运轴运行到取盘点 - if (TempMotionPoint.PointRun(MCVM.AllShaftList)) - { - OutputList[6].Switchs = true;//移栽上下气缸 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 10000, TempMotionPoint.PointName + "移动超时")) - { - TempMotionPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step6: - //移栽下降到位 - if (InputList[24].LightUp) - { - if (!CurrentMachine.RunningMode) - { - OutputList[9].Switchs = true;//打开真空 - } - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[24].InputMeaning + "异常")) - { - OutputList[6].Switchs = true;//移栽上下气缸 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step7: - //真空到位 - if (InputList[41].LightUp || CurrentMachine.RunningMode) - { - OutputList[6].Switchs = false;//移栽上下气缸 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[41].InputMeaning + "异常")) - { - OutputList[9].Switchs = true;//打开真空 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step8: - //移栽上升到位 - if (InputList[23].LightUp) - { - TempMotionPoint = Coper(CurrentMachine.MotionPointList.Where(w => w.PointType == 6).FirstOrDefault()); - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[23].InputMeaning + "异常")) - { - OutputList[6].Switchs = false;//移栽上下气缸 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step9: - //空盘搬运轴运行到放盘点 - if (TempMotionPoint.PointRun(MCVM.AllShaftList)) - { - //料盘置为白色,可以继续上料 - Tray1.MyLabelList.ForEach(w => w.Prouct.StateColour = ColorStr.White); - OutputList[6].Switchs = true;//移栽上下气缸 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 10000, TempMotionPoint.PointName + "移动超时")) - { - TempMotionPoint.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step10: - //移栽下降到位 - if (InputList[24].LightUp) - { - OutputList[9].Switchs = false;//打开真空 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[24].InputMeaning + "异常")) - { - OutputList[4].Switchs = true;//移栽上下气缸 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step11: - //真空吸没有 - if (!InputList[41].LightUp) - { - OutputList[6].Switchs = false;//移栽上下气缸 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[26].LightUp + "异常")) - { - OutputList[9].Switchs = false;//打开真空 - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step12: - //移栽上升到位 - if (InputList[23].LightUp) - { - TakeKongTray = false; - MyFlow.RunStep = GengralProcessEnum.Step3; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, InputList[22].InputMeaning + "异常")) - { - OutputList[6].Switchs = false;//移栽上下气缸 - MyFlow.RunTime = DateTime.Now; - } - break; - #endregion - - #region 空盘满盘下料 - case GengralProcessEnum.Step20: - //运行到下料点 - BlankingManPan = CurrentMachine.MotionPointList.Where(w => w.PointType == 5).FirstOrDefault(); - BlankingManPan.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step21: - //到达下料区 - if (BlankingManPan.PointRun(MCVM.AllShaftList)) - { - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (TimeOutValidation(MyFlow.RunTime, 5000, BlankingManPan.PointName + "超时异常")) - { - BlankingManPan.PointRunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - break; - case GengralProcessEnum.Step22: - //下料区无盘 - if (!InputList[17].LightUp && !InputList[18].LightUp) - { - OutputList[15].Switchs = true;//空盘皮带1 - OutputList[16].Switchs = true;//空盘皮带2 - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - } - else if (InputList[17].LightUp && InputList[18].LightUp) - { - ExcepNoStop("请取走空盘"); - } - break; - case GengralProcessEnum.Step23: - //下料区有盘 且空盘区无盘 - if (InputList[17].LightUp && InputList[18].LightUp && !InputList[15].LightUp && !InputList[16].LightUp) - { - OutputList[15].Switchs = false;//空盘皮带1 - OutputList[16].Switchs = false;//空盘皮带2 - //ExcepNoStop("请取走空盘"); - //OutputList[36].Switchs = false;//空盘满料指示灯 - MyFlow.RunStep = GengralProcessEnum.Start; - MyFlow.RunTime = DateTime.Now; - } - else if (MyFlow.RunTime.AddSeconds(20) < DateTime.Now) - { - ExcepStop("空盘推出异常"); + OutputList[Y102NG皮带].Switchs = true; //左ng皮带 } else { - OutputList[15].Switchs = true;//空盘皮带1 - OutputList[16].Switchs = true;//空盘皮带2 + BadLineRun = false; + OutputList[Y102NG皮带].Switchs = false; } - break; - #endregion + } + else + { + OutputList[Y102NG皮带].Switchs = false; + BadLineRunTime = DateTime.Now; + } } + else + { + ExcepStop("NG料满,请清料"); + BadLineRunTime = DateTime.Now; + } + } #endregion @@ -3407,100 +3938,31 @@ namespace ViewModel /// bool GratingSignal { get; set; } + /// + /// 载具是否已放行 + /// + bool yifangxing { get; set; } + + /// + /// 载具字符串 + /// + public string SendVehicleStr { get; set; } /// /// 双控运行 /// private void DualControlRun() { - OutputList[5].Switchs = !OutputList[6].Switchs; //上下搬运气缸 - OutputList[25].Switchs = !OutputList[24].Switchs; //顶升气缸 - - //运行模式下触发料仓光栅 - if (RunStatu == RunStatuEnum.Normal && InputList[10].LightUp) - { - GratingSignal = true; - } - - //光栅信号触发后,清除光栅报警 - if (GratingSignal && (InputList[8].LightUp || InputList[9].LightUp)) - { - GratingSignal = false; - } - - //撤销回流 - if (InputList[36].LightUp || InputList[37].LightUp) - { - BehindSendInfo = JiaohuModel.BackflowRevoke; - } - - - //前后站交互 - //SendFrontStation(); - //SendNextStation(); + //OutputList[Y105左笔形气缸伸出].Switchs = !OutputList[Y106左笔形气缸缩回].Switchs; + //OutputList[Y107左顶升气缸下位].Switchs = !OutputList[Y108左顶升气缸上位].Switchs; + //OutputList[Y109右笔形气缸伸出].Switchs = !OutputList[Y110右笔形气缸缩回].Switchs; + //OutputList[Y111右顶升气缸下位].Switchs = !OutputList[Y112右顶升气缸上位].Switchs; + //OutputList[Y200搬运气缸上位].Switchs = !OutputList[Y201搬运气缸下位].Switchs; + OutputList[36].Switchs = !OutputList[37].Switchs; + OutputList[38].Switchs = !OutputList[39].Switchs; } #endregion - #region 机台通讯 - #region 上一站连接 - /// - /// 上一站连接 - /// - public CommunicationManagementClass FrontStation { get; set; } - #endregion - - #region 下一站连接 - /// - /// 下一站连接 - /// - public CommunicationManagementClass NextStation { get; set; } - #endregion - - #region 发送消息给下一站 - DateTime SendNextStationTime { get; set; } - - /// - /// 发给后站的信息 - /// - string BehindSendInfo { get; set; } - - /// - /// 发送消息给下一站 - /// - /// - private void SendNextStation() - { - if (SendNextStationTime.AddMilliseconds(500) < DateTime.Now && !string.IsNullOrEmpty(BehindSendInfo)) - { - NextStation.SendInfo(BehindSendInfo); - SendNextStationTime = DateTime.Now; - } - } - #endregion - - #region 发送信息给上一站 - /// - /// 发给上一站的信息 - /// - string FrontSendInfor { get; set; } - DateTime SendFrontStationTime { get; set; } - /// - /// 发送信息给上一站 - /// - /// - private void SendFrontStation() - { - if (SendFrontStationTime.AddMilliseconds(500) < DateTime.Now && !string.IsNullOrEmpty(FrontSendInfor)) - { - FrontStation.SendInfo(FrontSendInfor); - SendFrontStationTime = DateTime.Now; - } - } - #endregion - - - #endregion - #region 网络连接控制 /// /// 网络连接控制 @@ -3539,6 +4001,207 @@ namespace ViewModel } } #endregion + + #region 测试机连接对象 + private CommunicationManagementClass testMachine; + /// + /// 测试机连接对象 + /// + public CommunicationManagementClass TestMachine + { + get { return testMachine; } + set { testMachine = value; this.RaisePropertyChanged("TestMachine"); } + } + + + string TestRecStr { get; set; } + + /// + /// 测试成功信号,测试机回复 + /// + bool TestFinish { get; set; } + + /// + /// 测试机回调函数 + /// + /// + private void TestMachine_ReceiveCallback(string str) + { + if (!String.IsNullOrEmpty(str)) + { + TestRecStr = str; + + if (str.Contains("TEST")) + { + TestResultStr = TestRecStr; + } + } + } + #endregion + + #region 上一站连接 + /// + /// 上一站连接 + /// + public CommunicationManagementClass FrontStation { get; set; } + #endregion + + #region 下一站连接 + /// + /// 下一站连接 + /// + public CommunicationManagementClass NextStation { get; set; } + #endregion + + #region 发送消息给下一站 + + /// + /// 发送载具状态的字符串 + /// + + DateTime SendNextStationTime { get; set; } + /// + /// 发送消息给下一站 + /// + private void SendNextStation() + { + if (SendNextStationTime.AddMilliseconds(100) < DateTime.Now) + { + if (NextStation.Showmsg.StatusBackground == ColorStr.Green) + { + var sendStr = ShareHelp.ObjToJson(NextStationSend); + NextStation.SendInfo(sendStr); + } + else + { + NextStationSend.Safe = false; + NextStation.ConnectSwitch = !NextStation.ConnectSwitch; + } + SendNextStationTime = DateTime.Now; + } + } + #endregion + + #region 发送信息给上一站 + + DateTime SendFrontStationTime { get; set; } + /// + /// 发送信息给上一站 + /// + /// + private void SendFrontStation() + { + if (SendFrontStationTime.AddMilliseconds(100) < DateTime.Now) + { + if (FrontStation.Showmsg.StatusBackground == ColorStr.Green) + { + var sendStr = ShareHelp.ObjToJson(FrontStationSend); + FrontStation.SendInfo(sendStr); + } + else + { + FrontStationSend.Safe = false; + FrontStation.ConnectSwitch = !FrontStation.ConnectSwitch; + } + + SendFrontStationTime = DateTime.Now; + } + } + #endregion + + #region 前站消息 + /// + /// 从后站收到的消息 + /// + StationMessage _FrontStationReceive = new StationMessage(); + /// + /// 从前站收到的消息 + /// + StationMessage FrontStationReceive + { + get + { + return _FrontStationReceive; + } + set + { + if (value != null) + { + _FrontStationReceive = value; + } + else + { + _FrontStationReceive.Safe = false; + } + } + } + /// + /// 发送给前站的消息 + /// + StationMessage FrontStationSend = new StationMessage(); + + /// + /// 前站回调函数 + /// + /// + private void FrontStation_ReceiveCallback(string str) + { + try + { + FrontStationReceive = ShareHelp.JsonToObj(str); + + } + catch (Exception) + { + FrontStationReceive = new StationMessage(); + } + } + #endregion + + #region 后站消息 + StationMessage _NextStationReceive = new StationMessage(); + /// + /// 从后站收到的消息 + /// + StationMessage NextStationReceive + { + get + { + return _NextStationReceive; + } + set + { + if (value != null) + { + _NextStationReceive = value; + } + else + { + _NextStationReceive.Safe = false; + } + } + } + /// + /// 发送给后站的消息 + /// + StationMessage NextStationSend = new StationMessage(); + + /// + /// 后站回调函数 + /// + /// + private void NextStation_ReceiveCallback(string str) + { + try + { + NextStationReceive = ShareHelp.JsonToObj(str); + } + catch (Exception) + { + NextStationReceive = new StationMessage(); + } + } + #endregion #endregion #region 4、加载功能界面 @@ -3645,88 +4308,6 @@ namespace ViewModel #endregion - #region 前站回调函数 - /// - /// 前站发来的字符串拆解 - /// - List NewsList { get; set; } - - /// - /// 当前前站交互信息 - /// - string CurrFrontStr { get; set; } - - /// - /// 当前前站回流交互信息 - /// - string CurrFrontHuiliuStr { get; set; } - - /// - /// 前站回调函数 - /// - /// - private void FrontStation_ReceiveCallback(string str) - { - try - { - NewsList = str.Split(';').ToList(); - switch (NewsList[0]) - { - case "BackflowRequest": - CurrFrontHuiliuStr = JiaohuModel.BackflowRequest; - break; - case "BackflowRevoke": - CurrFrontHuiliuStr = JiaohuModel.BackflowRevoke; - break; - case "BackflowFangxing": - CurrFrontHuiliuStr = JiaohuModel.BackflowFangxing; - break; - } - } - catch (Exception) - { - - } - } - #endregion - - #region 后站回调函数 - /// - /// 当前接收到的下一站信息 - /// - string CurrNextStr { get; set; } - - /// - /// 当前接收到的回流送料信息 - /// - string CurrNextHuiliuStr { get; set; } - - /// - /// 后站发来的字符串拆解 - /// - List NextStrList { get; set; } - /// - /// 后站回调函数 - /// - /// - private void NextStation_ReceiveCallback(string str) - { - NextStrList = str.Split(':').ToList(); - switch (NextStrList[0]) - { - case "VehicleRequest": - CurrNextStr = JiaohuModel.VehicleRequest; - break; - case "VehicleRevoke": - CurrNextStr = JiaohuModel.VehicleRevoke; - break; - case "BackflowFangxing": - CurrNextHuiliuStr = JiaohuModel.BackflowFangxing; - break; - } - } - #endregion - #region 刷新机械手阵列点位 /// /// 刷新机械手阵列点位 @@ -3845,10 +4426,10 @@ namespace ViewModel { try { - if (ExcepNoIng) - { - return; - } + //if (ExcepNoIng) + //{ + // return; + //} ShowStatu.StatusBackground = ColorStr.Yellow; ShowStatu.StatusForeground = ColorStr.Red; @@ -3860,7 +4441,6 @@ namespace ViewModel //OutputList[2].Switchs = true; //绿灯 OutputList[3].Switchs = true; //蜂鸣器 - //记录异常信息 try { @@ -3939,11 +4519,6 @@ namespace ViewModel if (RunStatu != RunStatuEnum.Stop) { - //上下皮带暂停 - OutputList[17].Switchs = false;//正转 - OutputList[18].Switchs = false;//反转 - HLLiftPlatLine = 0; - RunStatu = RunStatuEnum.Stop; RecordLog("停止运行"); } @@ -4016,17 +4591,15 @@ namespace ViewModel TakeFlow = new FlowModel("取料"); DownVisionFlow = new FlowModel("测试盒取出"); BoxInPutFlow = new FlowModel("测试盒投入"); - TrayFeedFlow = new FlowModel("料盘上料"); - TrayBlankingFlow = new FlowModel("空盘回收"); - UpLineRunFlow = new FlowModel("出料流程"); - VehicleLiftRunFlow = new FlowModel("载具升降流程"); - HuiLiuFlow = new FlowModel("回流流程"); + CarryPutOutFlow = new FlowModel("机台搬运"); + ProLineFlow = new FlowModel("良品皮带运行"); + TestBoxFlow = new FlowModel("测试平台运行"); - MyVehicleBox.ForEach(w => w.State.StatusBackground = ColorStr.White); + TestFinish = false; + Testing = false; + PutOk = false; - TrayFeedReady = false; - TouliaoReady = false; - TakeKongTray = false; + //MyVehicleBox.ForEach(w => w.State.StatusBackground = ColorStr.White); //重置吸嘴状态 if (XizuiLabelPaperList != null) @@ -4095,7 +4668,7 @@ namespace ViewModel dal.UpdateProductionData(CurrentMachine); //更新生产数据 dal.UpdateMachineData(CurrentMachine); dal.UpdateSystemPar(SystemPar); - + dal.UpdateRobotModel(Robot.RobotPer); CloseRes = MyMessageBox.Show("你确定要退出吗?", "提示", MessageDialogStyle.AffirmativeAndNegative); @@ -4397,52 +4970,10 @@ namespace ViewModel /// /// 获取吸嘴Grid /// - public void GetMachineLabelGrid() + public void GetXizuiLabelGrid() { XizuiLabelPaperList = new List(); - Grid gd = new Grid(); - for (int i = 0; i < 1; i++) - { - gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 - HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; - gd.Children.Add(sm.Labels); - sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 - sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 - XizuiLabelPaperList.Add(sm); - } - - XizuiLabelPaperList[0].VacuumSwitch = OutputList[11]; - XizuiLabelPaperList[0].VacuumPoSwitch = OutputList[12]; - XizuiLabelPaperList[0].VacuumCheck = InputList[42]; - - XizuiLabelGrid = gd; - } - #endregion - - #region 载具初始化 - private Grid vehicleBoxGrid; - /// - /// 缓存位Grid - /// - public Grid VehicleBoxGrid - { - get { return vehicleBoxGrid; } - set { vehicleBoxGrid = value; this.RaisePropertyChanged("VehicleBoxGrid"); } - } - - /// - /// 缓存位集合 - /// - public List MyVehicleBox { get; set; } - - /// - /// 获取缓存位Grid - /// - public void GetVehicleGrid() - { - MyVehicleBox = new List(); - Grid gd = new Grid(); for (int i = 0; i < 2; i++) { @@ -4451,13 +4982,243 @@ namespace ViewModel gd.Children.Add(sm.Labels); sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 - MyVehicleBox.Add(sm); + XizuiLabelPaperList.Add(sm); } - VehicleBoxGrid = gd; + + //吸嘴吸真空 + XizuiLabelPaperList[0].VacuumSwitch = OutputList[32]; + XizuiLabelPaperList[0].VacuumPoSwitch = OutputList[33]; + XizuiLabelPaperList[0].VacuumCheck = InputList[32]; + + XizuiLabelPaperList[1].VacuumSwitch = OutputList[34]; + XizuiLabelPaperList[1].VacuumPoSwitch = OutputList[35]; + XizuiLabelPaperList[1].VacuumCheck = InputList[33]; + + //吸嘴气缸 + XizuiLabelPaperList[0].QiGang = OutputList[37]; + XizuiLabelPaperList[0].QiGangUp = InputList[34]; + XizuiLabelPaperList[0].QiGangDown = InputList[35]; + + XizuiLabelPaperList[1].QiGang = OutputList[39]; + XizuiLabelPaperList[1].QiGangUp = InputList[36]; + XizuiLabelPaperList[1].QiGangDown = InputList[37]; + + XizuiLabelGrid = gd; + } + #endregion + + #region 测试平台初始化 + private Grid testBenchGrid; + /// + /// 测试平台Grid + /// + public Grid TestBenchGrid + { + get { return testBenchGrid; } + set { testBenchGrid = value; this.RaisePropertyChanged("TestBenchGrid"); } + } + + /// + /// 测试平台集合 + /// + public List TestBenchBox { get; set; } + + /// + /// 测试平台Grid + /// + public void GetTestBenchGrid() + { + TestBenchBox = new List(); + + Grid gd = new Grid(); + for (int i = 0; i < 2; i++) + { + gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 + HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; + gd.Children.Add(sm.Labels); + sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 + sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + TestBenchBox.Add(sm); + } + TestBenchGrid = gd; //分配载具放料点 - MyVehicleBox[0].PutProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 11).FirstOrDefault(); - MyVehicleBox[1].PutProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 12).FirstOrDefault(); + TestBenchBox[0].PutProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 5).FirstOrDefault(); + TestBenchBox[0].TakeProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 4).FirstOrDefault(); + TestBenchBox[1].PutProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 7).FirstOrDefault(); + TestBenchBox[1].TakeProPoint1 = Robot.RobotPointList.Where(w => w.PointType == 6).FirstOrDefault(); + + //平台顶升气缸 + TestBenchBox[0].YDingShengQiGangYW = OutputList[18]; + TestBenchBox[0].YDingShengQiGangDW = OutputList[19]; + TestBenchBox[0].XDingShengQigangYW = InputList[18]; + TestBenchBox[0].XDingShengQigangDW = InputList[19]; + TestBenchBox[1].YDingShengQiGangYW = OutputList[24]; + TestBenchBox[1].YDingShengQiGangDW = OutputList[25]; + TestBenchBox[1].XDingShengQigangYW = InputList[24]; + TestBenchBox[1].XDingShengQigangDW = InputList[25]; + + //平台伸缩气缸 + TestBenchBox[0].YShenSuoQiGangYW = OutputList[16]; + TestBenchBox[0].YShenSuoQiGangDW = OutputList[17]; + TestBenchBox[0].XShenSuoQigangYW = InputList[16]; + TestBenchBox[0].XShenSuoQigangDW = InputList[17]; + TestBenchBox[1].YShenSuoQiGangYW = OutputList[22]; + TestBenchBox[1].YShenSuoQiGangDW = OutputList[23]; + TestBenchBox[1].XShenSuoQigangYW = InputList[22]; + TestBenchBox[1].XShenSuoQigangDW = InputList[23]; + } + + #endregion + + #region 流线对象 + #region 缓存流线对象 + private Grid cacheLineGrid; + /// + /// 缓存流线对象 + /// + public Grid CacheLineGrid + { + get { return cacheLineGrid; } + set { cacheLineGrid = value; this.RaisePropertyChanged("CacheLineGrid"); } + } + + + /// + /// 缓存流线对象集合 + /// + public List CacheLineList { get; set; } + + /// + /// 获取缓存流线Grid + /// + public void GetCacheLineGrid() + { + CacheLineList = new List(); + + Grid gd = new Grid(); + for (int i = 0; i < 1; i++) + { + gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 + HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; + gd.Children.Add(sm.Labels); + sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 + sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + CacheLineList.Add(sm); + } + CacheLineGrid = gd; + } + #endregion + + #region 良品流线对象 + private Grid produceLineGrid; + /// + /// 良品流线对象 + /// + public Grid ProduceLineGrid + { + get { return produceLineGrid; } + set { produceLineGrid = value; this.RaisePropertyChanged("ProduceLineGrid"); } + } + + + /// + /// 良品流线对象集合 + /// + public List ProduceLineList { get; set; } + + /// + /// 获取良品流线Grid + /// + public void GetProduceLineGrid() + { + ProduceLineList = new List(); + + Grid gd = new Grid(); + for (int i = 0; i < 1; i++) + { + gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 + HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; + gd.Children.Add(sm.Labels); + sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 + sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + ProduceLineList.Add(sm); + } + ProduceLineGrid = gd; + } + #endregion + #endregion + + #region 前后站物料状态 + private Grid stationProduceGrid; + /// + /// 前后站物料Grid + /// + public Grid StationProduceGrid + { + get { return stationProduceGrid; } + set { stationProduceGrid = value; RaisePropertyChanged("StationProduceGrid"); } + } + + /// + /// 前后站物料集合 + /// + public List StationProduceList { get; set; } + /// + /// 前后站物料Grid + /// + public void GetStationProduceGrid() + { + StationProduceList = new List(); + + Grid gd = new Grid(); + for (int i = 0; i < 2; i++) + { + gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 + HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; + gd.Children.Add(sm.Labels); + sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 + sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + StationProduceList.Add(sm); + } + StationProduceGrid = gd; + } + #endregion + + #region 进料平台状态 + private Grid inCacheGrid; + /// + /// 进料平台对象 + /// + public Grid InCacheGrid + { + get { return inCacheGrid; } + set { inCacheGrid = value; this.RaisePropertyChanged("InCacheGrid"); } + } + + /// + /// 进料平台对象集合 + /// + public List InCacheList { get; set; } + + /// + /// 进料平台对象Grid + /// + public void GetInCacheGrid() + { + InCacheList = new List(); + + Grid gd = new Grid(); + for (int i = 0; i < 1; i++) + { + gd.ColumnDefinitions.Add(new ColumnDefinition()); //添加列 + HandModel sm = new HandModel() { Number = i + 1, State = new ShowInfo() { StatuInfo = (i + 1).ToString() } }; + gd.Children.Add(sm.Labels); + sm.Labels.SetValue(Grid.RowProperty, 0); //设置按钮所在Grid控件的行 + sm.Labels.SetValue(Grid.ColumnProperty, i); //设置按钮所在Grid控件的列 + InCacheList.Add(sm); + } + InCacheGrid = gd; } #endregion } @@ -5275,163 +6036,4 @@ namespace ViewModel } #endregion - - /// - /// 吸嘴模型 - /// - public class HandModel : NotificationObject - { - /// - /// 序号 - /// - public int Number { get; set; } - - public Label Labels { get; set; } - - private ShowInfo state; - /// - /// 标签状态 - /// - public ShowInfo State - { - get { return state; } - set - { - state = value == null ? new ShowInfo() : value; - RaisePropertyChanged("State"); - } - } - - /// - /// 气缸 - /// - public OutputSignal QiGang { get; set; } - /// - /// 气缸原位 - /// - public InputSignal QiGangUp { get; set; } - /// - /// 气缸到位 - /// - public InputSignal QiGangDown { get; set; } - - /// - /// 旋转气缸 - /// - public OutputSignal XuanzhuangQiGang { get; set; } - /// - /// 旋转气缸原位 - /// - public InputSignal XuanzhuanQigangYW { get; set; } - /// - /// 旋转气缸到位 - /// - public InputSignal XuanzhuanQigangDW { get; set; } - - - /// - /// 真空开关 - /// - public OutputSignal VacuumSwitch { get; set; } - - /// - /// 真空破开关 - /// - public OutputSignal VacuumPoSwitch { get; set; } - - /// - /// 真空捡知 - /// - public InputSignal VacuumCheck { get; set; } - - /// - /// 吸嘴放料点位1 - /// - public RobotPoint PutProPoint1 { get; set; } - /// - /// 吸嘴放料点位2 - /// - public RobotPoint PutProPoint2 { get; set; } - - public double OfficeX { get; set; } - public double OfficeY { get; set; } - - public double OfficeU { get; set; } - - /// - /// Label显示控件对象 - /// - public HandModel() - { - State = new ShowInfo(); - Labels = new Label(); - //数据样式 - Labels.Style = (Style)MyMessageBox.MetroWin.FindResource("Mylabel1");//LabelStyle 这个样式是引用的资源文件中的样式名称 - //绑定背景颜色 - Labels.SetBinding(Label.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatusBackground"), Mode = BindingMode.TwoWay }); - //绑定内容 - Labels.SetBinding(Label.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("State.StatuInfo"), Mode = BindingMode.TwoWay }); - - Labels.MouseDoubleClick += Labels_MouseDoubleClick; //增加鼠标双击事件 - Labels.Margin = new Thickness(1); //设置边距 - } - - - /// - /// Label的双击事件 - /// - /// - /// - private void Labels_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) - { - //如果为绿色 则不允许改其他颜色 - if (State.StatusBackground == ColorStr.White) - { - State.StatusBackground = ColorStr.Blue; - } - else if (State.StatusBackground == ColorStr.Blue) - { - State.StatusBackground = ColorStr.Green; - - } - else - { - State.StatusBackground = ColorStr.White; - } - - } - } - - /// - /// 机台交互模型 - /// - public static class JiaohuModel - { - /// - /// 载具请求 - /// - public static string VehicleRequest = "VehicleRequest"; - /// - /// 载具已放行 - /// - public static string VehicleFangxing = "VehicleFangxing"; - /// - /// 撤销载具请求 - /// - public static string VehicleRevoke = "VehicleRevoke"; - - /// - /// 回流请求 - /// - public static string BackflowRequest = "BackflowRequest"; - /// - /// 回流已放行 - /// - public static string BackflowFangxing = "BackflowFangxing"; - /// - /// 撤销回流 - /// - public static string BackflowRevoke = "BackflowRevoke"; - - } } diff --git a/ViewModel/Robots/EpsonRobotVM.cs b/ViewModel/Robots/EpsonRobotVM.cs index 3cd1b38..45c91aa 100644 --- a/ViewModel/Robots/EpsonRobotVM.cs +++ b/ViewModel/Robots/EpsonRobotVM.cs @@ -50,8 +50,6 @@ namespace ViewModel.Robots /// public string RCVInfo { get; set; } - - #region 机器人连接 private bool robotConn; /// diff --git a/ViewModel/ViewModel.csproj b/ViewModel/ViewModel.csproj index a368dbc..a6641de 100644 --- a/ViewModel/ViewModel.csproj +++ b/ViewModel/ViewModel.csproj @@ -90,6 +90,7 @@ + diff --git a/ViewModel/Vision/V_SweepCode.cs b/ViewModel/Vision/V_SweepCode.cs index 63f7c62..c500bba 100644 --- a/ViewModel/Vision/V_SweepCode.cs +++ b/ViewModel/Vision/V_SweepCode.cs @@ -553,9 +553,6 @@ namespace ViewModel.Vision ho_SymbolXLDs.Dispose(); HOperatorSet.FindDataCode2d(ho_ROIImage, out ho_SymbolXLDs, hv_DataCodeHandleMaximum, ParamName, CodeCount, out hv_ResultHandles, out hv_DecodedDataStrings); - - - //显示XLD轮廓 SetColored(12); //ClearWindowAndData(); diff --git a/Views/ControlPanel.xaml b/Views/ControlPanel.xaml index c5f6956..e811929 100644 --- a/Views/ControlPanel.xaml +++ b/Views/ControlPanel.xaml @@ -21,7 +21,7 @@ - + @@ -31,12 +31,14 @@ - - - - - - + + + + + + + + @@ -91,8 +93,7 @@ Content="前站连接" Foreground="White" Background="{Binding StatusBackground}"> - - - + + + + - + diff --git a/Views/MainInterface.xaml b/Views/MainInterface.xaml index 8a315bc..dc849bd 100644 --- a/Views/MainInterface.xaml +++ b/Views/MainInterface.xaml @@ -10,8 +10,7 @@ - - + @@ -23,15 +22,9 @@ - - + + - - - - - - - + diff --git a/Views/Robot.xaml b/Views/Robot.xaml index 68fe0bb..6fdf207 100644 --- a/Views/Robot.xaml +++ b/Views/Robot.xaml @@ -204,7 +204,7 @@ - +