This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SerialPort = require('serial-port'); | |
var sp = new SerialPort('/dev/ttyUSB0'); | |
sp.on('open', function() { | |
sp.write('<ID01><PA>', function(err, res){ | |
if(!err) { | |
sp.write('<ID01><PA>$1', function(err, res) { | |
if(!err) { | |
console.log("yay!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnStart(string[] args) | |
{ | |
string[] imagePathArgs = Environment.GetCommandLineArgs(); | |
if (imagePathArgs.Length >= 2) | |
{ | |
int value = 0; | |
if (Int32.TryParse(imagePathArgs[1], out value)) MaxCPUUsage = value; | |
else | |
{ | |
eventLog.WriteEntry("Fail to convert parameter 1:" + imagePathArgs[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Process() | |
{ | |
while (!finalizeService) | |
{ | |
PerformanceCounter PC = new PerformanceCounter(); | |
PC.CategoryName = "Processor"; | |
PC.CounterName = "% Processor Time"; | |
PC.InstanceName = "_Total"; | |
PC.ReadOnly = true; | |
var value = PC.NextValue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void SendAlertMessage(AlertType alertType, double value, long ramValue) | |
{ | |
List<RTPMProcess> list = new List<RTPMProcess>(); | |
lstPerformance = new List<PerformanceCounter>(); | |
Process[] processes = System.Diagnostics.Process.GetProcesses(); | |
for (int i = 0; i < processes.Length; i++) | |
{ | |
PerformanceCounter pc = new PerformanceCounter("Process", "% Processor Time", processes[i].ProcessName, true); | |
try | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnStop() | |
{ | |
try | |
{ | |
eventLog.WriteEntry("Unsubscribe channel " + channel); | |
mrePubNub = new ManualResetEvent(false); | |
pubnub.Unsubscribe<string>(channel, UnsubscribeCallback, SubscribeMethodForConnectCallback, UnsubscribeMethodForDisconnectCallback, ErrorCallback); | |
mrePubNub.WaitOne(manualResetEventsWaitTimeout); | |
eventLog.WriteEntry("Channel " + channel + " unsubscribed."); | |
finalizeService = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:PhoneRTPM" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:System="using:System" | |
x:Class="PhoneRTPM.MainPage" | |
mc:Ignorable="d" | |
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ReceivedMessageCallbackWhenSubscribed(string result) | |
{ | |
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim())) | |
{ | |
List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result); | |
if (deserializedMessage != null && deserializedMessage.Count > 0) | |
{ | |
object subscribedObject = (object)deserializedMessage[0]; | |
if (subscribedObject != null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.publish({ | |
channel : 'mouseMoves', | |
message : { | |
x: 400, | |
y: 200 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.subscribe({channels: [channel]}); | |
pubnub.addListener({ | |
presence: function(m){ | |
document.getElementById('occupancy').textContent = m.occupancy; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::num; | |
struct Vector { | |
x:f32, | |
y:f32, | |
z:f32 | |
} | |
impl Vector { |
OlderNewer