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

Final merge #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions ldmicro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ LDOBJS = $(OBJDIR)\ldmicro.obj \

COMPOBJS = $(OBJDIR)\components.obj \
$(OBJDIR)\switch.obj \
$(OBJDIR)\relay.obj

$(OBJDIR)\relay.obj \
$(OBJDIR)\spdt.obj \
$(OBJDIR)\dpst.obj \
$(OBJDIR)\dpdt.obj

HELPOBJ = $(OBJDIR)\helptext.obj

Expand Down Expand Up @@ -76,7 +78,7 @@ all: $(OBJDIR)/ldmicro.exe $(OBJDIR)/ldinterpret.exe

clean:
rm -rf $(LDOBJS) $(COMPOBJS) $(CLEANOBJ)
rmdir reg\results
rmdir reg\results

lang.cpp: $(OBJDIR)/lang-tables.h

Expand Down
18 changes: 18 additions & 0 deletions ldmicro/components/componentfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,40 @@ 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

Expand Down
18 changes: 16 additions & 2 deletions ldmicro/components/componentimages.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@
#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 2
#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
Expand All @@ -32,7 +43,10 @@ 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:"}}
{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
Expand Down
47 changes: 47 additions & 0 deletions ldmicro/components/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ size_t GetStructSize(int ComponentId)
break;
case COMPONENT_RELAY:
return sizeof(RelayStruct);
break;
case COMPONENT_SPDT:
return sizeof(SpdtStruct);
break;
case COMPONENT_DPST:
return sizeof(DpstStruct);
break;
case COMPONENT_DPDT:
return sizeof(DpdtStruct);
break;
}
return (size_t)-1;
}
Expand All @@ -64,6 +73,15 @@ int InitializeComponentProperties(void *ComponentAddress, int ComponentId)
case COMPONENT_RELAY:
return InitRelay(ComponentAddress);
break;
case COMPONENT_SPDT:
return InitSpdt(ComponentAddress);
break;
case COMPONENT_DPST:
return InitDpst(ComponentAddress);
break;
case COMPONENT_DPDT:
return InitDpdt(ComponentAddress);
break;
}
return 0;
}
Expand All @@ -81,6 +99,16 @@ double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, in
break;
case COMPONENT_RELAY:
return RelayVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation);
break;
case COMPONENT_SPDT:
return SpdtVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation);
break;
case COMPONENT_DPST:
return DpstVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation);
break;
case COMPONENT_DPDT:
return DpdtVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation);
break;
}
return Volt;
}
Expand All @@ -97,6 +125,16 @@ void SetPinIds(int Index, void *PinName,int ComponentId, void *ComponentAddres
break;
case COMPONENT_RELAY:
SetRelayIds(PinIds,ComponentAddress);
break;
case COMPONENT_SPDT:
SetSpdtIds(PinIds, ComponentAddress);
break;
case COMPONENT_DPST:
SetDpstIds(PinIds, ComponentAddress);
break;
case COMPONENT_DPDT:
SetDpdtIds(PinIds, ComponentAddress);
break;
}
}
}
Expand Down Expand Up @@ -125,6 +163,15 @@ int NotifyComponent(void *ComponentAddress, void *PinName, int ComponentId,
HandleRelayEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h);
// return InitRelay(ComponentAddress);
break;
case COMPONENT_SPDT:
HandleSpdtEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h);
break;
case COMPONENT_DPST:
HandleDpstEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h);
break;
case COMPONENT_DPDT:
HandleDpdtEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h);
break;
}
// return voltage
return 0;
Expand Down
34 changes: 32 additions & 2 deletions ldmicro/components/componentstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,39 @@ typedef struct RelayStructTag
double CoilVolt2; //Voltage at input pin
double COMVolt; //Voltage at COM pin
double NOVolt; //Voltage at NO pin
double NCVolt;
int PinId[5]; //Voltage at NC 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
Loading