コード例 #1
0
        public static void DoEntrySideJobs(MachinesDTO senderMachine)
        {
            productId        = random.Next(1, 30);
            productionlineId = random.Next(1, 22);
            paletteBarcode   = "palettebarcode" + productId.ToString();
            boxquantity      = random.Next(50, 100);
            lot   = "lot" + productId.ToString();
            batch = "BT382020";

            easyModbusCommunication = new EasyModbusCommunication(senderMachine.IpAddress, 502);
            easyModbusCommunication.WriteToPLC(0, new int[] { 100 });//plcden ye done göndermesi için

            //Console.SetOut(TextWriter.Null);
            var rd = ReadConveyorPLC(senderMachine);
            //Console.SetOut(TextWriter.Synchronized(writer));

            var id = easyModbusCommunication.ConvertRegistersToInt(new int[] { rd.MW202, rd.MW203 });

            if (rd.MW200 == (int)Plc_Task.DONESUCCESSFULLY)
            {
                var pnId = InsertProductionNotification();//plc den gelen datayla beslenecek gibi düşün
                CreateTaskForPalette(paletteBarcode, senderMachine, pnId /*obj den gelen bir data veri barkod üzerine sistem kayıtlarını oluştur.*/);
            }

            //WriteDataToPlc();
        }
コード例 #2
0
        public static PlcCommunicationReadedData ReadShuttlePLC(MachinesDTO communicationMachine)
        {
            easyModbusCommunication = new EasyModbusCommunication(communicationMachine.IpAddress, 502);

            var readedData = easyModbusCommunication.ReadFromPLC(0, 40);

            var rd = ObjectAssign.IntArrayToObject_RD(readedData, communicationMachine);

            readedDataAcces.InsertReadedData(rd);

            return(rd);
        }
コード例 #3
0
        internal static void DoEntrySideJobs(MachinesDTO senderMachine)
        {
            //simule ok
            easyModbusCommunication = new EasyModbusCommunication(senderMachine.IpAddress, 502);
            easyModbusCommunication.WriteToPLC(0, new int[] { 100 });//plcden ye done göndermesi için
            //


            var rd = ReadAsrsPLC(senderMachine);
            var id = easyModbusCommunication.ConvertRegistersToInt(new int[] { rd.MW202, rd.MW203 });


            if (id > 0 && rd.MW200 == (int)Plc_Task.DONESUCCESSFULLY)
            {
                log.Info(id);


                var incomingTask = machineTasksData.GetMachineTaskById(id);
                var prodNotif    = productionNotificationData.GetProductionNotificationById(incomingTask.ProductNotificationId);

                if (!incomingTask.IsCompleted)
                {
                    if (incomingTask.TaskType == (int)TaskType.CTA)
                    {
                        palletsAtAddressesData.InsertPalettesAtAddresses(incomingTask, prodNotif);
                        addressData.AddressesChangeFirstRowInfo(incomingTask.TargetAddress, false, incomingTask.EndTime, Location.WH_IN);
                        machineTasksData.CreateTaskForFirstRowPalette(incomingTask);
                    }
                    else if (incomingTask.TaskType == (int)TaskType.CTB)
                    {
                        buffersData.UpdateBufferWithPalette(incomingTask); //buffer transaction logu tablosu oluşturup tutulmalı mı?
                        machineTasksData.CreateTaskForBufferPalette(incomingTask);
                    }
                    else if (incomingTask.TaskType == (int)TaskType.BTA) //TODO:check
                    {
                        buffersData.UpdateBufferWithOutPalette(incomingTask);
                        palletsAtAddressesData.InsertPalettesAtAddresses(incomingTask, prodNotif);
                        addressData.AddressesChangeFirstRowInfo(incomingTask.TargetAddress, false, incomingTask.EndTime, Location.WH_IN);
                        machineTasksData.CreateTaskForFirstRowPalette(incomingTask);
                    }

                    machineTasksData.UpdateMachineTaskWithPlcCompletedById(id);
                }


                //task ata
                AssignTask(senderMachine);
            }
            else if (rd.MW200 == (int)Plc_Task.DONEWITHERROR) // hata kontrolu
            {
                //yarım iş??
            }
        }
