| | |
| | | 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(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); |
| | | }}; |
| | | 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); |
| | | }}; |
| | | |
| | | /** |
| | | * 条码数量 |
| | | */ |
| | | private int barcodeSize = 3; |
| | | private int barcodeSize = 5; |
| | | |
| | | /** |
| | | * 入出库模式 |
| | |
| | | // 写数据 ID+目标站 码垛完成 给输送线写任务完成复位 |
| | | case 4: |
| | | write4((StaProtocol)task.getData()); |
| | | break; |
| | | case 5: |
| | | write3((StaProtocol)task.getData()); |
| | | Thread.sleep(400); |
| | | write4((StaProtocol)task.getData()); |
| | | Thread.sleep(400); |
| | | write((StaProtocol)task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | |
| | | //条码扫描器 |
| | | 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(); |
| | |
| | | } |
| | | staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0))); |
| | | } |
| | | |
| | | |
| | | |
| | | if (result.IsSuccess) { |
| | | |
| | |
| | | case 135: |
| | | index=5; |
| | | break; |
| | | case 147: |
| | | index=6; |
| | | break; |
| | | default: |
| | | return; |
| | | } |
| | |
| | | case 135: |
| | | index=5; |
| | | break; |
| | | case 147: |
| | | index=6; |
| | | break; |
| | | default: |
| | | return; |
| | | } |