/// <summary> /// /// </summary> void UpdatePowerFB(byte powerByte) { var newVal = powerByte == 1; if (newVal != _PowerIsOn) { _PowerIsOn = newVal; PowerIsOnFeedback.FireUpdate(); } }
/// <summary> /// /// </summary> void UpdatePowerFB(byte powerByte) { var newVal = powerByte == 1; if (newVal != _PowerIsOn) { _PowerIsOn = newVal; Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Feedback Power State: {0}", _PowerIsOn); PowerIsOnFeedback.FireUpdate(); } }
private void displayEvent(GenericBase device, BaseEventArgs args) { switch (args.EventId) { case RoomViewConnectedDisplay.OnLineFeedbackEventId: // TODO: figure out what to do with OnLine event in BaseEvent // Read current state of the projector power and if differ from room state update room state accordingly without setters actions. foreach (var feeedback in Feedbacks) { //feeedback.FireUpdate(); } break; case RoomViewConnectedDisplay.PowerOffFeedbackEventId: case RoomViewConnectedDisplay.PowerOnFeedbackEventId: PowerIsOnFeedback.FireUpdate(); break; case RoomViewConnectedDisplay.CoolingDownFeedbackEventId: IsCoolingDownFeedback.FireUpdate(); break; case RoomViewConnectedDisplay.WarmingUpFeedbackEventId: IsWarmingUpFeedback.FireUpdate(); break; case RoomViewConnectedDisplay.MuteOnFeedbackEventId: MuteFeedback.FireUpdate(); break; case RoomViewConnectedDisplay.VolumeFeedbackEventId: VolumeLevelFeedback.FireUpdate(); break; case RoomViewConnectedDisplay.SourceSelectFeedbackEventId: uint sourceSelectIndex = (uint)args.Index; if (_display.SourceSelectFeedbackSigs[sourceSelectIndex].BoolValue == true) { RoutingInputPort newInputPort = (RoutingInputPort)_display.SourceSelectFeedbackSigs[sourceSelectIndex].UserObject; CurrentInputFeedback.FireUpdate(); OnSwitchChange(new RoutingNumericEventArgs(null, newInputPort, eRoutingSignalType.AudioVideo)); } break; case RoomViewConnectedDisplay.SourceNameTextFeedbackEventId: break; case RoomViewConnectedDisplay.LampHoursFeedbackEventId: case RoomViewConnectedDisplay.LampHoursTextFeedbackEventId: break; } }
public override void PowerOn() { Send(PowerOnCmd); if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) { _IsWarmingUp = true; IsWarmingUpFeedback.FireUpdate(); // Fake power-up cycle WarmupTimer = new CTimer(o => { _IsWarmingUp = false; _PowerIsOn = true; IsWarmingUpFeedback.FireUpdate(); PowerIsOnFeedback.FireUpdate(); }, WarmupTime); } }
/// <summary> /// /// </summary> public override void PowerOn() { //Send(PowerOnCmd); SendBytes(new byte[] { 0x07, ID, 0x02, 0x50, 0x4F, 0x57, 0x01, 0x08, 0x0d }); if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) { _IsWarmingUp = true; IsWarmingUpFeedback.FireUpdate(); // Fake power-up cycle WarmupTimer = new CTimer(o => { _IsWarmingUp = false; _PowerIsOn = true; IsWarmingUpFeedback.FireUpdate(); PowerIsOnFeedback.FireUpdate(); }, WarmupTime); } }
public override void PowerOff() { // If a display has unreliable-power off feedback, just override this and // remove this check. if (PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) { Send(PowerOffCmd); _IsCoolingDown = true; _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); IsCoolingDownFeedback.FireUpdate(); // Fake cool-down cycle CooldownTimer = new CTimer(o => { Debug.Console(2, this, "Cooldown timer ending"); _IsCoolingDown = false; IsCoolingDownFeedback.FireUpdate(); }, CooldownTime); } }
/// <summary> /// /// </summary> public override void PowerOff() { // If a display has unreliable-power off feedback, just override this and // remove this check. if (!_IsWarmingUp && !_IsCoolingDown) // PowerIsOnFeedback.BoolValue && { //Send(PowerOffCmd); SendBytes(new byte[] { 0x07, ID, 0x02, 0x50, 0x4F, 0x57, 0x00, 0x08, 0x0d }); _IsCoolingDown = true; _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); IsCoolingDownFeedback.FireUpdate(); // Fake cool-down cycle CooldownTimer = new CTimer(o => { _IsCoolingDown = false; IsCoolingDownFeedback.FireUpdate(); }, CooldownTime); } }
/// <summary> /// /// </summary> public override void PowerOn() { Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering On Display"); IsPoweringOnIgnorePowerFb = true; //Send(PowerOnCmd); SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 }); if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) { _IsWarmingUp = true; IsWarmingUpFeedback.FireUpdate(); // Fake power-up cycle WarmupTimer = new CTimer(o => { _IsWarmingUp = false; _PowerIsOn = true; IsWarmingUpFeedback.FireUpdate(); PowerIsOnFeedback.FireUpdate(); }, WarmupTime); } }
/// <summary> /// /// </summary> public override void PowerOff() { Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering Off Display"); IsPoweringOnIgnorePowerFb = false; // If a display has unreliable-power off feedback, just override this and // remove this check. if (!_IsWarmingUp && !_IsCoolingDown) // PowerIsOnFeedback.BoolValue && { //Send(PowerOffCmd); SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x00, 0x00 }); _IsCoolingDown = true; _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); IsCoolingDownFeedback.FireUpdate(); // Fake cool-down cycle CooldownTimer = new CTimer(o => { _IsCoolingDown = false; IsCoolingDownFeedback.FireUpdate(); }, CooldownTime); } }
/// <summary> /// This method will run when the PortGather is satisfied. Parse responses here. /// </summary> /// <param name="dev"></param> /// <param name="args"></param> void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) { if (Debug.Level == 2) { Debug.Console(2, this, "Received: '{0}'", ComTextHelper.GetEscapedText(args.Text)); } char[] trimChars = { '\x02', '\x03' }; var FB = args.Text.Trim(trimChars); Debug.Console(2, this, "Received cmd: '{0}'", FB); switch (FB) { case "PON": { _PowerIsOn = true; PowerIsOnFeedback.FireUpdate(); InputNumberFeedback.FireUpdate(); break; } case "POF": { _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); InputNumber = 102; InputNumberFeedback.FireUpdate(); break; } case "QPW:1": { _PowerIsOn = true; PowerIsOnFeedback.FireUpdate(); InputNumberFeedback.FireUpdate(); break; } case "QPW:0": { _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); InputNumber = 102; InputNumberFeedback.FireUpdate(); break; } case "QMI:HM1": { if (_PowerIsOn) { InputNumber = 1; InputNumberFeedback.FireUpdate(); } break; } case "QMI:HM2": { if (_PowerIsOn) { InputNumber = 2; InputNumberFeedback.FireUpdate(); } break; } case "QMI:DV1": { if (_PowerIsOn) { InputNumber = 3; InputNumberFeedback.FireUpdate(); } break; } case "QMI:PC1": { if (_PowerIsOn) { InputNumber = 4; InputNumberFeedback.FireUpdate(); } break; } } }
///// <summary> ///// / ///// </summary> ///// <param name="sender"></param> //void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e) //{ // // This is probably not thread-safe buffering // // Append the incoming bytes with whatever is in the buffer // var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length]; // IncomingBuffer.CopyTo(newBytes, 0); // e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); // if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1 // Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes)); // // Need to find AA FF and have // for (int i = 0; i < newBytes.Length; i++) // { // if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) // { // newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer // // parse it // // If it's at least got the header, then process it, // while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) // { // var msgLen = newBytes[3]; // // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1), // // give and save it for next time // if (newBytes.Length < msgLen + 4) // break; // // Good length, grab the message // var message = newBytes.Skip(4).Take(msgLen).ToArray(); // // At this point, the ack/nak is the first byte // if (message[0] == 0x41) // { // switch (message[1]) // type byte // { // case 0x00: // General status // UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps // UpdateInputFb(message[5]); // UpdateVolumeFB(message[3]); // UpdateMuteFb(message[4]); // UpdateInputFb(message[5]); // break; // case 0x11: // UpdatePowerFB(message[2]); // break; // case 0x12: // UpdateVolumeFB(message[2]); // break; // case 0x13: // UpdateMuteFb(message[2]); // break; // case 0x14: // UpdateInputFb(message[2]); // break; // default: // break; // } // } // // Skip over what we've used and save the rest for next time // newBytes = newBytes.Skip(5 + msgLen).ToArray(); // } // break; // parsing will mean we can stop looking for header in loop // } // } // // Save whatever partial message is here // IncomingBuffer = newBytes; //} void PortGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs e) { Debug.Console(1, this, "Receivied: '{0}'", ComTextHelper.GetEscapedText(e.Text)); if (e.Text.IndexOf("\x50\x4F\x57") > -1) { // Power Status Response var value = e.Text.ToCharArray(); switch (value[6]) { case '\x00': { _PowerIsOn = false; break; } case '\x01': { _PowerIsOn = true; break; } } PowerIsOnFeedback.FireUpdate(); Debug.Console(1, this, "PowerIsOn State: {0}", PowerIsOnFeedback.BoolValue); } else if (e.Text.IndexOf("\x4D\x49\x4E") > -1) { var value = e.Text.ToCharArray(); var b = value[6]; var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b)); if (newInput != null && newInput != _CurrentInputPort) { _CurrentInputPort = newInput; CurrentInputFeedback.FireUpdate(); Debug.Console(1, this, "Current Input: {0}", CurrentInputFeedback.StringValue); } } else if (e.Text.IndexOf("\x56\x4F\x4C") > -1) { // Volume Status Response var value = e.Text.ToCharArray(); var b = value[6]; var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535); if (!VolumeIsRamping) { _LastVolumeSent = newVol; } if (newVol != _VolumeLevelForSig) { _VolumeLevelForSig = newVol; VolumeLevelFeedback.FireUpdate(); if (_VolumeLevelForSig > 0) { _IsMuted = false; } else { _IsMuted = true; } MuteFeedback.FireUpdate(); Debug.Console(1, this, "Volume Level: {0}", VolumeLevelFeedback.IntValue); } } }
void ParseBytes(byte[] bytes) { if (bytes[0] == 0x22) { // Power on if (bytes[1] == 0x00) { _PowerIsOn = true; PowerIsOnFeedback.FireUpdate(); } // Power off else if (bytes[1] == 0x01) { _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); } } // Running Status else if (bytes[0] == 0x20 && bytes[1] == 0x85 && bytes[4] == 0x10) { var operationStates = new Dictionary <int, string> { { 0x00, "Standby" }, { 0x04, "Power On" }, { 0x05, "Cooling" }, { 0x06, "Standby (error)" }, { 0x0f, "Standby (power saving" }, { 0x10, "Network Standby" }, { 0xff, "Not supported" } }; var newPowerIsOn = bytes[7] == 0x01; if (newPowerIsOn != _PowerIsOn) { _PowerIsOn = newPowerIsOn; PowerIsOnFeedback.FireUpdate(); } Debug.Console(2, this, "PowerIsOn={0}\rCooling={1}\rPowering on/off={2}\rStatus={3}", _PowerIsOn, bytes[8] == 0x01, bytes[9] == 0x01, operationStates[bytes[10]]); } // Lamp remaining else if (bytes[0] == 0x23 && bytes[1] == 0x96 && bytes[4] == 0x06 && bytes[6] == 0x04) { var newValue = bytes[7]; if (bytes[5] == 0x00) { if (newValue != _Lamp1RemainingPercent) { _Lamp1RemainingPercent = newValue; Lamp1RemainingPercent.FireUpdate(); } } else { if (newValue != _Lamp2RemainingPercent) { _Lamp2RemainingPercent = newValue; Lamp2RemainingPercent.FireUpdate(); } } Debug.Console(0, this, "Lamp {0}, {1}% remaining", (bytes[5] + 1), bytes[7]); } }
public override void PowerToggle() { _PowerIsOn = false; PowerIsOnFeedback.FireUpdate(); IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime); }
public override void PowerOn() { IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime); _PowerIsOn = true; PowerIsOnFeedback.FireUpdate(); }