public void machineResponseTimeoutCallback(SerialComm.Packet_t packet) { try { } catch { } }
public override void responseReceived(SerialComm.Packet_t p) { if (form == null || formWasClosed == true) { formWasClosed = false; form = new ResponseForm(this); form.FormClosing += new FormClosingEventHandler(form_FormClosing); if (showResponseForm == true) { form.WindowState = FormWindowState.Normal; form.Show(); } } if (showResponseForm == true) { //form.WindowState = FormWindowState.Normal; //form.TopMost = true; form.Show(); counter++; } lastResponse = form.updateStatus(p); form.updateStatus(p); if (StatusReceivedEvent != null) { StatusReceivedEvent(this, new StatusEventArgs(lastResponse)); } }
public void machineSentCallback(SerialComm.Packet_t packet) { try { } catch { } }
public void apiAckTimeoutCallback(SerialComm.Packet_t packet) { try { } catch { } }
public SerialPacketField(SerialComm.Packet_t p) { InitializeComponent(); showTime(); telegram.FromPacket(p); showTelegram(); }
public void apiSentCallback(SerialComm.Packet_t packet) { try { } catch { } }
public void FromPacket(SerialComm.Packet_t p) { byte[] buffer = p.ToByteArray(); pip = buffer[0]; pie = buffer[1]; pn = buffer[2]; sa = buffer[3]; da = buffer[4]; if (p.type == SerialComm.PacketType_t.Data_e || p.type == SerialComm.PacketType_t.Request_e) { mi = buffer[5]; mp = (ushort)((buffer[7] << 8) + buffer[6]); dl = (ushort)((buffer[9] << 8) + buffer[8]); if (dl > 0) { Array.Resize(ref data, dl); Array.Copy(buffer, 10, data, 0, dl); } crc = (ushort)((buffer[11 + dl] << 8) + buffer[10 + dl]); isAckNack = false; } else { mi = 0; mp = 0; dl = 0; crc = 0; isAckNack = true; } }
public void machineNackFailCallback(SerialComm.Packet_t packet) { try { } catch { } }
private void addSerialPacketFieldMachine(SerialComm.Packet_t packet) { switch (cmbxProcessLevel.SelectedIndex) { case 1: // raw packet byte[] arr = packet.ToRawArray(); SerialRawPacketField srpf = new SerialRawPacketField(arr, arr.Length); flowMachine.Controls.Add(srpf); flowMachine.Controls.SetChildIndex(srpf, 0); srpf.Show(); break; case 0: // processed packet default: SerialPacketField spf = new SerialPacketField(); spf.showTime(); spf.telegram.FromPacket(packet); spf.showTelegram(); flowMachine.Controls.Add(spf); flowMachine.Controls.SetChildIndex(spf, 0); spf.Show(); break; } }
public void machineReceivedCallback(SerialComm.Packet_t packet) { try { BeginInvoke(addSpfToMachine, packet); } catch { } }
public void apiReceivedCallback(SerialComm.Packet_t packet) { try { BeginInvoke(addSpfToApi, packet); } catch { } }
private void telegramReceivedCallback(SerialComm.Packet_t packet) { try { this.BeginInvoke(ApiDataReceived, packet); } catch { } }
private void nackFailCallback(SerialComm.Packet_t packet) { try { errorOccurredEvent(this, new PacketEventArgs(packet)); // Das andere Gerät erhält inkorrekte Daten } catch { } }
private void ackTimeoutCallback(SerialComm.Packet_t packet) { try { errorOccurredEvent(this, new PacketEventArgs(packet)); // Das andere Gerät antwortet nicht. } catch { } }
/// <summary> /// Show a packet in the incoming part of the view. /// </summary> /// <param name="p">packet containing the information</param> private void fillInDetails(SerialComm.Packet_t p) { string s = ""; eApi.Analyzer.TelegramStructure telegram = new eApi.Analyzer.TelegramStructure(); telegram.FromPacket(p); txtInEOT.Text = "04"; txtInSOH.Text = "01"; txtInPIP.Text = String.Format("{0:x2}", telegram.pip).ToUpper(); txtInPIE.Text = String.Format("{0:x2}", telegram.pie).ToUpper(); txtInPN.Text = String.Format("{0:x2}", telegram.pn).ToUpper(); txtInSA.Text = String.Format("{0:x2}", telegram.sa).ToUpper(); txtInDA.Text = String.Format("{0:x2}", telegram.da).ToUpper(); if (!telegram.isAckNack) { txtInMI.Text = String.Format("{0:x2}", telegram.mi).ToUpper(); txtInMP.Text = String.Format("{0:x4}", telegram.mp).ToUpper(); txtInDL.Text = String.Format("{0:x4}", telegram.dl).ToUpper(); txtInCRC.Text = String.Format("{0:x4}", telegram.crc).ToUpper(); } else { txtInMI.Text = "--"; txtInMP.Text = "--"; txtInDL.Text = "--"; txtInCRC.Text = "----"; } // Data for (int i = 0; i < p.dataLength; i++) { s += "0x" + String.Format("{0:X02}", ((byte)p.data[i])) + ", "; } if (s == "") { s = "no data"; } txtInData.Text = s; s = ""; // Raw byte[] buffer = p.ToRawArray(); for (int i = 0; i < buffer.Length; i++) { s += "0x" + String.Format("{0:X02}", ((byte)buffer[i])) + ", "; } if (s == "") { s = "no data"; } txtInRawData.Text = s; }
public ProcDump_t updateStatus(SerialComm.Packet_t p) { string str = ""; if (p.dataLength > 0) { // cast packet p into response processResponse(p); str = response.date.ToString( ) + " / "; str += response.time.ToString( ) + "\n"; str += "Cake Press Before: " + (response.cakePressBefore / 10.0).ToString("0.0") + " mm\n"; str += "Cake Press After: " + (response.cakePressAfter / 10.0).ToString("0.0") + " mm\n"; str += "Cake Press Hub: " + (response.cakePressHub / 10.0).ToString("0.0") + " mm\n"; str += "Cake Press Final: " + (response.cakePressFinal / 10.0).ToString("0.0") + " mm\n"; str += "Brew Side: " + response.side.ToString( ) + "\n"; str += "PQC: " + response.pwdrQntyCtrl.ToString( ) + "\n"; str += "Grind Time: " + (response.powderQty / 10.0).ToString("0.0") + " s\n"; str += "Extract Time: " + (response.extractTime / 10.0).ToString("0.0") + " s\n"; str += "Water Qnty: " + response.waterQnty.ToString( ) + " ticks\n"; str += "Water Temp: " + response.waterTemp.ToString( ) + " °C\n"; str += "Product Type: " + response.prodType.ToString( ) + "\n"; str += "Double Prod: " + response.doubleProd.ToString( ) + "\n"; str += "Key Number: " + (response.keyId + 1).ToString( ) + "\n"; str += "Bean Hopper: " + response.beanHopp.ToString( ) + "\n"; str += "Outlet Side: " + response.outSide.ToString( ) + "\n"; str += "Stopped: " + response.prodAbort.ToString( ) + "\n"; str += "Grind Adjust Left: " + (( short )response.grindAdjustLeft).ToString( ) + "\n"; str += "Grind Adjust Right: " + (( short )response.grindAdjustRight).ToString( ) + "\n"; str += "Ref Extract Time: " + response.refExtractTime.ToString( ) + "\n"; str += "Milk Temp: " + response.milkTemp.ToString( ) + " °C\n"; str += "Steam Press: " + (response.steamPress / 10.0).ToString("0.0") + " bar\n"; str += "Milk Time: " + (response.milkTime / 10.0).ToString("0.0") + " s\n"; str += "RPM Foam: " + response.rpmFoam.ToString( ) + "\n"; str += "RPM Milk: " + response.rpmMilk.ToString( ) + "\n"; if (p.dataLength > 42) { str += "Boiler Temp: " + response.boilerTemp.ToString( ) + " °C\n"; str += "Milk Control Temp Foam: " + response.mctTempFoam.ToString( ) + " °C\n"; str += "Milk Control Temp Milk: " + response.mctTempMilk.ToString( ) + " °C\n"; str += "Milk Control Time Foam: " + (response.mctTimeFoam / 10.0).ToString("0.0") + " s\n"; str += "Milk Control Time Milk: " + (response.mctTimeMilk / 10.0).ToString("0.0") + " s\n"; str += "Milk Input Temp: " + response.milkInputTemp.ToString( ) + " °C\n"; str += "Air Quantity: " + response.airQuantity.ToString( ) + " %\n"; } } lblProcDump.Text = str; return(response); }
private void responseTimeoutCallback(SerialComm.Packet_t packet) { try { this.BeginInvoke(updateUI, packet, CommStatus.ResponseTimeout); errorOccurredEvent(this, new PacketEventArgs(packet)); // Das andere Gerät schickt keine Antwort // Dies kann auch bedeuten das es Verbindungsprobleme gibt aber // das Ack wurde empfangen d.h. das warscheinlich ein Problem // beim Main Thread des anderen Gerätes vorliegt. } catch { } }
static public void saveToFile(SerialComm.Packet_t product, string name, string id) { string save = ""; save += name + "|"; save += System.Convert.ToString((byte)product.type) + "|"; save += System.Convert.ToString((byte)product.message.command) + "|"; save += System.Convert.ToString((byte)product.message.parameter) + "|"; save += System.Convert.ToString((byte)product.dataLength) + "|"; save += System.Convert.ToBase64String(product.data) + "|"; System.IO.File.WriteAllText("C:/Users/Public/eApi/" + id + ".settings", save); }
public CommandForm(ref ProductParameter_t[] defaultProducts, SerialComm.Packet_t p) { InitializeComponent(); packet = p; defaultProductParams = defaultProducts; // load saved products files = filesystem.loadFromFiles(); for (int i = 0; i < files.Length; i++) { if (files[i].id != null) { files[i] = CompleteDataOfFile(files[i]); nmbrOfCustomButtons++; ParamButton dpb = new ParamButton(new ProductParameter_t(files[i].packet), OnButtonClick, files[i].name, files[i].id); dpb.parameter = files[i].packet.message.parameter; flowProductButtons.Controls.Add(dpb); } } // if there are no saved products load the default ones if (flowProductButtons.Controls.Count == 0) { ParamButton Espresso = new ParamButton(defaultProductParams[(byte)ProductType_t.Espresso_e], OnButtonClick, "Espresso", "defEsp"); ParamButton Coffee = new ParamButton(defaultProductParams[(byte)ProductType_t.Coffee_e], OnButtonClick, "Coffee", "defCof"); ParamButton Cappuccino = new ParamButton(defaultProductParams[(byte)ProductType_t.Cappuccino_e], OnButtonClick, "Cappuccino", "defCap"); ParamButton Americano = new ParamButton(defaultProductParams[(byte)ProductType_t.Americano_e], OnButtonClick, "Americano", "defAmericano"); ParamButton AutoSteam = new ParamButton(defaultProductParams[(byte)ProductType_t.AutoSteam_e], OnButtonClick, "Auto steam", "defAutoSteam"); ParamButton HotWater = new ParamButton(defaultProductParams[(byte)ProductType_t.HotWater_e], OnButtonClick, "Hot water", "defHotWater"); ParamButton Everfoam = new ParamButton(defaultProductParams[(byte)ProductType_t.Everfoam_e], OnButtonClick, "Everfoam", "defEFoam"); ParamButton Milk = new ParamButton(defaultProductParams[(byte)ProductType_t.Milk_e], OnButtonClick, "Milk", "defMilk"); ParamButton MilkFoam = new ParamButton(defaultProductParams[(byte)ProductType_t.MilkFoam_e], OnButtonClick, "Milk foam", "defMilkFoam"); ParamButton ManualSteam = new ParamButton(defaultProductParams[(byte)ProductType_t.ManualSteam_e], OnButtonClick, "Manual steam", "defManSteam"); flowProductButtons.Controls.Add(Espresso); flowProductButtons.Controls.Add(Coffee); flowProductButtons.Controls.Add(Cappuccino); flowProductButtons.Controls.Add(Americano); flowProductButtons.Controls.Add(AutoSteam); flowProductButtons.Controls.Add(Everfoam); flowProductButtons.Controls.Add(Milk); flowProductButtons.Controls.Add(MilkFoam); flowProductButtons.Controls.Add(ManualSteam); } // select Espresso as default cbxOutletSide.SelectedIndex = 0; this.ProductParams = defaultProductParams[(byte)ProductType_t.Espresso_e]; paramsToControls(); }
public void showResponse(SerialComm.Packet_t packet) { CmdButton btn = LastRequest as CmdButton; if (btn.processResponse) { btn.responseReceived(packet); } // Eingang anzeige aktualisieren //try // temp fix //{ this.BeginInvoke(updateUI, packet, CommStatus.ResponseReceived); //} //catch { } }
public GetStatus() { SerialComm.Packet_t packet = new SerialComm.Packet_t(); lastResponse = new GetStatusResponse_t(); this.Click += new EventHandler(OnButtonClick); this.Text = "GetStatus"; this.toolTip = "get the current status"; packet.destination = (byte)ModuleId_t.Touch_e; packet.source = (byte)ModuleId_t.Api_e; packet.appPort = SerialComm.ApplicationPort_t.Api_e; packet.type = SerialComm.PacketType_t.Request_e; packet.message.command = (byte)API_Command_t.GetStatus_e; this.packet = packet; this.processResponse = true; this.showResponseForm = true; }
public plainCommand(API_Command_t commandType, string description) { SerialComm.Packet_t packet = new SerialComm.Packet_t(); this.Click += new EventHandler(OnButtonClick); this.Text = description; packet.destination = (byte)ModuleId_t.Touch_e; packet.source = (byte)ModuleId_t.Api_e; packet.appPort = SerialComm.ApplicationPort_t.Api_e; packet.type = SerialComm.PacketType_t.Data_e; packet.message.command = (byte)commandType; this.packet = packet; this.processResponse = false; this.showCommandForm = false; this.showResponseForm = false; }
private void API_ReceiveData(SerialComm.Packet_t packet) { //try // temp fix //{ if (packet.type == SerialComm.PacketType_t.Data_e) { // Antwort if (packet.sequenceNumber == serialSession.LastSentPacket.sequenceNumber && serialSession.LastSentPacket.type == SerialComm.PacketType_t.Request_e) { if (packet.isFail == true) { // Erhaltene Antwort hat einen Fehler serialSession.EnqueuePacket(serialSession.LastSentPacket); } else { showResponse(packet); } } // Kommando switch (packet.message.command) { default: break; } } else { // Request switch (packet.message.command) { default: serialSession.EnqueuePacket(packet.source, (byte)API_Command_t.Undef_e, packet.sequenceNumber); break; } } //} //catch { } }
public ResponseForm(GetStatus parentButton) { InitializeComponent(); ParentButton = parentButton; this.FormClosing += new FormClosingEventHandler(ResponseForm_FormClosing); stopPacket = new SerialComm.Packet_t(); stopPacket.message.command = (byte)API_Command_t.Stop_e; stopPacket.destination = (byte)ModuleId_t.Touch_e; stopPacket.source = (byte)ModuleId_t.Api_e; stopPacket.appPort = SerialComm.ApplicationPort_t.Api_e; stopPacket.type = SerialComm.PacketType_t.Data_e; cbxInterval.SelectedIndex = 3; if (btnStopLeft.Visible == false) { pnlCoffeeMilkLeft.Size = new Size(pnlCoffeeMilkLeft.Size.Width, pnlCoffeeMilkLeft.Size.Height - 33); pnlCoffeeMilkRight.Size = new Size(pnlCoffeeMilkRight.Size.Width, pnlCoffeeMilkRight.Size.Height - 33); pnlSteamLeft.Size = new Size(pnlSteamLeft.Size.Width, pnlSteamLeft.Size.Height - 33); pnlSteamRight.Size = new Size(pnlSteamRight.Size.Width, pnlSteamRight.Size.Height - 33); pnlWater.Size = new Size(pnlWater.Size.Width, pnlWater.Size.Height - 33); } #if !Briggo //lblDetailedBriggo.Visible = false; lblCoffeeLeftBriggo.Visible = false; lblCoffeeRightBriggo.Visible = false; lblMilkLeftBriggo.Visible = false; lblMilkRightBriggo.Visible = false; txtCoffeeLeftBriggo.Visible = false; txtCoffeeRightBriggo.Visible = false; txtMilkLeftBriggo.Visible = false; txtMilkRightBriggo.Visible = false; #endif }
private void processResponse(SerialComm.Packet_t p) { // Machine response.machineStatus = p.data[0]; // Coffee Left response.coffeeL.status = (Status_t)(p.data[1] & 0x0F); response.coffeeL.action = (Actions_t)(p.data[1] >> 4); response.coffeeL.process = (Process_t)p.data[6]; // Coffee Right response.coffeeR.status = (Status_t)(p.data[2] & 0x0F); response.coffeeR.action = (Actions_t)(p.data[2] >> 4); response.coffeeR.process = (Process_t)p.data[7]; // Steam Left response.steamL.status = (Status_t)(p.data[3] & 0x0F); response.steamL.action = (Actions_t)(p.data[3] >> 4); response.steamL.process = (Process_t)p.data[8]; // Steam Right response.steamR.status = (Status_t)(p.data[4] & 0x0F); response.steamR.action = (Actions_t)(p.data[4] >> 4); response.steamR.process = (Process_t)p.data[9]; // Hot Water response.water.status = (Status_t)(p.data[5] & 0x0F); response.water.action = (Actions_t)(p.data[5] >> 4); response.water.process = (Process_t)p.data[10]; if (p.dataLength > 11) { Array.Resize(ref response.remainder, p.dataLength - 11); Array.Copy(p.data, 11, response.remainder, 0, p.dataLength - 11); } }
public GetStatusResponse_t updateStatus(SerialComm.Packet_t p) { // cast packet p into response processResponse(p); // Machine txtMachineStatus.Text = toBinaryString(response.machineStatus); // Coffee Left txtActionLeft.Text = getActionString(response.coffeeL.action); txtStatusLeft.Text = getStatusString(response.coffeeL.status); txtProcessLeft.Text = getProcessString(response.coffeeL.process); txtStatusByteLeft.Text = toBinaryString((byte)response.coffeeL.status); txtProcessByteLeft.Text = toBinaryString((byte)response.coffeeL.process); // Coffee Right txtActionRight.Text = getActionString(response.coffeeR.action); txtStatusRight.Text = getStatusString(response.coffeeR.status); txtProcessRight.Text = getProcessString(response.coffeeR.process); txtStatusByteRight.Text = toBinaryString((byte)response.coffeeR.status); txtProcessByteRight.Text = toBinaryString((byte)response.coffeeR.process); // Steam Left txtActionSteamLeft.Text = getActionString(response.steamL.action); txtStatusSteamLeft.Text = getStatusString(response.steamL.status); txtProcessSteamLeft.Text = getProcessString(response.steamL.process); txtStatusByteSteamLeft.Text = toBinaryString((byte)response.steamL.status); txtProcessByteSteamLeft.Text = toBinaryString((byte)response.steamL.process); // Steam Right txtActionSteamRight.Text = getActionString(response.steamR.action); txtStatusSteamRight.Text = getStatusString(response.steamR.status); txtProcessSteamRight.Text = getProcessString(response.steamR.process); txtStatusByteSteamRight.Text = toBinaryString((byte)response.steamR.status); txtProcessByteSteamRight.Text = toBinaryString((byte)response.steamR.process); // Hot Water txtActionWater.Text = getActionString(response.water.action); txtStatusWater.Text = getStatusString(response.water.status); txtProcessWater.Text = getProcessString(response.water.process); txtStatusByteWater.Text = toBinaryString((byte)response.water.status); txtProcessByteWater.Text = toBinaryString((byte)response.water.process); #if Briggo if (response.remainder.Length >= 2) { txtCoffeeLeftBriggo.Text = getActionCoffeeString((byte)(response.remainder[0] >> 4)); txtCoffeeRightBriggo.Text = getActionCoffeeString((byte)(response.remainder[0] & 0x0F)); txtMilkLeftBriggo.Text = getActionMilkString((byte)(response.remainder[1] >> 4)); txtMilkRightBriggo.Text = getActionMilkString((byte)(response.remainder[1] & 0x0F)); } else { txtCoffeeLeftBriggo.Text = "check machine"; txtCoffeeRightBriggo.Text = "software version"; } #endif return(response); }
public override void responseReceived(SerialComm.Packet_t p) { }
/// <summary> /// Packet p will be shown if show is set to true. /// </summary> public PacketEventArgs(SerialComm.Packet_t p, bool show) { packet = p; showPacket = show; }
/// <summary> /// Packet p will be shown by default. /// </summary> public PacketEventArgs(SerialComm.Packet_t p) { packet = p; showPacket = true; }
/// <summary> /// This method is called when a response is received. It will only be called when processResponse is true. /// It should check the variable showResponseForm. /// </summary> /// <param name="p"></param> abstract public void responseReceived(SerialComm.Packet_t p);