-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
166 additions
and
79 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.10 $ | ||
* Version: $Revision: 1.11 $ | ||
*/ | ||
|
||
#ifndef _RTL_PLC_CRESULT | ||
|
@@ -66,7 +66,7 @@ | |
* @param dt Specified data type | ||
* @param op Implemented operator (+,-,/ ....) | ||
*/ | ||
#define CResultOp(dt, op) case DT_##dt: InternalData.m_##dt##_Value op##= Value.InternalData.m_##dt##_Value; break; | ||
#define CResultOp(dt, op) case DT_##dt: this->InternalData.m_##dt##_Value op##= Value.Result##dt(); break; | ||
|
||
/** | ||
* Macro for short implementation of comparing operators | ||
|
@@ -75,7 +75,7 @@ | |
* @param dt Specified data type | ||
* @param op Implemented operator (<,<=,==, ...) | ||
*/ | ||
#define CResultCmpOp(dt, op) case DT_##dt: return(InternalData.m_##dt##_Value op Value.InternalData.m_##dt##_Value); break; | ||
#define CResultCmpOp(dt, op) case DT_##dt: return(InternalData.m_##dt##_Value op Value.Result##dt()); break; | ||
|
||
/** | ||
* Macro for short implementation when getting | ||
|
@@ -85,6 +85,7 @@ | |
* @param dt Internaly stored data type | ||
*/ | ||
#define CResultGV(dt) case DT_##dt: Var = (DataType) InternalData.m_##dt##_Value; break; | ||
|
||
/** | ||
* Macro for short implementation when getting | ||
* negated current result into CVariable<> or CProperty<> | ||
|
@@ -93,13 +94,46 @@ | |
* @param dt Internaly stored data type | ||
*/ | ||
#define CResultNegGV(dt) case DT_##dt: Var = ~((DataType) InternalData.m_##dt##_Value); break; | ||
/** | ||
|
||
/** | ||
* Macro for short implementation when getting internaly | ||
* stored value in operators | ||
* | ||
* @param idt Internal data type stored in result | ||
* @param rdt Requested data type into which convert result | ||
*/ | ||
#define CResultDT(idt, rdt) case DT_##idt: return ((rdt) (this->InternalData.m_##idt##_Value)); break; | ||
/** | ||
* Macro for short implementation when getting current | ||
* value of result converted to specified datatype | ||
* | ||
* @param dt Requested datatype | ||
*/ | ||
#define ImplementResult(dt) dt Result##dt(void) const \ | ||
{\ | ||
switch(m_iStoredDataType) \ | ||
{\ | ||
CResultDT(SINT, dt);\ | ||
CResultDT(INT, dt);\ | ||
CResultDT(DINT, dt);\ | ||
CResultDT(USINT, dt);\ | ||
CResultDT(UINT, dt);\ | ||
CResultDT(UDINT, dt);\ | ||
CResultDT(REAL, dt);\ | ||
CResultDT(TIME, dt);\ | ||
CResultDT(BYTE, dt);\ | ||
CResultDT(WORD, dt);\ | ||
CResultDT(DWORD, dt);\ | ||
}\ | ||
return ((dt)0);\ | ||
} | ||
/** | ||
* This class implements result functionality for PLC | ||
* IL language operations. | ||
* All operations (comparisions, additions, multiplications...) | ||
* are defined here as operators | ||
* | ||
* @version $Revision: 1.10 $ | ||
* @version $Revision: 1.11 $ | ||
* @author Voloda <[email protected]> | ||
*/ | ||
class CResult | ||
|
@@ -127,10 +161,27 @@ | |
TOD m_todValue; | ||
DT m_dtValue; | ||
*/ | ||
BYTE m_bValue; | ||
WORD m_wValue; | ||
DWORD m_dwValue; | ||
BYTE m_BYTE_Value; | ||
WORD m_WORD_Value; | ||
DWORD m_DWORD_Value; | ||
} InternalData; | ||
|
||
/* | ||
* Implementation of functions, which returns | ||
* internal value converted into specified datatype | ||
*/ | ||
ImplementResult(SINT); | ||
ImplementResult(INT); | ||
ImplementResult(DINT); | ||
ImplementResult(USINT); | ||
ImplementResult(UINT); | ||
ImplementResult(UDINT); | ||
ImplementResult(REAL); | ||
ImplementResult(TIME); | ||
ImplementResult(BYTE); | ||
ImplementResult(WORD); | ||
ImplementResult(DWORD); | ||
|
||
/** | ||
* Contain information about current data type | ||
* stored in result object as defined in | ||
|
@@ -278,7 +329,7 @@ | |
* kernel space. Returns current value | ||
* stored in result | ||
*/ | ||
if (InternalData.m_REAL_Value == 0) | ||
if (Value.ResultINT() == 0) | ||
{ | ||
rtl_printf("SoftwarePLC: Division by zerp detected, returned result is wrong!"); | ||
return (*this); | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.6 $ | ||
* Version: $Revision: 1.7 $ | ||
*/ | ||
|
||
#include "include/ccodeprocessor.h" | ||
|
@@ -107,7 +107,10 @@ void CContainerConfiguration :: GenerateCode(int iType) | |
// generate module initialization routine | ||
// --- | ||
CurrentOutput << "\n\nint init_module(void)\n{\n"; | ||
CurrentOutput << "\tint iRetv = 0, iCount = 0;\n\n\t__do_global_ctors_aux();\n\n"; | ||
CurrentOutput << "\tint iRetv = 0, iCount = 0;\npthread_attr_t\tattr;\n\n\t__do_global_ctors_aux();\n\n"; | ||
|
||
CurrentOutput << "\tpthread_attr_init(&attr);\n\tpthread_attr_setfp_np(&attr, 1);\n\n"; | ||
|
||
// generate code for task thread | ||
// initializations (module initialization) | ||
m_pPCalls->GenerateCode(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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.10 $ | ||
* Version: $Revision: 1.11 $ | ||
*/ | ||
|
||
#include <iostream> | ||
|
@@ -159,7 +159,7 @@ void CContainerPCall :: GenerateCode(int iCodePart) | |
break; | ||
// generates program call thread initialization | ||
case 1: | ||
CurrentOutput << "\tiRetv += pthread_create(&threads[iCount++], NULL, PCall" << m_sBlockName.c_str() << ", NULL);\n"; | ||
CurrentOutput << "\tiRetv += pthread_create(&threads[iCount++], &attr, PCall" << m_sBlockName.c_str() << ", NULL);\n"; | ||
break; | ||
} | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.2 $ | ||
* Version: $Revision: 1.3 $ | ||
*/ | ||
|
||
#ifndef _CVisualisationCanvas_H_ | ||
|
@@ -41,6 +41,7 @@ | |
wxFrame *m_pParent; | ||
|
||
void DrawAxes(wxDC& dc); | ||
void WriteText(wxDC &dc, const wxString &sText, int iYMiddle, int iXMax); | ||
void OnSize(wxSizeEvent& event); | ||
void OnTimer(wxTimerEvent &event); | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.2 $ | ||
* Version: $Revision: 1.3 $ | ||
*/ | ||
|
||
#ifndef _CVisualisationMain_H_ | ||
|
@@ -43,7 +43,6 @@ | |
|
||
wxSpinCtrl *m_RotPerSec; | ||
CVisualisationCanvas *m_Canvas; | ||
wxStaticText *m_RotPerSecAct; | ||
|
||
DECLARE_EVENT_TABLE() | ||
}; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Author: Vladimir Kloz <[email protected]> | ||
* Project home: http://sourceforge.net/projects/softwareplc | ||
* Version: $Revision: 1.2 $ | ||
* Version: $Revision: 1.3 $ | ||
*/ | ||
|
||
#include <sys/types.h> | ||
|
@@ -70,7 +70,7 @@ void CMeasureThread :: ResetDriver(void) | |
write(m_iControl, &Control, sizeof(Control)); | ||
|
||
Control.Command = PLC_SEND_SET_TIME; | ||
Control.iTime = 20; | ||
Control.iTime = 50; | ||
|
||
write(m_iControl, &Control, sizeof(Control)); | ||
} | ||
|
@@ -115,9 +115,15 @@ void *CMeasureThread :: Entry() | |
} | ||
else if (pBuff[0] == 'O') | ||
{ | ||
int iValue; | ||
|
||
iValue = *(int *)(pBuff + 1); | ||
|
||
m_pProcessVariable->Lock(); | ||
m_pProcessVariable->AddValue(*((int *) (pBuff + 1))); | ||
m_pProcessVariable->AddValue(iValue); | ||
m_pProcessVariable->Unlock(); | ||
|
||
// cout << "Value: " << iValue << "\n"; | ||
} | ||
else | ||
ResetDriver(); | ||
|
Oops, something went wrong.