void timer_Tick(object sender, EventArgs e) { try { if (status == ConnectorStatus.Monitoring) { BeginLoad(); } } catch (Exception ex) { this.Stop(); error = ex; this.status = ConnectorStatus.Error; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, status); } MessageBox.Show(string.Format("Connection Failed.\n\nReason: {0}", ex.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); connected = false; } }
private void ThreadedConnect() { try { if (this.ConnectToBM(guid, url)) { this.status = ConnectorStatus.Connected; } else if (connected) { this.status = ConnectorStatus.Stopped; } if (this.ConnectionChanged != null) { this.ConnectionChanged(this, status); } } catch (Exception ex) { this.status = ConnectorStatus.Error; error = ex; MessageBox.Show(string.Format("Unable to connect to Business Module.\n\nReason: {0}", ex.Message), "Failed to connect!", MessageBoxButtons.OK, MessageBoxIcon.Error); connected = false; } }
public void Start() { if (connected && bm.RunStatus != ServiceStatus.Started) { if (MessageBox.Show(string.Format("Business Module '{0}' ({1}) is currently not running.\nStart it from the web admin console?", bm.Name, bm.Description), "Not Running!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { bm.RunStatus = ServiceStatus.Started; status = ConnectorStatus.Connected; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, this.status); } } } if (status == ConnectorStatus.Connected) { bm.StartReading(); timer.Enabled = true; status = ConnectorStatus.Monitoring; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, this.status); } } }
public void Stop() { timer.Enabled = false; bm.StopReading(); status = ConnectorStatus.Stopped; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, this.status); } }
/// <summary> /// Create a status notification request. /// </summary> /// <param name="Timestamp">The time for which the status is reported.</param> /// <param name="ConnectorStatus">The current status of the connector.</param> /// <param name="EVSEId">The identification of the EVSE to which the connector belongs for which the the status is reported.</param> /// <param name="ConnectorId">The identification of the connector within the EVSE for which the status is reported.</param> /// <param name="CustomData">An optional custom data object to allow to store any kind of customer specific data.</param> public StatusNotificationRequest(DateTime Timestamp, ConnectorStatus ConnectorStatus, EVSE_Id EVSEId, Connector_Id ConnectorId, CustomData CustomData = null) { this.Timestamp = Timestamp; this.ConnectorStatus = ConnectorStatus; this.EVSEId = EVSEId; this.ConnectorId = ConnectorId; this.CustomData = CustomData; }
public void Disconnect() { Stop(); bm.RunStatus = ServiceStatus.Stopped; bm = null; connected = false; this.status = ConnectorStatus.NotConnected; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, status); } }
/// <summary> /// Return the HashCode of this object. /// </summary> /// <returns>The HashCode of this object.</returns> public override Int32 GetHashCode() { unchecked { return(Timestamp.GetHashCode() * 11 ^ ConnectorStatus.GetHashCode() * 7 ^ EVSEId.GetHashCode() * 5 ^ ConnectorId.GetHashCode() * 3 ^ (CustomData != null ? CustomData.GetHashCode() : 0)); } }
public override string ToText(MonitorContent content) { switch (content.Subtype) { case "stat": return(EnumToText((int)ConnectorStatus, ConnectorStatus.ToString(), content)); case "connect": return(BoolToText(Connected, "Connected", "", content)); case "unconnect": return(BoolToText(Unconnected, "Unconnected", "", content)); case "ship": return(ShipName); default: return(base.ToText(content)); } }
/// <summary> /// Compares two status notification requests for equality. /// </summary> /// <param name="StatusNotificationRequest">A status notification request to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public override Boolean Equals(StatusNotificationRequest StatusNotificationRequest) { if (StatusNotificationRequest is null) { return(false); } return(Timestamp.Equals(StatusNotificationRequest.Timestamp) && ConnectorStatus.Equals(StatusNotificationRequest.ConnectorStatus) && EVSEId.Equals(StatusNotificationRequest.EVSEId) && ConnectorId.Equals(StatusNotificationRequest.ConnectorId) && ((CustomData == null && StatusNotificationRequest.CustomData == null) || (CustomData != null && StatusNotificationRequest.CustomData != null && CustomData.Equals(StatusNotificationRequest.CustomData)))); }
void UpdateStatus(ConnectorStatus status) { foreach (var control in Controls.OfType <Control>()) { control.Enabled = false; } nudAppId.Enabled = true; btnLoad.Enabled = true; btnSave.Enabled = true; lvwLog.Enabled = true; btnExport.Enabled = true; btnDownloadImages.Enabled = true; switch (status) { case ConnectorStatus.NotRegistered: break; case ConnectorStatus.ValidationCodeNeeded: txtCode.Enabled = true; btnAuth.Enabled = true; break; case ConnectorStatus.Connected: UpdateContactsList(); txtRecipient.Enabled = true; txtRecipient.Text = string.Empty; txtDownload.Enabled = true; lvwContacts.Enabled = true; break; case ConnectorStatus.ClientError: break; case ConnectorStatus.NotConnected: nudAppId.Enabled = true; txtAppHash.Enabled = true; txtNumber.Enabled = true; btnConnect.Enabled = true; break; default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomStatusNotificationRequestSerializer">A delegate to serialize custom StatusNotification requests.</param> /// <param name="CustomCustomDataResponseSerializer">A delegate to serialize CustomData objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <StatusNotificationRequest> CustomStatusNotificationRequestSerializer = null, CustomJObjectSerializerDelegate <CustomData> CustomCustomDataResponseSerializer = null) { var JSON = JSONObject.Create( new JProperty("timestamp", Timestamp.ToIso8601()), new JProperty("connectorStatus", ConnectorStatus.AsText()), new JProperty("evseId", EVSEId.ToString()), new JProperty("connectorId", ConnectorId.ToString()), CustomData != null ? new JProperty("customData", CustomData.ToJSON(CustomCustomDataResponseSerializer)) : null); return(CustomStatusNotificationRequestSerializer != null ? CustomStatusNotificationRequestSerializer(this, JSON) : JSON); }
public void CheckBlocks() { ConnectorStatus currentConnectorStatus = ConnectorStatus; if (Connector == null) { ConnectorStatus = ConnectorStatus.NoConnector; CurrentColor = NotConnected; } else { switch (Connector.Status) { case MyShipConnectorStatus.Connected: ConnectorStatus = ConnectorStatus.Connected; CurrentColor = Connected; break; case MyShipConnectorStatus.Connectable: ConnectorStatus = ConnectorStatus.AwaitingConnection; CurrentColor = Connectable; break; case MyShipConnectorStatus.Unconnected: ConnectorStatus = ConnectorStatus.NotConnected; CurrentColor = NotConnected; break; } } if (ConnectorStatus != currentConnectorStatus) { foreach (DisplayPanel panel in Panels) { panel.UpdatePanel(); } } SetBlockColors(); }
/// <summary> /// Connect to the desired business model /// </summary> public bool Connect() { this.error = null; try { this.status = ConnectorStatus.Connecting | ConnectorStatus.NotConnected; if (this.ConnectionChanged != null) { this.ConnectionChanged(this, status); } if (!Connected) { ThreadedConnect(); } } catch (Exception e) { connected = false; error = e; MessageBox.Show(string.Format("Error while connecting to BM.\n\nReason: {0}", e.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); }
public static String AsText(this ConnectorStatus ConnectorStatus) { switch (ConnectorStatus) { case ConnectorStatus.Available: return("Available"); case ConnectorStatus.Occupied: return("Occupied"); case ConnectorStatus.Reserved: return("Reserved"); case ConnectorStatus.Unavailable: return("Unavailable"); case ConnectorStatus.Faulted: return("Faulted"); default: return("unknown"); } }
public async Task <ConnectorStatus> Connect() { Status = await ConnectOrSendCodeRequest(); return(Status); }
public ConnectorStatusEventArgs(ConnectorStatus status, float percent) { this.status = status; this.percent = percent; }
public ConnectorStatusEventArgs(ConnectorStatus status) { this.status = status; this.percent = 0; }
public string HandleStatusNotification(OCPPMessage msgIn, OCPPMessage msgOut) { string errorCode = null; StatusNotificationResponse statusNotificationResponse = new StatusNotificationResponse(); int connectorId = 0; bool msgWritten = false; try { Logger.LogTrace("Processing status notification..."); StatusNotificationRequest statusNotificationRequest = JsonConvert.DeserializeObject <StatusNotificationRequest>(msgIn.JsonPayload); Logger.LogTrace("StatusNotification => Message deserialized"); connectorId = statusNotificationRequest.ConnectorId; // Write raw status in DB msgWritten = WriteMessageLog(ChargePointStatus.Id, connectorId, msgIn.Action, string.Format("Info={0} / Status={1} / ", statusNotificationRequest.Info, statusNotificationRequest.Status), statusNotificationRequest.ErrorCode.ToString()); ConnectorStatus newStatus = ConnectorStatus.Undefined; switch (statusNotificationRequest.Status) { case StatusNotificationRequestStatus.Available: newStatus = ConnectorStatus.Available; break; case StatusNotificationRequestStatus.Preparing: case StatusNotificationRequestStatus.Charging: case StatusNotificationRequestStatus.SuspendedEVSE: case StatusNotificationRequestStatus.SuspendedEV: case StatusNotificationRequestStatus.Finishing: case StatusNotificationRequestStatus.Reserved: newStatus = ConnectorStatus.Occupied; break; case StatusNotificationRequestStatus.Unavailable: newStatus = ConnectorStatus.Unavailable; break; case StatusNotificationRequestStatus.Faulted: newStatus = ConnectorStatus.Faulted; break; } Logger.LogInformation("StatusNotification => ChargePoint={0} / Connector={1} / newStatus={2}", ChargePointStatus?.Id, connectorId, newStatus.ToString()); if (connectorId <= 1) { ChargePointStatus.EVSE1Status = newStatus; } else if (connectorId == 2) { ChargePointStatus.EVSE2Status = newStatus; } msgOut.JsonPayload = JsonConvert.SerializeObject(statusNotificationResponse); Logger.LogTrace("StatusNotification => Response serialized"); } catch (Exception exp) { Logger.LogError(exp, "StatusNotification => ChargePoint={0} / Exception: {1}", ChargePointStatus.Id, exp.Message); errorCode = ErrorCodes.InternalError; } if (!msgWritten) { WriteMessageLog(ChargePointStatus.Id, connectorId, msgIn.Action, null, errorCode); } return(errorCode); }
void connector_ConnectionChanged(object sender, ConnectorStatus e) { this.sidePanel.Invalidate(); if (this.InvokeRequired) { this.Invoke(new ConnectorChangedHandler(connector_ConnectionChanged), sender, e); } else { switch (e) { case ConnectorStatus.Connected: if (Connector.Connected) { string connectionString = string.Format( "Connected to Business Module: {0}\nDescription: {1}", connector.BusinessModule.Name, connector.BusinessModule.Description); this.connectToolStripMenuItem.Enabled = false; this.disconnectMenuItem.Enabled = true; this.EnableGrids(); ToolTip tip = new ToolTip(); tip.IsBalloon = true; tip.Show(connectionString, this.monitorBar, 0, -50, 4000); this.UpdateStatus(connectionString, new ConnectorStatusEventArgs(ConnectorStatus.Connected)); } break; case ConnectorStatus.NotConnected: if (!Connector.Connected) { this.connectToolStripMenuItem.Enabled = true; this.disconnectMenuItem.Enabled = false; this.stopButton.Enabled = false; this.clearButton.Enabled = false; this.DisableGrids(); this.UpdateStatus("Not Connected!", new ConnectorStatusEventArgs(ConnectorStatus.NotConnected)); } break; case ConnectorStatus.Stopped: this.stopButton.Text = "&Start"; this.stopButton.Enabled = true; this.clearButton.Enabled = true; this.UpdateStatus("Stopped!", new ConnectorStatusEventArgs(ConnectorStatus.Stopped)); break; case ConnectorStatus.Monitoring: this.stopButton.Text = "&Stop"; this.stopButton.Enabled = true; this.clearButton.Enabled = true; this.UpdateStatus("Monitoring!", new ConnectorStatusEventArgs(ConnectorStatus.Monitoring)); break; case ConnectorStatus.Error: connector.Stop(); this.UpdateStatus((sender as Connector).Error, new ConnectorStatusEventArgs(ConnectorStatus.Error)); break; default: this.UpdateStatus((sender as Connector).Error, new ConnectorStatusEventArgs(ConnectorStatus.Error)); break; } } }
public ConnectorStatusEventArgs(float percent) { this.status = ConnectorStatus.Monitoring; this.percent = percent; }