コード例 #1
0
        public void Connect(string cname, int stationNumber)
        {
            ActUtlTypeClass tapi = new ActUtlTypeClass();

            Open(ref tapi, stationNumber, cname);
            qList.Add(cname, tapi);
        }
コード例 #2
0
        public void Open(ref ActUtlTypeClass api, int stationNumber, string cName)
        {
            api.ActLogicalStationNumber = stationNumber;
            int iReturnCode;

            iReturnCode = api.Open();
            if (iReturnCode != 0)
            {
                throw new Exception(string.Format("打开{2:s}站号{0:d}错误 0x{1:x8}", stationNumber, iReturnCode, cName));
            }
        }
コード例 #3
0
ファイル: PortPLC_MITNew.cs プロジェクト: 0000duck/TW_CT2
        //打开通信接口
        public override bool OpenPLC(out string error)
        {
            error = "";
            try
            {
#if MIT
                //如果为Null,实例化对象
                if (lpcom_ReferencesUtlType == null)
                {
                    lpcom_ReferencesUtlType  = new ActUtlTypeClass();
                    lpcom_ReferencesProgType = new ActProgTypeClass();
                }

                lpcom_ReferencesUtlType.ActLogicalStationNumber = 01; //逻辑站号
                int intState = lpcom_ReferencesUtlType.Open();
                if (intState == 0)
                {
                    return(true);
                }
                else
                {
                    Log.L_I.WriteError(NameClass, intState.ToString());
                }
                //如果打开失败,重新打开一次
                intState = lpcom_ReferencesUtlType.Open();
                if (intState == 0)
                {
                    return(true);
                }
#endif
                return(false);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }