Exemple #1
0
        protected string ReadString(TCustomTKDevice device, ArrayCharOfTag tag)
        {
            byte[] buffer = new byte[tag.Length];
            int    resNo  =
                CS7TcpClient.ReadString(
                    plcHandle,
                    (int)tag.DB_Type,
                    device.DBNumber,
                    tag.DB_Offset,
                    (short)tag.Length,
                    buffer);

            return(Encoding.Default.GetString(buffer));
        }
 public WIPStation()
 {
     WIP_Station_LeafID            = new DWordOfTag();
     Product_Number                = new ArrayCharOfTag(40);
     WIP_Code                      = new ArrayCharOfTag(20);
     WIP_ID_Type_Code              = new ArrayCharOfTag(2);
     WIP_ID_Code                   = new ArrayCharOfTag(80);
     WIP_Move_In                   = new BoolOfTag();
     Production_Start              = new BoolOfTag();
     Production_End                = new BoolOfTag();
     WIP_Move_Out                  = new BoolOfTag();
     Change_Over_Start             = new BoolOfTag();
     Change_Over_End               = new BoolOfTag();
     Production_Pause              = new BoolOfTag();
     Production_Restart            = new BoolOfTag();
     Request_For_Poka_Yoke         = new BoolOfTag();
     Move_To_MRB_Operation         = new BoolOfTag();
     Request_For_Routing           = new BoolOfTag();
     Request_For_ID_Binding        = new BoolOfTag();
     Trigger_Equipment_Fail_Andon  = new BoolOfTag();
     Trigger_Quality_Problem_Andon = new BoolOfTag();
     Stagnation_Warnning           = new BoolOfTag();
     Serial_Number_Request         = new BoolOfTag();
     Label_ELements_Request        = new BoolOfTag();
     Label_Print_Request           = new BoolOfTag();
     Label_Reprint_Request         = new BoolOfTag();
     Packing_Succeeded             = new BoolOfTag();
     Is_OK_WIP_Onto_Line_Station   = new BoolOfTag();
     Is_NG_WIP_Onto_Line_Station   = new BoolOfTag();
     Scheduled_Production_Down     = new BoolOfTag();
     Error_proofing_detection      = new BoolOfTag();
     Reserved_Signal_28            = new BoolOfTag();
     Reserved_Signal_29            = new BoolOfTag();
     Reserved_Signal_30            = new BoolOfTag();
     Reserved_Signal_31            = new BoolOfTag();
     Reserved_Signal_32            = new BoolOfTag();
     Poka_Yoke_Result              = new ByteOfTag();
     Operation_Conclusion          = new ByteOfTag();
 }
Exemple #3
0
        /// <summary>
        /// 回写到 PLC 中
        /// </summary>
        private void WritebackToPLC(TCustomTKDevice device, CustomTagTest tag)
        {
            if (tag is BoolOfTag)
            {
                BoolOfTag ltag = tag as BoolOfTag;

                CS7TcpClient.WriteBool(
                    plcHandle,
                    0x84,
                    device.DBNumber,
                    ltag.DB_Offset,
                    ltag.Position,
                    Convert.ToUInt16(ltag.Value));
            }
            else if (tag is ByteOfTag)
            {
                ByteOfTag ltag = tag as ByteOfTag;

                CS7TcpClient.WriteByte(
                    plcHandle,
                    0x84,
                    device.DBNumber,
                    ltag.DB_Offset,
                    ltag.Value);
            }
            else if (tag is WordOfTag)
            {
                WordOfTag ltag = tag as WordOfTag;

                CS7TcpClient.WriteWord(
                    plcHandle,
                    0x84,
                    device.DBNumber,
                    ltag.DB_Offset,
                    (uint)ltag.Value);
            }
            else if (tag is DWordOfTag)
            {
                DWordOfTag ltag = tag as DWordOfTag;

                CS7TcpClient.WriteDWord(
                    plcHandle,
                    0x84,
                    device.DBNumber,
                    ltag.DB_Offset,
                    (uint)ltag.Value);
            }
            else if (tag is ArrayCharOfTag)
            {
                ArrayCharOfTag ltag = tag as ArrayCharOfTag;

                string temp = ltag.Value.PadRight(ltag.Length, ' ').Substring(0, ltag.Length);
                CS7TcpClient.WriteBlockAsByte(
                    plcHandle,
                    0x84,
                    device.DBNumber,
                    ltag.DB_Offset,
                    ltag.Length,
                    Encoding.Default.GetBytes(temp));
            }
        }