// IO 정보 리턴. public DeviceNetIO GetLinkData(string strIoName, DNET_IO_TYPE type) { DeviceNetIO Rtn = null; for (int nAdapter = 0; nAdapter < DNet_Adapter.Count; nAdapter++) { for (int nModule = 0; nModule < DNet_Adapter[nAdapter].Module_List.Count; nModule++) { if (DNet_Adapter[nAdapter].Module_List[nModule].IO_Type != type) { continue; } for (int nIO = 0; nIO < DNet_Adapter[nAdapter].Module_List[nModule].IO_List.Count; nIO++) { DeviceNetIO _IO = DNet_Adapter[nAdapter].Module_List[nModule].IO_List[nIO]; if (_IO.IO_Name.Equals(strIoName) && _IO.IO_Type.Equals(type)) { Rtn = _IO; break; } } if (Rtn != null) { break; } } if (Rtn != null) { break; } } return(Rtn); }
public DeviceNetIO(string name, ushort addr, ushort subaddr, DNET_IO_TYPE type, string strCable, string strDesc = "") { Address = addr; IO_Name = name; IO_Type = type; Cable = strCable; SubAddr = subaddr; Description = strDesc; }
public void RefreshAddress(ref ushort usInputMax, ref ushort usOutputMax) { //ushort nInputAddr = 0; ushort nInputAddr = 1; //ushort nInputAddr = 0; ushort nOutputAddr = 0; nSpare = 1; for (int nCntAdapter = 0; nCntAdapter < DNet_Adapter.Count; nCntAdapter++) { //nInputAddr += 2; //디지털 인풋은 아답터 정보때매 2Word를 차지한다. for (int nCntModule = 0; nCntModule < DNet_Adapter[nCntAdapter].Module_List.Count; nCntModule++) { //Todo if (DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_Type == DNET_IO_TYPE.D_INPUT || DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_Type == DNET_IO_TYPE.D_OUTPUT) { //Digital 신호 DNET_IO_TYPE _CurIO_Type = DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_Type; for (int nCntIO = 0; nCntIO < DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_List.Count; nCntIO++) { DeviceNetIO _CurIO = DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_List[nCntIO]; //_CurIO.SubAddr = (ushort)(1 << nCntIO); if (_CurIO.IO_Name == "" || _CurIO.IO_Name.IndexOf("SPARE_") >= 0) { _CurIO.IO_Name = string.Format("SPARE_{0:d04}", nSpare++); } } //nInputAddr += 2; //nOutputAddr += 2; } else { //Analog 신호 //아날로그 모듈은, 인풋이 9개, 아웃풋이 6개로,,, 각각 2워드를 차지한다. DNET_IO_TYPE _CurIO_Type = DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_Type; for (int nCntIO = 0; nCntIO < DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_List.Count; nCntIO++) { DeviceNetIO _CurIO = DNet_Adapter[nCntAdapter].Module_List[nCntModule].IO_List[nCntIO]; //_CurIO.Address = nInputAddr; //_CurIO.SubAddr = nOutputAddr; if (_CurIO.IO_Name == "" || _CurIO.IO_Name.IndexOf("SPARE_") >= 0) { _CurIO.IO_Name = string.Format("SPARE_{0:d04}", nSpare++); } //nInputAddr += 2; } //nOutputAddr += 12; //아날로그 아웃풋 영역은 6개니깐,, 고정으로 12워드를 차지한다. 단 첫번째 어드래스는,, 각 인풋영역의 셋팅값으로 활용된다. } } } usInputMax = nInputAddr; usOutputMax = nOutputAddr; }
public DeviceNetIO(DNET_IO_TYPE type) { //공통 IO_Type = type; Address = 0; IO_Name = ""; Cable = ""; SubAddr = 0; Description = ""; }
public DeviceNetIO() { //공통 IO_Type = DNET_IO_TYPE.D_INPUT; Address = 0; IO_Name = ""; Cable = ""; SubAddr = 0; Description = ""; }
public DNet_Module_Struct(DNET_IO_TYPE type) { IO_Type = type; if (type == DNET_IO_TYPE.D_INPUT || type == DNET_IO_TYPE.D_OUTPUT) { //디지털 신호 for (int i = 0; i < 16; i++) { IO_List.Add(new DeviceNetIO(type)); } } else { //아날로그 신호 for (int i = 0; i < 9; i++) { IO_List.Add(new DeviceNetIO(type)); } } }
private int Write(string strIOname, DNET_IO_TYPE type, bool bOn) { DeviceNetIO IO = cOM_DeviceNet_IO_List.GetLinkData(strIOname, type); return(cOM_DeviceNet.WriteBit(IO, bOn)); }
private bool Read(string strIOname, DNET_IO_TYPE type) { DeviceNetIO IO = cOM_DeviceNet_IO_List.GetLinkData(strIOname, type); return(cOM_DeviceNet.ReadBit(IO)); }