コード例 #4
0
        public static bool WriteShuttlePLC(MachinesDTO communicationMachine, TaskDTO taskDTO)
        {
            var idReg = easyModbusCommunication.ConvertIntToRegisters(taskDTO.taskId);
            var xReg  = easyModbusCommunication.ConvertIntToRegisters(taskDTO.X);
            var z1Reg = easyModbusCommunication.ConvertIntToRegisters(taskDTO.Z1);
            var z2Reg = easyModbusCommunication.ConvertIntToRegisters(taskDTO.Z2);
            var gReg  = easyModbusCommunication.ConvertIntToRegisters(taskDTO.G);

            //task verisine göre plc write datası oluşturup yazılması gerekie.
            PlcCommunicationWritedData wd = new PlcCommunicationWritedData();

            wd.MW100 = 0; //tetik

            wd.MW102 = idReg[0];
            wd.MW103 = idReg[1];

            wd.MW109 = (int)Plc_Asrs.GO;

            wd.MW110 = xReg[0];
            wd.MW111 = xReg[1];

            wd.MW112 = z1Reg[0];
            wd.MW113 = z1Reg[1];

            wd.MW114 = z2Reg[0];
            wd.MW115 = z2Reg[1];

            wd.MW116 = gReg[0];
            wd.MW117 = gReg[1];

            wd.MachineCode = communicationMachine.Code;
            wd.RecordDate  = DateTime.Now;

            easyModbusCommunication = new EasyModbusCommunication(communicationMachine.IpAddress, 502);


            if (easyModbusCommunication.WriteToPLC(0, ArrayAssign.WritedDataToIntArray(wd)))//plc ye yazdıysa
            {
                writedDataAcces.InsertWritedData(wd);
                return(true);
            }
            else
            {
                log.Error($"ASRS Plc Write Error. TaskId : {taskDTO.taskId}");
                return(false);
            }
        }
コード例 #5
0
        private static void AssignTask(MachinesDTO communicationMachine, PlcCommunicationReadedData rd)
        {
            var shuttle = shuttlesData.GetShuttleByCode(communicationMachine.Code);

            if (shuttle.Assignment == ShuttleAssign.OPTIMIZATION && shuttle.Status == Enum.GetName(typeof(SysStatus), SysStatus.READY))
            {
                //simule ok
                easyModbusCommunication = new EasyModbusCommunication(communicationMachine.IpAddress, 502);
                easyModbusCommunication.WriteToPLC(48, new int[] { 75 }); //plcden ye done göndermesi için
                                                                          //

                //şarjı varsa başka tüpe taşı ve optimizasyon başlat
                if (rd.MW248 > 10)//TODO: make parametric
                {
                    CreateOptimizationTasks(communicationMachine, shuttle);
                }
                else
                {
                    //şarja gönder, başka mekiği optimizasyon için ata, taşı, optimizasyon başlat
                    CreateChargeTasks(communicationMachine, shuttle);
                    shuttlesData.SelectNewOptimizationShuttle(); //yeni shuttle döndürür yeni optimizasyon mekiği için iş atayabilir yada mekikten sinyal gelince normal işleyişe göre çalışır
                }

                //şarjı yoksa şarja taşı, başka mekiği optimizasyon olarak ata, bulunduğu yeri yada başka adresi optimize görevi yaz (önce taşı sonra yaz!)
            }


            //TODO: optimization task seçmede kontrolet
            TaskDTO taskDTO = machineTasksData.GetTaskDataForShuttle(communicationMachine);

            if (taskDTO != null && WriteShuttlePLC(communicationMachine, taskDTO))
            {
                log.Info("shuttle assign id: " + taskDTO.taskId);
                machineTasksData.UpdateMachineTaskWithPlcSentById(taskDTO.taskId);
                machineTasksData.UpdateMachineTaskWithMachineCodeById(taskDTO.taskId, communicationMachine.Code);
            }
            else
            {
                CheckNeedShuttleAddressesAndCreateTaskForIt(communicationMachine);
            }
        }
