Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/storage info #20

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Meadow;
using Meadow.Cloud;

namespace CloudSample;

public class CommandController
{
public CommandController(ICommandService commandService)
{
commandService.Subscribe<SampleCommand>(OnSampleCommandRecevied);
}

private void OnSampleCommandRecevied(SampleCommand command)
{
Resolver.Log.Info($"Command received: Data = {command.Data}");
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Meadow;
using Meadow.Cloud;
using Meadow.Logging;
using System;
using System.Collections.Generic;
using System.Threading;

namespace CloudSample;
Expand Down Expand Up @@ -71,45 +69,8 @@ public void Start()

private void ControlTimerProc(object o)
{
telemetryController.LogTelemetry();
// telemetryController.LogTelemetry();

controlTimer.Change(10000, -1);
}
}

public class TelemetryController
{
private const int DataEventId = 2000;

private Random random = new();
private IMeadowCloudService cloudService;

public TelemetryController(IMeadowCloudService cloudService)
{
this.cloudService = cloudService;
}

public void LogTelemetry()
{
var data = new Dictionary<string, object>
{
{ "Int Value", random.Next(43) },
{ "String Value", BitConverter.ToString(BitConverter.GetBytes(random.NextDouble())) }
};

cloudService.SendEvent(DataEventId, "CloudSample Data", data);
}
}

public class CommandController
{
public CommandController(ICommandService commandService)
{
commandService.Subscribe<SampleCommand>(OnSampleCommandRecevied);
}

private void OnSampleCommandRecevied(SampleCommand command)
{
Resolver.Log.Info($"Command received: Data = {command.Data}");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Meadow.Cloud;
using System;
using System.Collections.Generic;

namespace CloudSample;

public class TelemetryController
{
private const int DataEventId = 2000;

private Random random = new();
private IMeadowCloudService cloudService;

public TelemetryController(IMeadowCloudService cloudService)
{
this.cloudService = cloudService;
}

public void LogTelemetry()
{
var data = new Dictionary<string, object>
{
{ "Int Value", random.Next(43) },
{ "String Value", BitConverter.ToString(BitConverter.GetBytes(random.NextDouble())) }
};

cloudService.SendEvent(DataEventId, "CloudSample Data", data);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# Uncomment additional options as needed.
# To learn more about these config options, including custom application configuration settings, check out the Application Settings Configuration documentation.
# http://developer.wildernesslabs.co/Meadow/Meadow.OS/Configuration/Application_Settings_Configuration/

# App lifecycle configuration.
Lifecycle:

# Control whether Meadow will restart when an unhandled app exception occurs. Combine with Lifecycle > AppFailureRestartDelaySeconds to control restart timing.
RestartOnAppFailure: true

# When app set to restart automatically on app failure,
# AppFailureRestartDelaySeconds: 15

# Meadow.Cloud configuration.
# Logging configuration.
Logging:

Expand All @@ -20,18 +8,7 @@ Logging:
# Trace, Debug, Information, Warning, or Error
Default: Trace

# Meadow.Cloud configuration.
MeadowCloud:

# Enable Meadow.Cloud features
Enabled: true
EnableUpdates: true

# Meadow.Cloud Health Metrics.
HealthMetrics:

# Enable Health Metrics
# Enabled: true

# How often to send metrics to Meadow.Cloud (in minutes)
# Interval: 15
EnableUpdates: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@ Logging:
MeadowCloud:
Enabled: true
EnableUpdates: true

HealthMetrics:
# Enable Health Metrics
# Enabled: true

# How often to send metrics to Meadow.Cloud (in minutes)
# Interval: 15
EnableHealthMetrics: true
HealthMetricsIntervalMinutes: 1
11 changes: 10 additions & 1 deletion Source/Meadow.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Walking_DigitalOutputs", "M
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Walking_DigitalOutputs_Fs", "Meadow F7\Utilities\WalkingDigitalOutputs_F#\Walking_DigitalOutputs_Fs.fsproj", "{DB444522-6F37-4AC0-83B1-70C693395CD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatherF7_OTA", "Meadow.Cloud\FeatherF7_OTA\FeatherF7_OTA.csproj", "{5F901575-0744-4A27-B2BE-AE868D361817}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatherF7_OTA", "Meadow.Cloud\FeatherF7_OTA\FeatherF7_OTA.csproj", "{5F901575-0744-4A27-B2BE-AE868D361817}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StorageInfo_Sample", "RaspberryPi\StorageInfo_Sample\StorageInfo_Sample.csproj", "{043EA273-EF6D-48BC-920D-D63F827B1C55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -2291,6 +2293,12 @@ Global
{5F901575-0744-4A27-B2BE-AE868D361817}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU
{5F901575-0744-4A27-B2BE-AE868D361817}.Simulation|Any CPU.Build.0 = Debug|Any CPU
{5F901575-0744-4A27-B2BE-AE868D361817}.Simulation|Any CPU.Deploy.0 = Debug|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Release|Any CPU.Build.0 = Release|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU
{043EA273-EF6D-48BC-920D-D63F827B1C55}.Simulation|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2527,6 +2535,7 @@ Global
{435CD7FA-15FF-43A3-AA1B-3EFCF8859DDA} = {8BC5FD06-80AB-4975-9964-EF1DA973D7BF}
{DB444522-6F37-4AC0-83B1-70C693395CD4} = {8BC5FD06-80AB-4975-9964-EF1DA973D7BF}
{5F901575-0744-4A27-B2BE-AE868D361817} = {0F5B8EEF-8895-42C6-9E93-A9152EDEEDDB}
{043EA273-EF6D-48BC-920D-D63F827B1C55} = {67E244C3-7B2D-45CE-A490-E7B1E1A6A9F9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E3F002EA-1A25-487F-9A5D-93D1E7EC6E31}
Expand Down
25 changes: 25 additions & 0 deletions Source/RaspberryPi/StorageInfo_Sample/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Meadow;

namespace StorageInfo_Sample;

public class MeadowApp : App<RaspberryPi>
{
public override Task Run()
{
Resolver.Log.Info($"\nMeadow file system info");
Resolver.Log.Info($"-----------------------");

Resolver.Log.Info($"Meadow root: {Device.PlatformOS.FileSystem.FileSystemRoot}");
Resolver.Log.Info($"Data dir: {Device.PlatformOS.FileSystem.DataDirectory}");
Resolver.Log.Info($"Temp dir: {Device.PlatformOS.FileSystem.TempDirectory}");


Resolver.Log.Info($"\n{"Filesystem",-15}{"1-K blocks",-15}{"Available",-15}Drive Name");
foreach (LinuxStorageInformation drive in Device.PlatformOS.FileSystem.Drives)
{
Resolver.Log.Info($"{drive.Filesystem,-15}{drive.Size.KibiBytes,-15}{drive.SpaceAvailable.KibiBytes,-15}{drive.Name}");
}

return base.Run();
}
}
11 changes: 11 additions & 0 deletions Source/RaspberryPi/StorageInfo_Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Meadow;

namespace StorageInfo_Sample;

public class Program
{
public static async Task Main(string[] args)
{
await MeadowOS.Start(args);
}
}
12 changes: 12 additions & 0 deletions Source/RaspberryPi/StorageInfo_Sample/StorageInfo_Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Core\source\implementations\linux\Meadow.Linux\Meadow.Linux.csproj" />
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj" />
</ItemGroup>
</Project>
Loading