aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StartThreadLoadingRequest.pb-c.h
blob: a21a7ba7fd8fa937fd4bffcba95fe73d0241965f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
/* Generated from: StartThreadLoadingRequest.proto */

#ifndef PROTOBUF_C_StartThreadLoadingRequest_2eproto__INCLUDED
#define PROTOBUF_C_StartThreadLoadingRequest_2eproto__INCLUDED

#include <protobuf-c/protobuf-c.h>

PROTOBUF_C__BEGIN_DECLS

#if PROTOBUF_C_VERSION_NUMBER < 1003000
# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif


typedef struct _StartThreadLoadingRequest StartThreadLoadingRequest;


/* --- enums --- */


/* --- messages --- */

struct  _StartThreadLoadingRequest
{
  ProtobufCMessage base;
};
#define START_THREAD_LOADING_REQUEST__INIT \
 { PROTOBUF_C_MESSAGE_INIT (&start_thread_loading_request__descriptor) \
     }


/* StartThreadLoadingRequest methods */
void   start_thread_loading_request__init
                     (StartThreadLoadingRequest         *message);
size_t start_thread_loading_request__get_packed_size
                     (const StartThreadLoadingRequest   *message);
size_t start_thread_loading_request__pack
                     (const StartThreadLoadingRequest   *message,
                      uint8_t             *out);
size_t start_thread_loading_request__pack_to_buffer
                     (const StartThreadLoadingRequest   *message,
                      ProtobufCBuffer     *buffer);
StartThreadLoadingRequest *
       start_thread_loading_request__unpack
                     (ProtobufCAllocator  *allocator,
                      size_t               len,
                      const uint8_t       *data);
void   start_thread_loading_request__free_unpacked
                     (StartThreadLoadingRequest *message,
                      ProtobufCAllocator *allocator);
/* --- per-message closures --- */

typedef void (*StartThreadLoadingRequest_Closure)
                 (const StartThreadLoadingRequest *message,
                  void *closure_data);

/* --- services --- */


/* --- descriptors --- */

extern const ProtobufCMessageDescriptor start_thread_loading_request__descriptor;

PROTOBUF_C__END_DECLS


#endif  /* PROTOBUF_C_StartThreadLoadingRequest_2eproto__INCLUDED */
span>public String SignalOutput { get; set; } /// <summary> /// Occurs when the emergency status has changed. /// </summary> public event EventHandler<EmergencyStatusChangedEventArgs> StatusChanged; /// <summary> /// Initializes a new instance of the <see cref="UsbEmergencyNotificationProvider"/> class. /// </summary> /// <param name="port">The port.</param> public UsbEmergencyNotificationProvider(String port) { SignalOutput = "1"; Address = port; ReadTimeout = TimeSpan.FromMilliseconds(500); _timer = new Timer(2000); _timer.Elapsed += _timer_Elapsed; _timer.Start(); } /// <summary> /// Called when the status has been changed. /// </summary> /// <param name="status">The status.</param> /// <param name="errorException">The error exception.</param> protected virtual void OnStatusChanged(EmergencyStatus status, Exception errorException = null) { if (Status != status) { Status = status; StatusChanged?.Invoke(this, new EmergencyStatusChangedEventArgs() { Status = status, ErrorException = errorException, }); } } /// <summary> /// Handles the Elapsed event of the _timer. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> [DebuggerNonUserCode] private void _timer_Elapsed(object sender, ElapsedEventArgs e) { if (IsEnabled && !_busy) { _busy = true; SerialPort serial = new SerialPort(Address); try { serial.ReadTimeout = (int)ReadTimeout.TotalMilliseconds; serial.Open(); serial.Write(SignalOutput + "\n"); try { string output = serial.ReadLine(); if (output == SignalOutput) { OnStatusChanged(EmergencyStatus.On); } else { OnStatusChanged(EmergencyStatus.Off); } } catch (TimeoutException) { OnStatusChanged(EmergencyStatus.Off); } catch (Exception ex) { OnStatusChanged(EmergencyStatus.Error, ex); } } catch (Exception ex) { OnStatusChanged(EmergencyStatus.Error, ex); } finally { try { serial.Dispose(); _busy = false; } catch { } } } } } }