summaryrefslogtreecommitdiff
path: root/ldmicro/includes/components
diff options
context:
space:
mode:
authorNatsuDrag92018-06-06 11:51:20 +0530
committerGitHub2018-06-06 11:51:20 +0530
commit003741ef327ab000986e6c5a3bc8ff058c171efc (patch)
tree860b10e7f01fdfc25be90aa0f6228fd6672cb333 /ldmicro/includes/components
parent8deab843fa6d616086955702c77751f631badc0d (diff)
parent42f0b6abf37b6afc278a218b8301b7d4f1f6b2cc (diff)
downloadLDMicroGtk-003741ef327ab000986e6c5a3bc8ff058c171efc.tar.gz
LDMicroGtk-003741ef327ab000986e6c5a3bc8ff058c171efc.tar.bz2
LDMicroGtk-003741ef327ab000986e6c5a3bc8ff058c171efc.zip
Merge pull request #3 from NatsuDrag9/GUI_port
Gui port 2
Diffstat (limited to 'ldmicro/includes/components')
-rw-r--r--ldmicro/includes/components/componentfunctions.h63
-rw-r--r--ldmicro/includes/components/componentimages.h53
-rw-r--r--ldmicro/includes/components/components.h51
-rw-r--r--ldmicro/includes/components/componentstructs.h62
4 files changed, 229 insertions, 0 deletions
diff --git a/ldmicro/includes/components/componentfunctions.h b/ldmicro/includes/components/componentfunctions.h
new file mode 100644
index 0000000..916bf00
--- /dev/null
+++ b/ldmicro/includes/components/componentfunctions.h
@@ -0,0 +1,63 @@
+#ifndef _COMPONENT_FUNCTIONS
+#define _COMPONENT_FUNCTIONS
+
+//Few Prerequisites
+extern HFONT MyNiceFont;
+extern HFONT MyFixedFont;
+extern HWND OkButton;
+extern HWND CancelButton;
+extern HINSTANCE* ComponentInstance;
+
+extern BOOL DlgDone;
+extern BOOL DlgCancel;
+extern HWND ComponentDialog;
+
+// Common Functions
+
+void FontNice(HWND h);
+void FontFixed(HWND h);
+HWND* CreateDialogWindow(LPCTSTR title, int x, int y, int width, int height, int style);
+void ShowDialogWindow(void);
+BOOL ProcessDialogWindow(void);
+
+/*Initialization Functions*/
+int InitSwitch(void* ComponentAddress);
+int InitRelay(void* ComponentAddress);
+int InitSpdt(void* ComponentAddress);
+int InitDpst(void* ComponentAddress);
+int InitDpdt(void* ComponentAddress);
+
+/*Event Handlers*/
+void HandleSwitchEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleRelayEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleSpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleDpstEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleDpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+
+/*Request Handlers*/
+double SwitchVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double RelayVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double SpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double DpstVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double DpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+
+/*Program Reference Functions*/
+void SetSwitchIds(int*, void*);
+void SetRelayIds(int*, void*);
+void SetSpdtIds(int*, void*);
+void SetDpstIds(int*, void*);
+void SetDpdtIds(int*, void*);
+
+// Relay Functions
+
+#endif
diff --git a/ldmicro/includes/components/componentimages.h b/ldmicro/includes/components/componentimages.h
new file mode 100644
index 0000000..27ef6ce
--- /dev/null
+++ b/ldmicro/includes/components/componentimages.h
@@ -0,0 +1,53 @@
+#ifndef __COMPONENTIMAGES_H
+#define __COMPONENTIMAGES_H
+
+#define SWITCH_CONNECTED 8000
+#define SWITCH_DISCONNECTED 8001
+#define RELAY_NC 8002
+#define RELAY_NO 8003
+#define SPDT_1 8004
+#define SPDT_2 8005
+#define DPST_1 8006
+#define DPST_2 8007
+#define DPDT_1 8008
+#define DPDT_2 8009
+
+
+
+#ifndef RC_INVOKED //Used to hide code from resource file(Guess)
+
+#define TOTAL_COMPONENTS 5
+#define COMPONENT_NAME_MAX_LENGTH 50
+
+// Try to keep ComponentID's between 6000 - 6999
+
+#define COMPONENT_SWITCH 6000
+#define COMPONENT_RELAY 6001
+#define COMPONENT_SPDT 6002
+#define COMPONENT_DPST 6003
+#define COMPONENT_DPDT 6004
+
+
+#define MAX_PIN_COUNT 10
+
+typedef struct ComponentDataTag{
+ int Index;
+ int ComponentId;
+ TCHAR ComponentName[COMPONENT_NAME_MAX_LENGTH];
+ int PinCount;
+ LPCTSTR PinNames[MAX_PIN_COUNT]; //Valid Number of images from below property
+}ComponentData;
+
+void RefreshImages();
+void SetImage(int Component, void *il);
+
+static ComponentData rgCompData[TOTAL_COMPONENTS] = {
+ {0, COMPONENT_SWITCH, TEXT("Switch"), 2, {"Input:", "Output:"}},
+ {1, COMPONENT_RELAY, TEXT("Relay"), 5, {"Coil1:", "Coil2:", "NO:", "COM:", "NC:"}},
+ {2, COMPONENT_SPDT, TEXT("SPDT"), 3, {"Input:", "Output1:", "Output2:"}},
+ {3, COMPONENT_DPST, TEXT("DPST"), 4, {"Input1:", "Input2:", "Output1:", "Output2:"}},
+ {4, COMPONENT_DPDT, TEXT("DPDT"), 6, {"Input1:", "Input2:", "Output11:", "Output12:", "Output21:", "Output22:"}}
+};
+
+#endif
+#endif
diff --git a/ldmicro/includes/components/components.h b/ldmicro/includes/components/components.h
new file mode 100644
index 0000000..810c2d2
--- /dev/null
+++ b/ldmicro/includes/components/components.h
@@ -0,0 +1,51 @@
+#ifndef _COMPONENTS_H
+#define _COMPONENTS_H
+
+#define EVENT_VALUE_CHANGED 0
+#define EVENT_MOUSE_CLICK 1
+#define EVENT_MOUSE_DOWN 2
+#define EVENT_MOUSE_UP 3
+#define EVENT_MOUSE_RDOWN 4
+#define EVENT_MOUSE_RUP 5
+#define EVENT_MOUSE_DBLCLICK 6
+#define EVENT_MOUSE_RCLICK 7
+
+
+
+#define SOURCE_PROGRAM_MAIN 1
+#define SOURCE_PROGRAM_NEW 2
+#define SOURCE_EVENT_MAIN 3
+#define SOURCE_EVENT_NEW 4
+#define SOURCE_FORCE_MAIN 5
+#define SOURCE_REQUEST_MAIN 6
+
+/*#define EVENT_KEY_DOWN 6
+#define EVENT_KEY_RELEASE 7
+#define EVENT_KEY_PRESS 8*/
+#define V_DIALOG_WIDTH 96
+#define V_DIALOG_HEIGHT 115
+#define H_DIALOG_WIDTH 179
+#define H_DIALOG_HEIGHT 85
+
+//Window styles for dialog box
+#define STYLE_HORIZONTAL 1
+#define STYLE_VERTICAL 2
+
+#define GND 0
+#define VOLT_5 5
+#define V_OPEN 4196
+
+int NotifyComponent(void *ComponentAddress, void* PinName, int ComponentId, int Event,
+ BOOL SimulationStarted, HWND* h, int Index, UINT ImageId, void* ImageLocation);
+int InitializeComponentProperties(void *ComponentAddress, int ComponentId);
+double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, int Index,
+ double Volt, int Source, void* ImageLocation);
+
+double VoltRequest(int PinId, void* ComponentAddress);
+// void RequestData(void* ComponentAddress);
+// double GlobalVoltChange(int PinId, void *ComponentAddress, double volt);
+double VoltChange(int PinId, int Index, void* ComponentAddress, double Volt);
+size_t GetStructSize(int ComponentId);
+size_t GetNameSize(int ComponentId);
+
+#endif
diff --git a/ldmicro/includes/components/componentstructs.h b/ldmicro/includes/components/componentstructs.h
new file mode 100644
index 0000000..76dadda
--- /dev/null
+++ b/ldmicro/includes/components/componentstructs.h
@@ -0,0 +1,62 @@
+#ifndef _COMPONENT_STRUCTS
+#define _COMPONENT_STRUCTS
+
+typedef struct SwitchStructTag
+{
+ int id;
+ int Image;
+ BOOL Latched; //Temporary/Latched Action
+ BOOL NOpen; //Initial Open/Closed position
+ BOOL Open;
+ char Name[15];
+ double Volt[2];
+ int PinId[2];
+}SwitchStruct;
+
+typedef struct RelayStructTag
+{
+ int id;
+ int Image;
+ BOOL NC; //Whether relay is operated
+ double MinOperatingVolt; //Operating voltage
+ double MaxOperatingVolt;
+ double CoilVolt1; //Voltage at input pin
+ double CoilVolt2; //Voltage at input pin
+ double COMVolt; //Voltage at COM pin
+ double NOVolt; //Voltage at NO pin
+ double NCVolt; //Voltage at NC pin
+ int PinId[5];
+
+}RelayStruct;
+
+typedef struct SpdtStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NO1; //Whether Output 1 is connected
+ double Volt[3]; //Voltage at Input, Output1, Output2 respectively
+ int PinId[3];
+}SpdtStruct;
+
+typedef struct DpstStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NO; //Whether the inputs and outputs are disconnected (Open)
+ double Volt[4]; // Voltage at Input1, Input2, Output1, Output2 respectively
+ int PinId[4];
+}DpstStruct;
+
+typedef struct DpdtStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NS1; //Whether the inputs and outputs are connected in state 1
+ double Volt[6]; // Voltage at Input1, Input2, Output11, Output12, Output21, Output22 respectively
+ int PinId[6];
+}DpdtStruct;
+
+#endif