예제 #1
0
        public void OnEvent_P2_NumInfo(ApcmEventArgs evt)
        {
            //查看2号料位是否有料箱
            RfidStationInfo rfidStationInfo = Get <RfidStationInfo>($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P2_WORKBININFO}:DATA");

            if (rfidStationInfo.LocaNumbInfo == null)
            {
                return;
            }
            //TODO 1.读取2号位取到第几片
            int p2Num = int.Parse(((Dictionary <string, object>)evt.Data)[ApcmDevcieConfig.EVENT_P2_NUMINFO].ToString());
            //TODO 2.更新2号料表信息
            int    btsIndex = p2Num / 8;
            int    btIndex  = p2Num % 8 - 1;
            string btstr    = Convert.ToString(rfidStationInfo.LocaNumbInfo[btsIndex], 2);

            char[] chars = btstr.ToCharArray();
            for (int i = 0; i < 8; i++)
            {
                chars[btIndex] = '0';
            }
            btstr = chars.ToString();
            byte tarbt = Convert.ToByte(btstr, 2);

            rfidStationInfo.LocaNumbInfo[btsIndex] = tarbt;
            Write(ApcmDevcieConfig.PROPERTY_P2_WORKBININFO, Encoding.ASCII.GetBytes(rfidStationInfo.ToJsonStr()));
            //存放当前取第几片料
            Set($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.EVENT_P2_NUMINFO}:DATA", p2Num);
        }
예제 #2
0
        public void OnEvent_P2_WorkbinInfoReadDone(ApcmEventArgs evt)
        {
            RfidStationInfo rfidStationInfo = new RfidStationInfo();

            rfidStationInfo = (RfidStationInfo)(((Dictionary <string, object>)evt.Data)[ApcmDevcieConfig.PROPERTY_P2_WORKBININFO]);
            Set($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P2_WORKBININFO}:DATA", rfidStationInfo);
            TriggerEvent(ApcmDevcieConfig.EVENT_CUSTOM_UPDATE_P1_INFO, evt);
        }
예제 #3
0
        //读取2号位信息
        public Result PLC02ReadInfoDoneEvent(ActionArgs actionArgs)
        {
            //TODO 1.读取2号位料表信息
            RfidStationInfo rfidStationInfo = (RfidStationInfo)actionArgs.StepResult.Data;

            curentRfidStation = rfidStationInfo;
            //TODO 2.更新1号料表信息
            UpdateP1Info(rfidStationInfo);
            Logger.Device.Info($" invoke PLC02ReadInfoEvent 2号位读取数据");
            return(Result.Success());
        }
예제 #4
0
        private void UpdateP1Info(RfidStationInfo rfidStationInfo)
        {
            if (Plc01Action.curentRsInfoList.RfidStationInfos.Contains(rfidStationInfo))
            {
                Plc01Action.curentRsInfoList.RfidStationInfos.Remove(rfidStationInfo);
            }
            var       eng   = ModBusDataFactory.workFlowEngines.FirstOrDefault(x => x.ModuleName == "WFE");
            FlowBlock block = eng?._workFlow.Blocks.FirstOrDefault(v => v.Name == "PLC01UpdateInfoB");

            block.Steps[0].Value = Plc01Action.curentRsInfoList.ToJsonStr();
            eng.EnqueueBlock(block);
        }
예제 #5
0
        public void OnEVENT_CUSTOM_UPDATE_P1_INFO(ApcmEventArgs evt)
        {
            RfidStationInfoList stationInfoList = Get <RfidStationInfoList>($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P1_INFO}:DATA");
            RfidStationInfo     rfidStationInfo = Get <RfidStationInfo>($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P2_WORKBININFO}:DATA");
            int i = 0;

            foreach (RfidStationInfo info in stationInfoList.RfidStationInfos)
            {
                if (info.Equals(stationInfoList.RfidStationInfos[i]))
                {
                    OrderRfidStationInfos(i, stationInfoList);
                }
                i++;
            }
            Write(ApcmDevcieConfig.PROPERTY_P1_INFO, StructTransform.StructToBytes(stationInfoList));
        }
