public CPortData PortDataConvert(string strUnitConvertMessage, CPortData cPortData, ushort[] MelsecNetReadGlassData) { CPortData portData = cPortData; //Melsec 35 Word Data //string glassID = null; //string glassSpecificData = null; if (strUnitConvertMessage == "portStatus") { portData.PortStatus = (enumPortStatus2)Enum.Parse(typeof(enumPortStatus2), MelsecNetReadGlassData[0] == 0 ? "6" : MelsecNetReadGlassData[0].ToString()); } portData.CassetteStatus = Convert.ToInt32(MelsecNetReadGlassData[1]); portData.CassetteIndex = Convert.ToInt32(MelsecNetReadGlassData[2]); string portCstID = string.Empty; string portIDSum = null; for (int i = 3; i < 11; i++) { char _convertChar00 = Convert.ToChar(Convert.ToInt32(MelsecNetReadGlassData[i]) & 0xff); char _convertChar01 = Convert.ToChar(((Convert.ToInt32(MelsecNetReadGlassData[i]) & 0xff00)) >> 8); portIDSum = _convertChar01.ToString() + _convertChar00.ToString(); portCstID += portIDSum; } string[] strCstID = portCstID.Split('\0'); portData.CassetteID = strCstID[0].ToString(); portData.JobCountinCassette = Convert.ToInt16(MelsecNetReadGlassData[11]); portData.CassetteCompletedReasonCode = Convert.ToInt16(MelsecNetReadGlassData[12]); ushort[] portJobSlot = new ushort[18]; int count = 0; for (int j = 13; j < 31; j++) { portJobSlot[count] = MelsecNetReadGlassData[j]; count++; } string jobExistenceSlotTemp = ""; try { foreach (ushort item in portJobSlot) { string charTemp = CDataConvert.HexToBitString(item.ToString("X"), 4); jobExistenceSlotTemp += charTemp; } jobExistenceSlotTemp = jobExistenceSlotTemp.Replace('0', 'X'); jobExistenceSlotTemp = jobExistenceSlotTemp.Replace('1', 'O'); portData.JobExistenceSlot = jobExistenceSlotTemp; portData.LoadingCassetteType = Convert.ToInt16(MelsecNetReadGlassData[31]); portData.SlotStatusChanged = Convert.ToInt16(MelsecNetReadGlassData[32]); portData.SlotStatusInOut = Convert.ToInt16(MelsecNetReadGlassData[33]); } catch (Exception ex) { Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } return(portData); }