Commits

Martin Vejnár committed 00e2960

Added a sketch of the plugin for Asix Sigma.

Comments (0)

Files changed (6)

sigma_plugin/main.cpp

+#include <Windows.h>
+#include <tchar.h>
+#include <algorithm>
+#include "sigma.h"
+
+namespace {
+
+TPluginSettings * g_settings = 0;
+
+sigma_bool_t SIGMAAPI init(sigma_bool_t * allowStartup)
+{
+	*allowStartup = true;
+	return true;
+}
+
+void SIGMAAPI cleanup()
+{
+}
+
+void SIGMAAPI about()
+{
+	::MessageBox(g_settings->hWND, _T("Omicron Analyzer plugin"), _T("About"), MB_OK | MB_ICONINFORMATION);
+}
+
+sigma_bool_t SIGMAAPI getinputinfo(int32_t index, int32_t *id, int32_t *maxchar, char *name)
+{
+	*id = index;
+	if (index > 0)
+		return false;
+
+	static char const n[] = "pokus_trace";
+	if (*maxchar < sizeof n)
+	{
+		*maxchar = sizeof n;
+		return false;
+	}
+
+	strcpy(name, n);
+	return true;
+}
+
+sigma_bool_t SIGMAAPI getinput(int32_t id, TPluginInputSnapshot *snapshot)
+{
+	if (id != 0)
+		return false;
+
+	snapshot->BoundaryMin = 0;
+	snapshot->BoundaryMax = 1;
+	for (size_t i = 0; i < snapshot->ViewWidth; ++i)
+	{
+		snapshot->MinArray[i] = 0;
+		snapshot->MaxArray[i] = 0;
+	}
+	return true;
+}
+
+}
+
+sigma_bool_t SIGMAAPI plugin_plugin(TPluginSettings * settings)
+{
+	if (settings->size != sizeof *settings
+		|| settings->version != PLUGIN_API_VERSION)
+	{
+		return false;
+	}
+
+	settings->plugin_init = init;
+	settings->plugin_free = cleanup;
+	settings->plugin_caption = "Omicron analyzer plugin";
+	settings->plugin_aboutdialog = about;
+	settings->plugin_getinputinfo = getinputinfo;
+	settings->plugin_getinput = getinput;
+	g_settings = settings;
+	return true;
+}

sigma_plugin/sigma.h