예제 #6
0
        public void OnEventP4_PlcInfoReadDone(ApcmEventArgs evt)
        {
            P4PlcInfo currentP4PlcInfo = new P4PlcInfo();

            currentP4PlcInfo = (P4PlcInfo)StructTransform.BytesToStruct((byte[])((Dictionary <string, object>)evt.Data)[ApcmDevcieConfig.PROPERTY_P4_PLCINFO], currentP4PlcInfo.GetType());
            //更新本地缓存
            Set($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P4_PLCINFO}:DATA", currentP4PlcInfo);
            //4号位需要更新
            Write(ApcmDevcieConfig.ACTION_P4_UPDATE, 1);
            //更新具体信息
            RfidStationInfo stationInfo = RefreshMaterialCode(currentP4PlcInfo);
            int             Spe         = Get <int>($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.ACTION_P4_WORKBINSPE}:DATA");

            if (Spe == 0)
            {
                Write(ApcmDevcieConfig.ACTION_P4_UPDATECPPINFO, StructTransform.StructToBytes(stationInfo));
            }
            else
            {
                Write(ApcmDevcieConfig.ACTION_P4_SPECPPINFO, StructTransform.StructToBytes(stationInfo));
            }
        }
예제 #7
0
        private RfidStationInfo RefreshMaterialCode(P4PlcInfo p4PlcInfo)
        {
            //获取订单的产品物料号
            string MaterialCode = Get <string>($"LD:{SysConf.KeyAssemblyLine}:MCIM:MATERIAL_CODE");

            p4PlcInfo.MaterialCode = MaterialCode;
            //更新本地缓存
            Set($"{ApcmKeyConf.DataCollection}:{ApcmDevcieConfig.PROPERTY_P4_PLCINFO}:DATA", p4PlcInfo);
            RfidStationInfo stationInfo = new RfidStationInfo();

            stationInfo.AssemblyLineId = p4PlcInfo.AssemblyLineId;
            stationInfo.UID            = p4PlcInfo.UID;
            stationInfo.MaterialCode   = p4PlcInfo.MaterialCode;
            stationInfo.BatchCode      = p4PlcInfo.BatchCode;
            stationInfo.LocaNumbInfo   = p4PlcInfo.LocaNumbInfo;
            stationInfo.McToMes        = p4PlcInfo.McToMes;
            stationInfo.MesToMc        = p4PlcInfo.MesToMc;
            stationInfo.NgStatus       = p4PlcInfo.NgStatus;
            stationInfo.ProductSnL     = p4PlcInfo.ProductSnL;
            stationInfo.Status         = p4PlcInfo.Status;
            return(stationInfo);
        }
예제 #8
0
        private byte[] InitStationInfo(ActionArgs actionArgs)
        {
            //获取package
            int package = Constant.Package;
            //模拟2号位读取料箱信息
            RfidStationInfo station = new RfidStationInfo();

            station.UID            = "Btary20190101";
            station.AssemblyLineId = "A01";
            station.BatchCode      = "Z19001-DR1108";
            //二进制字符串转byte
            string msbbitstr = "00000001";
            string lsbbitstr = "11111111";
            byte   msbbt     = Convert.ToByte(msbbitstr, 2);
            byte   lsbbt     = Convert.ToByte(lsbbitstr, 2);

            station.LocaNumbInfo = new byte[7] {
                msbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt
            };
            station.MaterialCode = "Z19001-DR1108";

            station.McToMes = new byte[2] {
                00000000, 00000000
            };
            station.MesToMc = new byte[2] {
                Convert.ToByte("00000000", 2), Convert.ToByte("00011111", 2)
            };

            station.ProductSn01 = "16122600001";
            station.ProductSn02 = "16122600002";
            station.ProductSn03 = "16122600003";
            station.ProductSn04 = "16122600004";
            station.ProductSn05 = "16122600005";
            station.ProductSn06 = "16122600006";
            station.ProductSn07 = "16122600007";
            station.ProductSn08 = "16122600008";
            station.ProductSn09 = "16122600009";
            station.ProductSn10 = "16122600010";
            station.ProductSn11 = "16122600011";
            station.ProductSn12 = "16122600012";
            station.ProductSn13 = "16122600013";
            station.ProductSn14 = "16122600014";
            station.ProductSn15 = "16122600015";
            station.ProductSn16 = "16122600016";
            station.ProductSn17 = "16122600017";
            station.ProductSn18 = "16122600018";
            station.ProductSn19 = "16122600019";
            station.ProductSn20 = "16122600020";
            station.ProductSn21 = "16122600021";
            station.ProductSn22 = "16122600022";
            station.ProductSn23 = "16122600023";
            station.ProductSn24 = "16122600024";
            station.ProductSn25 = "16122600025";
            station.ProductSn26 = "16122600026";
            station.ProductSn27 = "16122600027";
            station.ProductSn28 = "16122600028";
            station.ProductSn29 = "16122600029";
            station.ProductSn30 = "16122600030";
            station.ProductSn31 = "16122600031";
            station.ProductSn32 = "16122600032";
            station.ProductSn33 = "16122600033";
            station.ProductSn34 = "16122600034";
            station.ProductSn35 = "16122600035";
            station.ProductSn36 = "16122600036";
            station.ProductSn37 = "16122600037";
            station.ProductSn38 = "16122600038";
            station.ProductSn39 = "16122600039";
            station.ProductSn40 = "16122600040";
            station.ProductSn41 = "16122600041";
            station.ProductSn42 = "16122600042";
            station.ProductSn43 = "16122600043";
            station.ProductSn44 = "16122600044";
            station.ProductSn45 = "16122600045";
            station.ProductSn46 = "16122600046";
            station.ProductSn47 = "16122600047";
            station.ProductSn48 = "16122600048";
            station.ProductSn49 = "16122600049";

            //0 ”00“代表空箱
            //1 ”11”待加工箱体 “12”代表加工完成箱体
            station.Status = "11";
            //0  “00”正常箱体
            //1“11 产线上料不匹配”“12“ 订单冻结箱体””13“NG空箱“14”NG料箱
            station.NgStatus = "00";
            byte[] bts = new byte[1077];
            bts = Encoding.ASCII.GetBytes(station.ToJsonStr());
            return(bts);
        }
