コード例 #1
0
 public static int[] WritedDataToIntArray(PlcCommunicationWritedData data)
 {
     return(new int[] {
         data.MW100,
         data.MW101,
         data.MW102,
         data.MW103,
         data.MW104,
         data.MW105,
         data.MW106,
         data.MW107,
         data.MW108,
         data.MW109,
         data.MW110,
         data.MW111,
         data.MW112,
         data.MW113,
         data.MW114,
         data.MW115,
         data.MW116,
         data.MW117,
         data.MW118,
         data.MW119,
         data.MW120,
         data.MW121,
         data.MW122,
         data.MW123,
         data.MW124,
         data.MW125,
         data.MW126,
         data.MW127,
         data.MW128,
         data.MW129,
         data.MW130,
         data.MW131,
         data.MW132,
         data.MW133,
         data.MW134,
         data.MW135,
         data.MW136,
         data.MW137,
         data.MW138,
         data.MW139,
         data.MW140,
         data.MW141,
         data.MW142,
         data.MW143,
         data.MW144,
         data.MW145,
         data.MW146,
         data.MW147,
         data.MW148,
         data.MW149
     });
 }
コード例 #2
0
        public long InsertWritedData(PlcCommunicationWritedData wd)
        {
            long identity;

            using (var conn = new SqlConnection(conStr))
            {
                conn.Open();
                identity = conn.Insert(wd);
                conn.Close();
            }
            return(identity);
        }
コード例 #3
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);
            }
        }