From 00308b1e13f82c33a6dc688ba7db6cbb02b6399c Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期五, 07 六月 2024 16:10:37 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 148 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 116 insertions(+), 32 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index a05385d..baf9974 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -42,36 +42,97 @@
private DevpSlave slave;
private SiemensS7Net siemensS7Net;
private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
+ public boolean charge0; //璇锋眰鍏呯數
+ public boolean charge1; //璇锋眰鍏呯數
private short heartBeatVal = 1;
public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
- add(100);add(101);add(102);add(103);
- add(104);add(105);add(106);add(107);
- add(108);add(109);add(110);add(111);
- add(112);add(113);add(114);add(115);
- add(116);add(117);add(118);add(119);
- add(120);add(121);add(122);add(123);
-// add(124);add(125);add(126);add(127);
- add(130);add(131);
- add(132);add(133);add(134);add(135);
- add(136);add(137);add(138);add(139);
- add(140);add(141);add(142);add(143);
- add(144);add(145);add(146);add(147);
- add(148);add(149);add(150);add(151);
- add(152);add(153);
+ add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);
+ add(108);add(109);add(110);add(111);add(112);add(113);add(114);add(115);
+ add(116);add(117);add(118);add(119);add(120);add(121);add(122);add(123);
+ add(124);add(125);add(126);add(127);add(128);add(129);add(130);add(131);
+ add(132);add(133);add(134);add(135);add(136);add(137);add(138);add(139);
+ add(140);add(141);add(142);add(143);add(144);add(145);add(146);add(147);
+ add(148);add(149);add(150);add(151);add(152);add(153);add(154);add(155);
+ add(156);add(157);add(158);add(159);add(160);add(161);add(162);add(163);
+ add(164);add(165);add(166);add(167);add(168);add(169);add(170);add(171);
+ add(172);add(173);add(174);add(175);add(176);add(177);add(178);add(179);
+ add(180);add(181);add(182);add(183);add(184);add(185);add(186);add(187);
+ add(188);add(189);add(190);add(191);add(192);add(193);add(194);add(195);
+ add(196);add(197);add(198);add(199);
+ add(200);add(201);add(202);add(203);add(204);add(205);add(206);add(207);
+ add(208);add(209);add(210);add(211);add(212);add(213);add(214);add(215);
+ add(216);add(217);add(218);add(219);add(220);add(221);add(222);add(223);
+ add(224);add(225);add(226);add(227);add(228);add(229);add(230);add(231);
+ add(232);add(233);add(234);add(235);add(236);add(237);add(238);add(239);
+ add(240);add(241);add(242);add(243);add(244);add(245);add(246);add(247);
+ add(248);add(249);add(250);add(251);add(252);add(253);add(254);add(255);
+ add(256);add(257);add(258);add(259);add(260);add(261);add(262);add(263);
+ add(264);add(265);add(266);add(267);add(268);add(269);add(270);add(271);
+ add(272);add(273);add(274);add(275);add(276);add(277);add(278);add(279);
+ add(280);add(281);add(282);add(283);add(284);add(285);add(286);add(287);
+ add(288);add(289);add(290);add(291);add(292);add(293);add(294);add(295);
+ add(296);add(297);add(298);add(299);
+ add(300);add(301);add(302);add(303);add(304);add(305);add(306);add(307);
+ add(308);add(309);add(310);add(311);add(312);add(313);add(314);add(315);
+ add(316);add(317);add(318);add(319);add(320);add(321);add(322);add(323);
+ add(324);add(325);add(326);add(327);add(328);add(329);add(330);add(331);
+ add(332);add(333);add(334);add(335);add(336);add(337);add(338);add(339);
+ add(340);add(341);add(342);add(343);add(344);add(345);add(346);add(347);
+ add(348);add(349);add(350);add(351);add(352);add(353);add(354);add(355);
+ add(356);add(357);add(358);add(359);add(360);add(361);add(362);add(363);
+ add(364);add(365);add(366);add(367);add(368);add(369);add(370);add(371);
+ add(372);add(373);add(374);add(375);add(376);add(377);add(378);add(379);
+ add(380);add(381);add(382);add(383);add(384);add(385);add(386);add(387);
+ add(388);add(389);add(390);add(391);add(392);add(393);add(394);add(395);
+ add(396);add(397);add(398);add(399);
+ add(2000);
}};
public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
- add(200);add(201);add(202);add(203);
- add(204);add(205);add(206);add(207);
- add(208);add(209);add(210);add(211);
- add(212);add(213);add(214);add(215);
- add(216);add(217);add(218);add(219);
- add(220);add(221);add(222);add(2000);
+ add(400);add(401);add(402);add(403);add(404);add(405);add(406);add(407);
+ add(408);add(409);add(410);add(411);add(412);add(413);add(414);add(415);
+ add(416);add(417);add(418);add(419);add(420);add(421);add(422);add(423);
+ add(424);add(425);add(426);add(427);add(428);add(429);add(430);add(431);
+ add(432);add(433);add(434);add(435);add(436);add(437);add(438);add(439);
+ add(440);add(441);add(442);add(443);add(444);add(445);add(446);add(447);
+ add(448);add(449);add(450);add(451);add(452);add(453);add(454);add(455);
+ add(456);add(457);add(458);add(459);add(460);add(461);add(462);add(463);
+ add(464);add(465);add(466);add(467);add(468);add(469);add(470);add(471);
+ add(472);add(473);add(474);add(475);add(476);add(477);add(478);add(479);
+ add(480);add(481);add(482);add(483);add(484);add(485);add(486);add(487);
+ add(488);add(489);add(490);add(491);add(492);add(493);add(494);add(495);
+ add(496);add(497);add(498);add(499);
+ add(500);add(501);add(502);add(503);add(504);add(505);add(506);add(507);
+ add(508);add(509);add(510);add(511);add(512);add(513);add(514);add(515);
+ add(516);add(517);add(518);add(519);add(520);add(521);add(522);add(523);
+ add(524);add(525);add(526);add(527);add(528);add(529);add(530);add(531);
+ add(532);add(533);add(534);add(535);add(536);add(537);add(538);add(539);
+ add(540);add(541);add(542);add(543);add(544);add(545);add(546);add(547);
+ add(548);add(549);add(550);add(551);add(552);add(553);add(554);add(555);
+ add(556);add(557);add(558);add(559);add(560);add(561);add(562);add(563);
+ add(564);add(565);add(566);add(567);add(568);add(569);add(570);add(571);
+ add(572);add(573);add(574);add(575);add(576);add(577);add(578);add(579);
+ add(580);add(581);add(582);add(583);add(584);add(585);add(586);add(587);
+ add(588);add(589);add(590);add(591);add(592);add(593);add(594);add(595);
+ add(596);add(597);add(598);add(599);
+ add(600);add(601);add(602);add(603);add(604);add(605);add(606);add(607);
+ add(608);add(609);add(610);add(611);add(612);add(613);add(614);add(615);
+ add(616);add(617);add(618);add(619);add(620);add(621);add(622);add(623);
+ add(624);add(625);add(626);add(627);add(628);add(629);add(630);add(631);
+ add(632);add(633);add(634);add(635);add(636);add(637);add(638);add(639);
+ add(640);add(641);add(642);add(643);add(644);add(645);add(646);add(647);
+ add(648);add(649);add(650);add(651);add(652);add(653);add(654);add(655);
+ add(656);add(657);add(658);add(659);add(660);add(661);add(662);add(663);
+ add(664);add(665);add(666);add(667);add(668);add(669);add(670);add(671);
+ add(672);add(673);add(674);add(675);add(676);add(677);add(678);add(679);
+ add(680);add(681);add(682);add(683);add(684);add(685);add(686);add(687);
+ add(688);add(689);add(690);add(691);add(692);add(693);add(694);add(695);
+ add(696);add(697);add(698);add(699);
}};
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 3;
+ private int barcodeSize = 5;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -119,10 +180,6 @@
break;
// 鍐欐暟鎹� ID+鐩爣绔�
case 2:
-// write3((StaProtocol)task.getData());
-// Thread.sleep(400);
-// write4((StaProtocol)task.getData());
-// Thread.sleep(400);
write((StaProtocol)task.getData());
break;
// 鍐欐暟鎹� ID+鐩爣绔� 鐮佸灈瀹屾垚 缁欒緭閫佺嚎鍐欎换鍔″畬鎴�
@@ -209,6 +266,29 @@
}
}
}
+
+ Thread.sleep(200);
+ OperateResultExOne<byte[]> resultError = siemensS7Net.Read("DB101.800", (short) (8));
+ if (resultError.IsSuccess) {
+ ArrayList<Integer> staNoError = new ArrayList<Integer>() {{ add(217);add(221); }};
+ for (int i = 0; i < staNoError.size(); i++) {
+ Integer siteId = staNoError.get(i); // 绔欑偣缂栧彿
+ StaProtocol staProtocol = station.get(siteId);
+ if (null == staProtocol) {
+ staProtocol = new StaProtocol();
+ staProtocol.setSiteId(siteId);
+ station.put(siteId, staProtocol);
+ }
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(resultError.Content, i*4 + 2, 1);
+ staProtocol.setFrontErr(status[0]);// 鍓嶈秴闄�
+ staProtocol.setBackErr(status[1]);// 鍚庤秴闄�
+ staProtocol.setHighErr(status[2]);// 楂樿秴闄�
+ staProtocol.setLeftErr(status[3]);// 宸﹁秴闄�
+ staProtocol.setRightErr(status[4]);// 鍙宠秴闄�
+ staProtocol.setWeightErr(status[5]); // 瓒呴噸
+ staProtocol.setBarcodeErr(status[6]);// 鎵爜澶辫触
+ }
+ }
// Thread.sleep(200);
// OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
// if (result0.IsSuccess) {
@@ -247,22 +327,22 @@
//鏉$爜鎵弿鍣�
Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.288",(short)(barcodeSize*10));
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840",(short)(barcodeSize*8));
if (result2.IsSuccess) {
- for (int i = 0; i < barcodeSize; i++) {
- String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*10,6, "UTF-8");
+ for (int i = 0; i < barcodeSize; i++) { //1:217 2:221 3:null 4:215 5:219
+ String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8");
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
barcodeThread.setBarcode(barcode);
}
}
-
}
+
//RGV灏忚溅
Thread.sleep(200);
OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
if (result3.IsSuccess) {
- Integer siteId = 16;
+ Integer siteId = 2000;
StaProtocol staProtocol = station.get(siteId);
if (null == staProtocol) {
staProtocol = new StaProtocol();
@@ -271,8 +351,6 @@
}
staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)));
}
-
-
if (result.IsSuccess) {
@@ -374,6 +452,9 @@
case 135:
index=5;
break;
+ case 147:
+ index=6;
+ break;
default:
return;
}
@@ -429,6 +510,9 @@
case 135:
index=5;
break;
+ case 147:
+ index=6;
+ break;
default:
return;
}
--
Gitblit v1.9.1