+#ifndef ASIX_SIGMA_H
+#define ASIX_SIGMA_H
+
+#include <Windows.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SIGMAAPI __stdcall
+
+typedef uint32_t sigma_bool_t;
+
+#define mmFile 0
+#define mmView 1
+#define mmSettings 2
+#define mmPluginSettings 3
+
+typedef struct {
+	int32_t TopMenu; // mmFile..mmPluginSettings
+	char* Caption;
+	sigma_bool_t Checked;
+	sigma_bool_t Enabled;
+	char* ShurtCut;
+	void(SIGMAAPI *Notify)(void); // use stdcall
+} TPluginMenuItem;
+
+typedef struct {
+	// --- filled by caller of 'gettrace' function ---
+	uint32_t StartTimeLo; // All times in PU
+	int32_t StartTimeHi;
+	uint32_t PixelTimeLo;
+	int32_t PixelTimeHi;
+	int32_t ViewWidth;
+
+	// --- filled by called function ---
+	// arrays below allocated by caller
+	int32_t BoundaryMin, BoundaryMax; // minimum and maximum trace values
+	int32_t *MinArray, *MaxArray; // array of values; array length is ViewWidth
+	int32_t TextCount; // number of texts � length of arrays below
+	// arrays below allocated by called (remains allocated until next call of any function)
+	char **TextTexts; // array of char*
+	int32_t *TextPositions; // array center positions of texts, in pixels
+	int32_t *TextMaxWidths; // array of maximum widths of texts, in pixels
+	uint32_t *TextFlags; // array of flags; currently ignored, set to NULL
+	sigma_bool_t BusStyle;
+} TPluginTraceSnapshot;
+
+typedef struct {
+	// --- filled by caller of 'gettrace' function ---
+	uint32_t StartTimeLo; // All times in PU
+	int32_t StartTimeHi;
+	uint32_t PixelTimeLo;
+	int32_t PixelTimeHi;
+	int32_t ViewWidth;
+	// --- filled by called function ---
+	// arrays allocated by caller
+	int32_t BoundaryMin, BoundaryMax; // minimum and maximum trace values
+	int32_t *MinArray, *MaxArray; // array of values; array length is ViewWidth
+} TPluginInputSnapshot;
+
+#define hsBackground 0
+#define hsSelection 1
+#define hsLine 2
+#define hsTopLine 3
+#define hsText 4
+
+typedef struct {
+	int32_t Tag; // allowed is -1 and 0x0000..0xFFFF
+	int32_t Style; // style hsBackground..hsText
+	uint32_t Color;
+	int32_t TraceNumber; // -1 means all
+	// SelectTime[0]=-1 means no (remove) selection
+	// SelectTime[1] is applicable only for hsBackground and hsLine
+	struct { uint32_t Lo; int32_t Hi; } SelectTime[2];
+	int32_t SelectSampleValue[2]; // applicable only if TraceNumber is not -1
+	char *Text;
+} TPluginHighlightRange;
+
+#define ttBus 1
+#define ttInput 2
+#define ttTrace 4
+
+typedef struct {
+	char *Caption;
+	int32_t TraceType; // ttBus, ttInput or ttTrace
+	int32_t InputCount;
+	int32_t Inputs[1]; // InputCount integers � input ids
+} TNewTraceInfo;
+
+typedef struct {
+	uint32_t TimeLo; // time in PU
+	int32_t TimeHi;
+	int32_t min, max;
+} TPluginRawInputField;
+
+typedef struct {
+	uint32_t StartTimeLo; // All times in PU
+	int32_t StartTimeHi;
+	uint32_t PixelTimeLo;
+	int32_t PixelTimeHi;
+	int32_t ViewWidth; // visible area of viewer window, in pixels
+	POINT ViewerScreenPoint; // POINT is WINAPI defined structure
+} TPluginViewRange;
+
+#define PLUGIN_API_VERSION 0x00000001
+
+typedef struct {
+	// ------- filled by application, must be checked by plugin ---------
+	int32_t size; // set to sizeof this structure
+	int32_t version; // set to PLUGIN_API_VERSION
+
+	// -------- filled by application ---------
+	HWND hWND; // handle of viewer's window
+	int32_t pluginID; // plugin ID stored in upper 16bits
+	void (SIGMAAPI * sethighlightrange)(TPluginHighlightRange *range);
+	sigma_bool_t (SIGMAAPI * getintvalue)(char *ident, int32_t *value);
+	sigma_bool_t (SIGMAAPI * getstrvalue)(char *ident, int32_t *maxlen, char *value);
+	sigma_bool_t (SIGMAAPI * setintvalue)(char *ident, int32_t value);
+	sigma_bool_t (SIGMAAPI * setstrvalue)(char *ident, char *value);
+	sigma_bool_t (SIGMAAPI * registerintvalue)(char *ident, int32_t default, sigma_bool_t cansave, sigma_bool_t loaddef, sigma_bool_t loadnow, sigma_bool_t filesave); // returns wheather value already existed
+	sigma_bool_t (SIGMAAPI * registerstrvalue)(char *ident, char *default, sigma_bool_t cansave, sigma_bool_t loaddef, sigma_bool_t loadnow, sigma_bool_t filesave); // returns wheather value already existed
+	sigma_bool_t (SIGMAAPI * gettrace)(int32_t index, TPluginTraceSnapshot *snapshot);
+	sigma_bool_t (SIGMAAPI * gettraceinfo)(int32_t index, int32_t *maxlen, char *value);
+	sigma_bool_t (SIGMAAPI * getinput)(int32_t id, TPluginInputSnapshot *snapshot); // currently only analyzer inputs are supported
+	sigma_bool_t (SIGMAAPI * getinputinfo)(int32_t index, int32_t *maxlen, char *value, int32_t *id); // currently only analyzer inputs are supported
+	sigma_bool_t (SIGMAAPI * getanalyzerraw)(int32_t id, int32_t start, int32_t *len, void *raw); // FIXME: this is incorrect
+	void (SIGMAAPI * getanalyzerrawlength)(int32_t *maxlen);
+	sigma_bool_t (SIGMAAPI * sigma_readregister)(int32_t regaddr, int32_t *regdata);
+	sigma_bool_t (SIGMAAPI * sigma_writeregister)(int32_t regaddr, int32_t regdata);
+	sigma_bool_t (SIGMAAPI * sigma_configure)(void *configuration, int32_t configurationlength);
+	void *reserved1[8]; // reserved for future functions
+
+	// ---------- filled by plugin ----------
+	int32_t plugin_class; // 0 or -1 means without class
+	char *plugin_caption;
+	sigma_bool_t plugin_alwayswantsinputlist;
+	sigma_bool_t (SIGMAAPI * plugin_init)(uint32_t * allowStartup);
+	void (SIGMAAPI * plugin_free)(void);
+	void (SIGMAAPI * plugin_savesettings)(void);
+	void (SIGMAAPI * plugin_loadsettings)(void);
+	sigma_bool_t (SIGMAAPI * plugin_getmenuitem)(int32_t index, TPluginMenuItem *item);
+	sigma_bool_t (SIGMAAPI * plugin_getpopupitem)(int32_t index, TPluginMenuItem *item, TPluginViewRange *range, int32_t TraceCount, TNewTraceInfo *infos, POINT *mousePoint); // FIXME: check
+	void (SIGMAAPI * plugin_paintnotify)(TPluginViewRange *range, int32_t TraceCount, TNewTraceInfo *infos);
+	void (SIGMAAPI * plugin_updatehint)(TPluginViewRange *range, int32_t TraceCount, TNewTraceInfo *infos, int32_t *maxchar, char *text);
+	sigma_bool_t (SIGMAAPI * plugin_getinput)(int32_t id, TPluginInputSnapshot *snapshot);
+	sigma_bool_t (SIGMAAPI * plugin_gettrace)(int32_t id, TPluginTraceSnapshot *snapshot);
+	sigma_bool_t (SIGMAAPI * plugin_getinputinfo)(int32_t index, int32_t *id, int32_t *maxchar, char *name);
+	sigma_bool_t (SIGMAAPI * plugin_gettraceinfo)(int32_t index, int32_t *id, int32_t *maxchar, char *name);
+	void (SIGMAAPI * plugin_aboutdialog)(void);
+	void (SIGMAAPI * plugin_configdialog)(void);
+	void (SIGMAAPI * plugin_tracesconfigdialog)(void);
+} TPluginSettings;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

