public CapeOpenUnitPort GetPortByName(string name) { for (int i = 0; i < List.Count; i++) { CapeOpenUnitPort zPort = (CapeOpenUnitPort)List[i]; if (zPort.Name == name) { return((CapeOpenUnitPort)List[i]); } } ATCOError = new CapeOpenError(); ATCOError.UserCode = (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR; ATCOError.UserInterfaceName = "ICapeUnitCollection_Item"; ATCOError.UserOperation = "Item"; ATCOError.UserDescription = "The input value is a string but not rapresents a valid portname"; throw new COMException("Errore", (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR); }
public static CapeOpenUnitPort Create(CapeOpenPortType type, string name, string description, CapeOpenPortDirection direction) { CapeOpenUnitPort zPort = null; switch (type) { case CapeOpenPortType.Material: zPort = new MaterialPort(); break; default: throw new CapeOpenException(); } zPort.Name = name; zPort.Description = description; zPort.Direction = direction; return(zPort); }
protected override object OnItem(object id) { Int16 indice16; int indice32; if (!(id is int) && !(id is string) && !(id is Int16)) { ATCOError = new CapeOpenError(); ATCOError.UserCode = (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR; ATCOError.UserInterfaceName = "ICapeUnitCollection_Item"; ATCOError.UserOperation = "Item"; ATCOError.UserDescription = "The input value is not a valid number or string"; throw (new COMException("Errore", (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR)); } else { if (id is string) { string str; str = (string)id; for (int i = 0; i < List.Count; i++) { CapeOpenUnitPort zPort = (CapeOpenUnitPort)List[i]; if (zPort.Name == str) { return(List[i]); } } ATCOError = new CapeOpenError(); ATCOError.UserCode = (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR; ATCOError.UserInterfaceName = "ICapeUnitCollection_Item"; ATCOError.UserOperation = "Item"; ATCOError.UserDescription = "The input value is a string but not rapresents a valid portname"; throw new COMException("Errore", (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR); } else {//int or int16 try { if (id is int) { indice32 = (int)id; return(List[indice32 - 1]); } if (id is Int16) { indice16 = (Int16)id; return(List[indice16 - 1]); } return(null); } catch { ATCOError = new CapeOpenError(); ATCOError.UserCode = (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR; ATCOError.UserInterfaceName = "ICapeUnitCollection_Item"; ATCOError.UserOperation = "Item"; ATCOError.UserDescription = "The input value is a integer but is out of index"; throw (new COMException("Errore", (int)CAPEOPEN093.eCapeErrorInterfaceHR_tag.ECapeInvalidArgumentHR)); } } } }
public void Add(CapeOpenUnitPort port) { List.Add(port); }