/// <summary> /// Prepare open compartment object by communicating command to communication port service. /// </summary> /// <returns> /// Open compartment actual result with status. /// </returns> public static Compartment CompartmentOpen(string compartmentId, AppSettings lockerConfiguration) { // Find the target compartment var target_compartment = lockerConfiguration.Locker.Compartments.Find(compartment => compartment.CompartmentId.Contains(compartmentId)); // Commanding var DoorOpenResult = CommunicationPortControlService.SendCommand(CommandType.DoorOpen, CompartmentHelper.MapModuleId(target_compartment), lockerConfiguration); Compartment compartmentResult = new Compartment(lockerConfiguration.Locker.LockerId, target_compartment.CompartmentId, target_compartment.CompartmentSize, Convert.ToBoolean(DoorOpenResult["DoorOpen"]), !Convert.ToBoolean(DoorOpenResult["DoorOpen"]), false, Convert.ToBoolean(DoorOpenResult["DoorOpen"]) ? "ON" : "OFF"); return(compartmentResult); }