/// <summary> /// (인증필요)AB Plc 객체 생성. /// </summary> /// <param name="ePlcType">PLC종류 : AB</param> /// <param name="strIPAddress">Remote Gateway를 사용 할 경우 ip address 입력, local gateway 사용 시 공백 입력</param> /// <param name="strProgramID">local : 'RSLinx OPC Server' / 원격 : 'RSLinx Remote OPC Server'</param> /// <param name="strGroupName">Item Group명 : 미입력시'Group'으로 설정 </param> /// <param name="strTopicName">설정되 Topic 이릅</param> /// <param name="intUpdateRate">Value 업데이스 시간(ms)</param> /// <param name="strLogFileName">기록을 쌓을 로그 파일(프로그램 폴더 \Log_PlcModule 폴더에 기록.</param> public clsPLCModule(enPlcType ePlcType, string strIPAddress, string strProgramID, string strGroupName, string strTopicName, int intUpdateRate, string strLogFileName) { enPLCType = ePlcType; try { #if (ABPLC_A || ABPLC_B) if (ePlcType == enPlcType.AB) { clsPLC = new clsABPLC(strIPAddress, strProgramID, strGroupName, strTopicName, intUpdateRate); } else { throw new Exception(string.Format("AB PLC 생성자의 Type이 잘 못 되었니다.(생성 요청 타입 : {0})", enPLCType.ToString())); } #endif enPLCType = ePlcType; InitClass(strLogFileName); } catch (Exception ex) { ProcException(ex); throw ex; } }
/// <summary> /// Melsec A/Q plc 객체 생성 /// </summary> /// <param name="ePlcType"></param> /// <param name="?"></param> /// <param name="intPort"></param> /// <param name="strLogFileName"></param> public clsPLCModule(enPlcType ePlcType, string strIPAddress, int intPort, string strDeviceType, string strLogFileName) { try { enPLCType = ePlcType; if (ePlcType == enPlcType.Melsec_A) { clsPLC = new clsMelsecA(strIPAddress, intPort, strDeviceType); } else if (ePlcType == enPlcType.Melsec_Q) { clsPLC = new clsMelsecQ(strIPAddress, intPort, strDeviceType); } else { throw new Exception(string.Format("Melsec A/Q 생성자의 Type이 잘 못 되었니다.(생성 요청 타입 : {0})", enPLCType.ToString())); } InitClass(strLogFileName); } catch (Exception ex) { ProcException(ex); } }
public clsLS_XG(enPlcType plcType, string strIPAddress, int intPort, string _strDeviceType) : base(true) { switch (PlcType) { case enPlcType.LS_XGI: _c_header[12] = 0xa4; break; case enPlcType.LS_XGT: _c_header[12] = 0xa0; break; default: throw new Exception("clsLG_XG 모듈은 LGI, LGT 타입만 생성 가능합니다."); break; } Comm.Received += new PLCSocket.Receive(this.Received); Comm.strServerIP = strIPAddress; Comm.iPort = intPort; delStart = new delScanThread(Start_PLCScan); }
/// <summary> /// (인증필요)Melsec A/Q plc 객체 생성 /// </summary> /// <param name="ePlcType">PLC종류 : Melsec_A or Melsec_Q</param> /// <param name="strIPAddress">IP Address</param> /// <param name="intPort">Port No</param> /// <param name="strLogFileName">기록을 쌓을 로그 파일(프로그램 폴더 \Log_PlcModule 폴더에 기록.</param> public clsPLCModule(enPlcType ePlcType, string strIPAddress, int intPort, string strDeviceType, string strLogFileName) { try { string strLogDirectory = System.Windows.Forms.Application.StartupPath + @"\Log_PlcModule\"; Set_Module(ePlcType, strIPAddress, intPort, strDeviceType, strLogDirectory, strLogFileName); } catch (Exception ex) { ProcException(ex); throw ex; } }
internal void Set_Module(enPlcType ePlcType, string strIPAddress, int intPort, string strDeviceType, string LogFolderPath, string strLogFileName) { if (plc != null) { return; } try { enPLCType = ePlcType; IPAddress = strIPAddress; Port = intPort; switch (ePlcType) { /* * case enPlcType.Melsec_A: * plc = new PLCModule.PLCModules.clsMelsecA(strIPAddress, intPort, strDeviceType); * break; * * case enPlcType.Melsec_Q: * plc = new PLCModule.PLCModules.clsMelsecQ(strIPAddress, intPort, strDeviceType); * break; * * case enPlcType.LS_XGT: * plc = new PLCModule.PLCModules.clsLS_XGT(strIPAddress, intPort, strDeviceType); * break; * * case enPlcType.LS_XGI: * plc = new PLCModule.PLCModules.clsLS_XGI(strIPAddress, intPort, strDeviceType); * break; */ case enPlcType.TEST: plc = new TEST_PLC(strIPAddress, intPort, strDeviceType); break; default: throw new Exception(string.Format("Melsec A/Q 생성자의 Type이 잘 못 되었니다.(생성 요청 타입 : {0})", enPLCType.ToString())); } InitClass(LogFolderPath, strLogFileName); } catch (Exception ex) { ProcException(ex); } }
private void cmbPLCType_SelectedIndexChanged(object sender, System.EventArgs e) { //enPlcType en= (enPlcType)Enum.Parse(typeof(enPlcType), cmbPLCType.SelectedItem.ToString(), true); enPlcType en = (enPlcType)cmbPLCType.SelectedItem; try { switch (en) { case enPlcType.Melsec_A: case enPlcType.Melsec_Q: case enPlcType.LS_XGT: case enPlcType.LS_XGI: case enPlcType.TEST: string strIP = this.txtIPAdd.Text; int intPort = int.Parse(this.txtPort.Text); string strDeviceType = this.txtDeviceType.Text.PadLeft(1, char.Parse(" ")); Comm = new clsPLCModule(en, strIP, intPort, strDeviceType, strLogFileName); Comm.AddAddress("900"); Comm.AddAddress("901"); Comm.AddAddress("902"); Comm.AddAddress("903"); Comm.AddAddress("904"); Comm.AddAddress("1000"); Comm.AddAddress("1001"); //Comm.AddAddress("%MW500"); //Comm.AddAddress("%DW1000"); //Comm.AddAddress("%DW1001"); //Comm.AddAddress("%DW1100"); //Comm.AddAddress("%DW1101"); break; #if (ABPLC) case enPlcType.AB: string strNode = this.txtNODE.Text; string strProgID = this.txtProgID.Text; string strGroupName = "grpTest"; string strTopicName = this.txtTopic.Text; int intUpdateRate = 1000; Comm = new clsPLCModule(en, strNode, strProgID, strGroupName, strTopicName, intUpdateRate, strLogFileName); break; #endif default: Comm = null; break; } } catch (Exception ex) { ExceptionMsg(ex); } }