예제 #9
0
        //模拟数据
        private byte[] InitRfidStationInfos(ActionArgs actionArgs)
        {
            RfidStationInfo stationInfo1 = new RfidStationInfo();

            stationInfo1.UID            = "Btary20190101";
            stationInfo1.AssemblyLineId = "A01";
            stationInfo1.BatchCode      = "Z19001-DR1108";

            //二进制字符串转byte
            string msbbitstr = "00000001";
            string lsbbitstr = "11111111";
            byte   msbbt     = Convert.ToByte(msbbitstr, 2);
            byte   lsbbt     = Convert.ToByte(lsbbitstr, 2);

            stationInfo1.LocaNumbInfo = new byte[7] {
                msbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt
            };
            stationInfo1.MaterialCode = "Z19001-DR1108";

            stationInfo1.McToMes = new byte[2] {
                00000000, 00000000
            };
            stationInfo1.MesToMc = new byte[2] {
                Convert.ToByte("00000000", 2), Convert.ToByte("00011111", 2)
            };

            stationInfo1.ProductSn01 = "16122600001";
            stationInfo1.ProductSn02 = "16122600002";
            stationInfo1.ProductSn03 = "16122600003";
            stationInfo1.ProductSn04 = "16122600004";
            stationInfo1.ProductSn05 = "16122600005";
            stationInfo1.ProductSn06 = "16122600006";
            stationInfo1.ProductSn07 = "16122600007";
            stationInfo1.ProductSn08 = "16122600008";
            stationInfo1.ProductSn09 = "16122600009";
            stationInfo1.ProductSn10 = "16122600010";
            stationInfo1.ProductSn11 = "16122600011";
            stationInfo1.ProductSn12 = "16122600012";
            stationInfo1.ProductSn13 = "16122600013";
            stationInfo1.ProductSn14 = "16122600014";
            stationInfo1.ProductSn15 = "16122600015";
            stationInfo1.ProductSn16 = "16122600016";
            stationInfo1.ProductSn17 = "16122600017";
            stationInfo1.ProductSn18 = "16122600018";
            stationInfo1.ProductSn19 = "16122600019";
            stationInfo1.ProductSn20 = "16122600020";
            stationInfo1.ProductSn21 = "16122600021";
            stationInfo1.ProductSn22 = "16122600022";
            stationInfo1.ProductSn23 = "16122600023";
            stationInfo1.ProductSn24 = "16122600024";
            stationInfo1.ProductSn25 = "16122600025";
            stationInfo1.ProductSn26 = "16122600026";
            stationInfo1.ProductSn27 = "16122600027";
            stationInfo1.ProductSn28 = "16122600028";
            stationInfo1.ProductSn29 = "16122600029";
            stationInfo1.ProductSn30 = "16122600030";
            stationInfo1.ProductSn31 = "16122600031";
            stationInfo1.ProductSn32 = "16122600032";
            stationInfo1.ProductSn33 = "16122600033";
            stationInfo1.ProductSn34 = "16122600034";
            stationInfo1.ProductSn35 = "16122600035";
            stationInfo1.ProductSn36 = "16122600036";
            stationInfo1.ProductSn37 = "16122600037";
            stationInfo1.ProductSn38 = "16122600038";
            stationInfo1.ProductSn39 = "16122600039";
            stationInfo1.ProductSn40 = "16122600040";
            stationInfo1.ProductSn41 = "16122600041";
            stationInfo1.ProductSn42 = "16122600042";
            stationInfo1.ProductSn43 = "16122600043";
            stationInfo1.ProductSn44 = "16122600044";
            stationInfo1.ProductSn45 = "16122600045";
            stationInfo1.ProductSn46 = "16122600046";
            stationInfo1.ProductSn47 = "16122600047";
            stationInfo1.ProductSn48 = "16122600048";
            stationInfo1.ProductSn49 = "16122600049";

            //0 ”00“代表空箱
            //1 ”11”待加工箱体 “12”代表加工完成箱体
            stationInfo1.Status = "11";
            //0  “00”正常箱体
            //1“11 产线上料不匹配”“12“ 订单冻结箱体””13“NG空箱“14”NG料箱
            stationInfo1.NgStatus = "00";

            RfidStationInfo stationInfo2 = new RfidStationInfo();

            stationInfo2.UID            = "Btary20190102";
            stationInfo2.AssemblyLineId = "A01";
            stationInfo2.BatchCode      = "Z19001-DR1108";

            stationInfo2.LocaNumbInfo = new byte[7] {
                msbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt
            };
            stationInfo2.MaterialCode = "Z19001-DR1108";

            stationInfo2.McToMes = new byte[2] {
                00000000, 00000000
            };
            stationInfo2.MesToMc = new byte[2] {
                Convert.ToByte("00000000", 2), Convert.ToByte("00011111", 2)
            };

            stationInfo2.ProductSn01 = "16122600001";
            stationInfo2.ProductSn02 = "16122600002";
            stationInfo2.ProductSn03 = "16122600003";
            stationInfo2.ProductSn04 = "16122600004";
            stationInfo2.ProductSn05 = "16122600005";
            stationInfo2.ProductSn06 = "16122600006";
            stationInfo2.ProductSn07 = "16122600007";
            stationInfo2.ProductSn08 = "16122600008";
            stationInfo2.ProductSn09 = "16122600009";
            stationInfo2.ProductSn10 = "16122600010";
            stationInfo2.ProductSn11 = "16122600011";
            stationInfo2.ProductSn12 = "16122600012";
            stationInfo2.ProductSn13 = "16122600013";
            stationInfo2.ProductSn14 = "16122600014";
            stationInfo2.ProductSn15 = "16122600015";
            stationInfo2.ProductSn16 = "16122600016";
            stationInfo2.ProductSn17 = "16122600017";
            stationInfo2.ProductSn18 = "16122600018";
            stationInfo2.ProductSn19 = "16122600019";
            stationInfo2.ProductSn20 = "16122600020";
            stationInfo2.ProductSn21 = "16122600021";
            stationInfo2.ProductSn22 = "16122600022";
            stationInfo2.ProductSn23 = "16122600023";
            stationInfo2.ProductSn24 = "16122600024";
            stationInfo2.ProductSn25 = "16122600025";
            stationInfo2.ProductSn26 = "16122600026";
            stationInfo2.ProductSn27 = "16122600027";
            stationInfo2.ProductSn28 = "16122600028";
            stationInfo2.ProductSn29 = "16122600029";
            stationInfo2.ProductSn30 = "16122600030";
            stationInfo2.ProductSn31 = "16122600031";
            stationInfo2.ProductSn32 = "16122600032";
            stationInfo2.ProductSn33 = "16122600033";
            stationInfo2.ProductSn34 = "16122600034";
            stationInfo2.ProductSn35 = "16122600035";
            stationInfo2.ProductSn36 = "16122600036";
            stationInfo2.ProductSn37 = "16122600037";
            stationInfo2.ProductSn38 = "16122600038";
            stationInfo2.ProductSn39 = "16122600039";
            stationInfo2.ProductSn40 = "16122600040";
            stationInfo2.ProductSn41 = "16122600041";
            stationInfo2.ProductSn42 = "16122600042";
            stationInfo2.ProductSn43 = "16122600043";
            stationInfo2.ProductSn44 = "16122600044";
            stationInfo2.ProductSn45 = "16122600045";
            stationInfo2.ProductSn46 = "16122600046";
            stationInfo2.ProductSn47 = "16122600047";
            stationInfo2.ProductSn48 = "16122600048";
            stationInfo2.ProductSn49 = "16122600049";

            //0 ”00“代表空箱
            //1 ”11”待加工箱体 “12”代表加工完成箱体
            stationInfo2.Status = "11";
            //0  “00”正常箱体
            //1“11 产线上料不匹配”“12“ 订单冻结箱体””13“NG空箱“14”NG料箱
            stationInfo2.NgStatus = "00";

            RfidStationInfo stationInfo3 = new RfidStationInfo();

            stationInfo3.UID            = "Btary20190103";
            stationInfo3.AssemblyLineId = "A01";
            stationInfo3.BatchCode      = "Z19001-DR1108";

            stationInfo3.LocaNumbInfo = new byte[7] {
                msbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt, lsbbt
            };
            stationInfo3.MaterialCode = "Z19001-DR1108";

            stationInfo3.McToMes = new byte[2] {
                00000000, 00000000
            };
            stationInfo3.MesToMc = new byte[2] {
                Convert.ToByte("00000000", 2), Convert.ToByte("00011111", 2)
            };

            stationInfo3.ProductSn01 = "16122600001";
            stationInfo3.ProductSn02 = "16122600002";
            stationInfo3.ProductSn03 = "16122600003";
            stationInfo3.ProductSn04 = "16122600004";
            stationInfo3.ProductSn05 = "16122600005";
            stationInfo3.ProductSn06 = "16122600006";
            stationInfo3.ProductSn07 = "16122600007";
            stationInfo3.ProductSn08 = "16122600008";
            stationInfo3.ProductSn09 = "16122600009";
            stationInfo3.ProductSn10 = "16122600010";
            stationInfo3.ProductSn11 = "16122600011";
            stationInfo3.ProductSn12 = "16122600012";
            stationInfo3.ProductSn13 = "16122600013";
            stationInfo3.ProductSn14 = "16122600014";
            stationInfo3.ProductSn15 = "16122600015";
            stationInfo3.ProductSn16 = "16122600016";
            stationInfo3.ProductSn17 = "16122600017";
            stationInfo3.ProductSn18 = "16122600018";
            stationInfo3.ProductSn19 = "16122600019";
            stationInfo3.ProductSn20 = "16122600020";
            stationInfo3.ProductSn21 = "16122600021";
            stationInfo3.ProductSn22 = "16122600022";
            stationInfo3.ProductSn23 = "16122600023";
            stationInfo3.ProductSn24 = "16122600024";
            stationInfo3.ProductSn25 = "16122600025";
            stationInfo3.ProductSn26 = "16122600026";
            stationInfo3.ProductSn27 = "16122600027";
            stationInfo3.ProductSn28 = "16122600028";
            stationInfo3.ProductSn29 = "16122600029";
            stationInfo3.ProductSn30 = "16122600030";
            stationInfo3.ProductSn31 = "16122600031";
            stationInfo3.ProductSn32 = "16122600032";
            stationInfo3.ProductSn33 = "16122600033";
            stationInfo3.ProductSn34 = "16122600034";
            stationInfo3.ProductSn35 = "16122600035";
            stationInfo3.ProductSn36 = "16122600036";
            stationInfo3.ProductSn37 = "16122600037";
            stationInfo3.ProductSn38 = "16122600038";
            stationInfo3.ProductSn39 = "16122600039";
            stationInfo3.ProductSn40 = "16122600040";
            stationInfo3.ProductSn41 = "16122600041";
            stationInfo3.ProductSn42 = "16122600042";
            stationInfo3.ProductSn43 = "16122600043";
            stationInfo3.ProductSn44 = "16122600044";
            stationInfo3.ProductSn45 = "16122600045";
            stationInfo3.ProductSn46 = "16122600046";
            stationInfo3.ProductSn47 = "16122600047";
            stationInfo3.ProductSn48 = "16122600048";
            stationInfo3.ProductSn49 = "16122600049";

            //0 ”00“代表空箱
            //1 ”11”待加工箱体 “12”代表加工完成箱体
            stationInfo3.Status = "11";
            //0  “00”正常箱体
            //1“11 产线上料不匹配”“12“ 订单冻结箱体””13“NG空箱“14”NG料箱
            stationInfo3.NgStatus = "00";

            List <RfidStationInfo> rfidStationInfos = new List <RfidStationInfo>();

            rfidStationInfos.Add(stationInfo1);
            rfidStationInfos.Add(stationInfo2);
            rfidStationInfos.Add(stationInfo3);
            byte[] bts1 = new byte[1] {
                01
            };
            byte[] bts2 = new byte[1] {
                02
            };
            byte[] bts3 = new byte[1] {
                03
            };
            byte[] bts4 = Encoding.Unicode.GetBytes(rfidStationInfos.ToJsonStr());
            byte[] bts5 = new byte[bts1.Length + bts2.Length + bts3.Length + bts4.Length];
            bts1.CopyTo(bts5, 0);
            bts2.CopyTo(bts5, bts1.Length);
            bts3.CopyTo(bts5, bts1.Length + bts2.Length);
            bts4.CopyTo(bts5, bts1.Length + bts2.Length + bts3.Length);
            return(bts5);
        }