/* TIA 102.AACD-A 3.8.7 */ public List <RspKeyInfo> ViewKeyInfo() { List <RspKeyInfo> result = new List <RspKeyInfo>(); Begin(); InventoryCommandListActiveKeys commandKmmBody = new InventoryCommandListActiveKeys(); commandKmmBody.InventoryMarker = 0; commandKmmBody.MaxKeysRequested = 78; KmmBody responseKmmBody = TxRxKmm(commandKmmBody); if (responseKmmBody is InventoryResponseListActiveKeys) { InventoryResponseListActiveKeys kmm = responseKmmBody as InventoryResponseListActiveKeys; Logger.Debug("number of active keys: {0}", kmm.Keys.Count); for (int i = 0; i < kmm.Keys.Count; i++) { KeyInfo info = kmm.Keys[i]; Logger.Debug("* key index {0} *", i); Logger.Debug("keyset id: {0} (dec), {0:X} (hex)", info.KeySetId); Logger.Debug("sln: {0} (dec), {0:X} (hex)", info.SLN); Logger.Debug("algorithm id: {0} (dec), {0:X} (hex)", info.AlgorithmId); Logger.Debug("key id: {0} (dec), {0:X} (hex)", info.KeyId); RspKeyInfo res = new RspKeyInfo(); res.KeysetId = info.KeySetId; res.Sln = info.SLN; res.AlgorithmId = info.AlgorithmId; res.KeyId = info.KeyId; result.Add(res); } } else { throw new Exception("unexpected kmm"); } End(); return(result); }
/* TIA 102.AACD-A 3.8.7 */ public List <RspKeyInfo> ViewKeyInfo() { List <RspKeyInfo> result = new List <RspKeyInfo>(); Begin(); try { bool more = true; int marker = 0; while (more) { InventoryCommandListActiveKeys commandKmmBody = new InventoryCommandListActiveKeys(); commandKmmBody.InventoryMarker = marker; commandKmmBody.MaxKeysRequested = 78; KmmBody responseKmmBody = TxRxKmm(commandKmmBody); if (responseKmmBody is InventoryResponseListActiveKeys) { InventoryResponseListActiveKeys kmm = responseKmmBody as InventoryResponseListActiveKeys; marker = kmm.InventoryMarker; Logger.Debug("inventory marker: {0}", marker); if (marker == 0) { more = false; } Logger.Debug("number of keys returned: {0}", kmm.Keys.Count); for (int i = 0; i < kmm.Keys.Count; i++) { KeyInfo info = kmm.Keys[i]; Logger.Debug("* key index {0} *", i); Logger.Debug("keyset id: {0} (dec), {0:X} (hex)", info.KeySetId); Logger.Debug("sln: {0} (dec), {0:X} (hex)", info.SLN); Logger.Debug("algorithm id: {0} (dec), {0:X} (hex)", info.AlgorithmId); Logger.Debug("key id: {0} (dec), {0:X} (hex)", info.KeyId); RspKeyInfo res = new RspKeyInfo(); res.KeysetId = info.KeySetId; res.Sln = info.SLN; res.AlgorithmId = info.AlgorithmId; res.KeyId = info.KeyId; result.Add(res); } } else if (responseKmmBody is NegativeAcknowledgment) { NegativeAcknowledgment kmm = responseKmmBody as NegativeAcknowledgment; string statusDescr = OperationStatusExtensions.ToStatusString(kmm.Status); string statusReason = OperationStatusExtensions.ToReasonString(kmm.Status); throw new Exception(string.Format("received negative acknowledgment{0}status: {1} (0x{2:X2}){0}{3}", Environment.NewLine, statusDescr, kmm.Status, statusReason)); } else { throw new Exception("unexpected kmm"); } } } catch { End(); throw; } End(); return(result); }