/// <summary> /// Translates a PSEMResponse to a ClientMeterCmdResult response /// </summary> /// <param name="PSEMResult">the PSEMResponse to be translated</param> /// <returns>a ClientMeterCmdResult response code</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 12/01/06 AF 8.00.00 Created // private ClientMeterCmdResult TranslatePSEMResponse(PSEMResponse PSEMResult) { ClientMeterCmdResult Result = ClientMeterCmdResult.UNSUPPORTED_COMMAND; switch (PSEMResult) { case PSEMResponse.Ok: { Result = ClientMeterCmdResult.SUCCESS; break; } case PSEMResponse.Sns: case PSEMResponse.Onp: case PSEMResponse.Iar: { Result = ClientMeterCmdResult.UNSUPPORTED_COMMAND; break; } default: { Result = ClientMeterCmdResult.ERROR; break; } } return(Result); }
/// <summary> /// This command configures the schedule by which the Gas/Water meter /// will wake up and send its meter data to the electric meter /// </summary> /// <param name="ulClientAddr"> /// MAC address of the client to which to send the command /// </param> /// <param name="byWakeUpHour"> /// Hour for wake up and data delivery: midnight is 0, 11 pm is 23 /// </param> /// <param name="byFrequency"> /// Whether the client should wake up once or twice a day. 1 => every 12 hours; /// 0 => every 24 hours. /// </param> /// <returns>ClientMeterCmdResult</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 12/05/06 AF 8.00.00 Created // public virtual ClientMeterCmdResult SetDataDeliveryConfig(UInt64 ulClientAddr, byte byWakeUpHour, byte byFrequency) { ClientMeterCmdResult Result = ClientMeterCmdResult.UNSUPPORTED_COMMAND; PSEMResponse PSEMResult = new PSEMResponse(); byte[] abyCmdParams = new byte[SIZE_OF_CMD_PARAM_ARRAY]; int iIndex = 0; PSEMResult = PSEMResponse.Err; //Construct the command parameter byte byCommandParameter = (byte)((byFrequency << 5) | byWakeUpHour); // Start with a read of table 2100 to see what's already there. // We don't want to overwrite valid commands List <ClientCfgRcd> lstRcds = Table2100.HANConfigData; // Build the command parameter array. For this command, the first // byte contains the configuration info abyCmdParams[0] = byCommandParameter; //Fill the rest of the command data fields with FF for (iIndex = 1; iIndex < SIZE_OF_CMD_PARAM_ARRAY; iIndex++) { abyCmdParams[iIndex] = 0xFF; } bool blnFoundCmdSpace = ConstructTable2100(ulClientAddr, abyCmdParams, eZigbeeAppCmds.SetDataDeliveryCfg, ref lstRcds); if (false != blnFoundCmdSpace) { //Write the data into a byte array byte[] abyTable2100Data = ConvertDataToByteArray(lstRcds); PSEMResult = m_PSEM.FullWrite(2100, abyTable2100Data); Result = TranslatePSEMResponse(PSEMResult); } else { Result = ClientMeterCmdResult.TOO_MANY_COMMANDS; } return(Result); }
/// <summary> /// Writes a GW_Set_Remote_Date_Time command to table 2100 for the /// specified Zigbee client /// </summary> /// <param name="ulClientAddr"> /// MAC address of the client to which to send the command /// </param> /// <returns>ClientMeterCmdResult</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 11/22/06 AF 8.00.00 Created // public virtual ClientMeterCmdResult SetClientMeterTime(UInt64 ulClientAddr) { ClientMeterCmdResult Result = ClientMeterCmdResult.UNSUPPORTED_COMMAND; PSEMResponse PSEMResult = new PSEMResponse(); byte[] abyCmdParams = new byte[SIZE_OF_CMD_PARAM_ARRAY]; int iIndex; PSEMResult = PSEMResponse.Err; // Start with a read of table 2100 to see what's already there. // We don't want to overwrite valid commands List <ClientCfgRcd> lstRcds = Table2100.HANConfigData; // Build the command parameter array. For this command it really // doesn't matter. The electric meter will overwrite the field // when the command is sent to the Zigbee client for (iIndex = 0; iIndex < SIZE_OF_CMD_PARAM_ARRAY; iIndex++) { abyCmdParams[iIndex] = 0; } // Insert the command data into the existing contents of table 2100 // if there is room for it bool blnFoundCmdSpace = ConstructTable2100(ulClientAddr, abyCmdParams, eZigbeeAppCmds.SetDateTime, ref lstRcds); if (false != blnFoundCmdSpace) { //Write the data back to the meter byte[] abyTable2100Data = ConvertDataToByteArray(lstRcds); PSEMResult = m_PSEM.FullWrite(2100, abyTable2100Data); Result = TranslatePSEMResponse(PSEMResult); } else { Result = ClientMeterCmdResult.TOO_MANY_COMMANDS; } return(Result); }