コード例 #6
0
        public static void ReadStrechMachinePLC(MachinesDTO communicationMachine)
        {
            easyModbusCommunication = new EasyModbusCommunication(communicationMachine.IpAddress, 502);
            var readedData = easyModbusCommunication.ReadFromPLC(0, 40);

            var obj = ObjectAssign.IntArrayToObject_RD(readedData, communicationMachine);

            readedDataAcces.InsertReadedData(obj);


            if (true /*obj.MW200 == 0*/)
            {
                int productId = 0;//plc okuma sonrası netleşecek alanlar belki barcoda göre gidip tekrar sorgu atması gerekecek

                InsertPreProductionNotification(new PreProductionNotification
                {
                    ProductId           = 0,
                    PaletteBarcode      = "",
                    BatchNo             = "BT382020",
                    PreNotificationTime = DateTime.Now,
                    Lot = "",
                    ReadOnTheConveyor = false
                });

                //insert başarılı ve bufferda aynı üründen varsa adresinin tüp ağzında da aynı üründen varsa
                //adrese mekik shuttle taşıma işi oluştur

                var address = addressData.GetFirstRowIsEmptyByProductId(productId);
                var buffer  = buffersData.GetPaletteInfoByProductId(productId);

                if (!address.FirstRowIsEmpty && buffer.Id > 0)
                {
                    CreateTasksForShuttleRelocation(address.Code);
                }
            }
        }
コード例 #7
0
        internal static void DoShuttleJobs(MachinesDTO senderMachine)
        {
            //simule ok
            easyModbusCommunication = new EasyModbusCommunication(senderMachine.IpAddress, 502);
            easyModbusCommunication.WriteToPLC(0, new int[] { 100, 0 });//plcden ye done göndermesi için
            //


            var rd = ReadShuttlePLC(senderMachine);
            var id = easyModbusCommunication.ConvertRegistersToInt(new int[] { rd.MW202, rd.MW203 });

            if (id > 0 && rd.MW200 == (int)Plc_Task.DONESUCCESSFULLY)
            {
                int distance = 0;

                var incomingTask = machineTasksData.GetMachineTaskById(id);

                if (incomingTask.IsCompleted == false)
                {
                    if (incomingTask.TaskType == (int)TaskType.ShOPT)
                    {
                        //Tüpteki paletlerin bilgileri distancetoexit bilgileri entry date e göre güncelle isinside true olanlar
                        palletsAtAddressesData.OptimizationUpdatePalletsAtAddresses(incomingTask.TargetAddress);

                        machineTasksData.UpdateMachineTaskWithPlcCompletedById(id);
                    }
                    else if (incomingTask.TaskType == (int)TaskType.ShINSERT) //asrs koyduktan sonra oluşacak
                    {
                        //asrs koyduğunda oluştu burda güncellenmeli
                        //Tüp ağzındaki paleti palletsataddressde güncelle(distance to exit),
                        palletsAtAddressesData.UpdatePalletsAtAddressWithShInsert(incomingTask, distance);

                        //adrsin tüp agzı bilgisini güncelle boş olarak
                        addressData.AddressesChangeFirstRowInfo(incomingTask.TargetAddress, true, null, Location.WH_IN);


                        machineTasksData.UpdateMachineTaskWithPlcCompletedById(id);
                    }
                    else if (incomingTask.TaskType == (int)TaskType.ShTAKEOUT) //orderdetail a göre veye asrs buraya mekik taşıdıktan sonra oluşacak??
                    {
                        //Tüp içindeki en öndeki paleti palletsataddressde güncelle(sadece distance bilgisi  ),
                        palletsAtAddressesData.UpdatePalletsAtAddressWithShTakeOut(incomingTask);

                        //adresin tüp agzı bilgisini güncelle dolu olarak
                        addressData.AddressesChangeFirstRowInfo(incomingTask.TargetAddress, false, DateTime.Now, Location.WH_OUT);

                        machineTasksData.UpdateMachineTaskWithPlcCompletedById(id);
                    }
                    else if (incomingTask.TaskType == (int)TaskType.ShATA)
                    {
                        //asrs de bu adım asrs için var burada shuttle için yapması gereken birşey olup olmadığı kontrol edilebilir
                        //
                        machineTasksData.UpdateMachineTaskWithPlcCompletedById(id);
                    }
                    else
                    {
                        //hata logu vs try catch
                    }
                }

                AssignTask(senderMachine, rd);
            }
        }