sigma_plugin/sigma_plugin.def

+EXPORTS
+	plugin_plugin

sigma_plugin/sigma_plugin.sln

+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sigma_plugin", "sigma_plugin.vcxproj", "{240C54AA-7139-4F3B-A549-B3521909E6D7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{240C54AA-7139-4F3B-A549-B3521909E6D7}.Debug|Win32.ActiveCfg = Debug|Win32
+		{240C54AA-7139-4F3B-A549-B3521909E6D7}.Debug|Win32.Build.0 = Debug|Win32
+		{240C54AA-7139-4F3B-A549-B3521909E6D7}.Release|Win32.ActiveCfg = Release|Win32
+		{240C54AA-7139-4F3B-A549-B3521909E6D7}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

sigma_plugin/sigma_plugin.vcxproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{240C54AA-7139-4F3B-A549-B3521909E6D7}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>sigma_plugin</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SIGMA_PLUGIN_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <ModuleDefinitionFile>sigma_plugin.def</ModuleDefinitionFile>
+    </Link>
+    <PostBuildEvent>
+      <Command>copy "$(TargetPath)" "c:\Program Files (x86)\ASIX\SIGMA"</Command>
+      <Message>Copying the plugin into the Sigma directory.</Message>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SIGMA_PLUGIN_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <ModuleDefinitionFile>sigma_plugin.def</ModuleDefinitionFile>
+    </Link>
+    <PostBuildEvent>
+      <Command>copy "$(TargetPath)" "c:\Program Files (x86)\ASIX\SIGMA"</Command>
+      <Message>Copying the plugin into the Sigma directory.</Message>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="sigma_plugin.def" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="main.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="sigma.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

sigma_plugin/sigma_plugin.vcxproj.filters

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <None Include="sigma_plugin.def" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="main.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="sigma.h" />
+  </ItemGroup>
+</Project>