Commit 7a828f44 authored by Ivan Tyagov's avatar Ivan Tyagov

Remove traces from OPC-UA client from modbus example.

parent a671c0ee
...@@ -256,7 +256,7 @@ typedef struct{ ...@@ -256,7 +256,7 @@ typedef struct{
static client_node_t client_nodes[NUMBER_OF_CLIENT_NODES] = { static client_node_t client_nodes[NUMBER_OF_CLIENT_NODES] = {
/*node 0.0*/ /*node 0.0*/
{"0.0", "Modbus TCP Client 0.0", "192.168.0.110", "502", {naf_tcp, {.tcp = {NULL, NULL, DEF_CLOSE_ON_SILENCE}}}, -1 /* mb_nd */, 0 /* init_state */, 1000 /* communication period */, 0 /* prev_error */} {"0.0", "Modbus TCP Client 0.0", "192.168.0.78", "1502", {naf_tcp, {.tcp = {NULL, NULL, DEF_CLOSE_ON_SILENCE}}}, -1 /* mb_nd */, 0 /* init_state */, 1000 /* communication period */, 0 /* prev_error */}
}; };
......
...@@ -234,14 +234,14 @@ void COUNTERST_body__(COUNTERST *data__) { ...@@ -234,14 +234,14 @@ void COUNTERST_body__(COUNTERST *data__) {
} else { } else {
__SET_VAR(data__->,CNT0,,(__GET_VAR(data__->CNT0,) + 1)); __SET_VAR(data__->,CNT0,,(__GET_VAR(data__->CNT0,) + 1));
__SET_VAR(data__->,CNT1,,(__GET_VAR(data__->CNT1,) + 1)); __SET_VAR(data__->,CNT1,,(__GET_VAR(data__->CNT1,) + 1));
if ((__GET_VAR(data__->CNT1,) > 5)) { if ((__GET_VAR(data__->CNT1,) > 10)) {
__SET_EXTERNAL(data__->,RELAY0VALUE,,__BOOL_LITERAL(TRUE)); __SET_EXTERNAL(data__->,RELAY0VALUE,,__BOOL_LITERAL(TRUE));
__SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(TRUE)); __SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(TRUE));
} else { } else {
__SET_EXTERNAL(data__->,RELAY0VALUE,,__BOOL_LITERAL(TRUE)); __SET_EXTERNAL(data__->,RELAY0VALUE,,__BOOL_LITERAL(TRUE));
__SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(FALSE)); __SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(FALSE));
}; };
if ((__GET_VAR(data__->CNT1,) > 7)) { if ((__GET_VAR(data__->CNT1,) > 15)) {
__SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(FALSE)); __SET_EXTERNAL(data__->,RELAY1VALUE,,__BOOL_LITERAL(FALSE));
__SET_VAR(data__->,CNT1,,0); __SET_VAR(data__->,CNT1,,0);
}; };
......
...@@ -26,5 +26,10 @@ int LogMessage(uint8_t level, char* buf, uint32_t size); ...@@ -26,5 +26,10 @@ int LogMessage(uint8_t level, char* buf, uint32_t size);
#endif #endif
long AtomicCompareExchange(long* atomicvar,long compared, long exchange); long AtomicCompareExchange(long* atomicvar,long compared, long exchange);
void *create_RT_to_nRT_signal(char* name);
void delete_RT_to_nRT_signal(void* handle);
int wait_RT_to_nRT_signal(void* handle);
int unblock_RT_to_nRT_signal(void* handle);
void nRT_reschedule(void);
#endif #endif
...@@ -25,7 +25,7 @@ FUNCTION_BLOCK CounterST ...@@ -25,7 +25,7 @@ FUNCTION_BLOCK CounterST
ELSE ELSE
Cnt0 := Cnt0 + 1; Cnt0 := Cnt0 + 1;
Cnt1 := Cnt1 + 1; Cnt1 := Cnt1 + 1;
IF Cnt1 > 5 THEN IF Cnt1 > 10 THEN
Relay0Value := True; Relay0Value := True;
Relay1Value := True; Relay1Value := True;
ELSE ELSE
...@@ -33,7 +33,7 @@ FUNCTION_BLOCK CounterST ...@@ -33,7 +33,7 @@ FUNCTION_BLOCK CounterST
Relay1Value := False; Relay1Value := False;
END_IF; END_IF;
IF Cnt1 > 7 THEN IF Cnt1 > 15 THEN
Relay1Value := False; Relay1Value := False;
Cnt1 :=0; Cnt1 :=0;
END_IF; END_IF;
......
6e1af784c3e7b7bca21bc2147e065019 680fbe404b11a44c9877be3f7ae5b1fb
\ No newline at end of file \ No newline at end of file
...@@ -119,7 +119,7 @@ FUNCTION_BLOCK CounterST ...@@ -119,7 +119,7 @@ FUNCTION_BLOCK CounterST
ELSE ELSE
Cnt0 := Cnt0 + 1; Cnt0 := Cnt0 + 1;
Cnt1 := Cnt1 + 1; Cnt1 := Cnt1 + 1;
IF Cnt1 > 5 THEN IF Cnt1 > 10 THEN
Relay0Value := True; Relay0Value := True;
Relay1Value := True; Relay1Value := True;
ELSE ELSE
...@@ -127,7 +127,7 @@ FUNCTION_BLOCK CounterST ...@@ -127,7 +127,7 @@ FUNCTION_BLOCK CounterST
Relay1Value := False; Relay1Value := False;
END_IF; END_IF;
IF Cnt1 > 7 THEN IF Cnt1 > 15 THEN
Relay1Value := False; Relay1Value := False;
Cnt1 :=0; Cnt1 :=0;
END_IF; END_IF;
......
...@@ -323,7 +323,7 @@ int WaitPythonCommands(void) ...@@ -323,7 +323,7 @@ int WaitPythonCommands(void)
/* Called by PLC thread on each new python command*/ /* Called by PLC thread on each new python command*/
void UnBlockPythonCommands(void) void UnBlockPythonCommands(void)
{ {
/* signal debugger thread it can read data */ /* signal python thread it can read data */
pthread_mutex_unlock(&python_wait_mutex); pthread_mutex_unlock(&python_wait_mutex);
} }
...@@ -342,6 +342,60 @@ void LockPython(void) ...@@ -342,6 +342,60 @@ void LockPython(void)
pthread_mutex_lock(&python_mutex); pthread_mutex_lock(&python_mutex);
} }
struct RT_to_nRT_signal_s {
pthread_cond_t WakeCond;
pthread_mutex_t WakeCondLock;
};
typedef struct RT_to_nRT_signal_s RT_to_nRT_signal_t;
#define _LogAndReturnNull(text) \
{\
char mstr[256] = text " for ";\
strncat(mstr, name, 255);\
LogMessage(LOG_CRITICAL, mstr, strlen(mstr));\
return NULL;\
}
void *create_RT_to_nRT_signal(char* name){
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)malloc(sizeof(RT_to_nRT_signal_t));
if(!sig)
_LogAndReturnNull("Failed allocating memory for RT_to_nRT signal");
pthread_cond_init(&sig->WakeCond, NULL);
pthread_mutex_init(&sig->WakeCondLock, NULL);
return (void*)sig;
}
void delete_RT_to_nRT_signal(void* handle){
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle;
pthread_cond_destroy(&sig->WakeCond);
pthread_mutex_destroy(&sig->WakeCondLock);
free(sig);
}
int wait_RT_to_nRT_signal(void* handle){
int ret;
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle;
pthread_mutex_lock(&sig->WakeCondLock);
ret = pthread_cond_wait(&sig->WakeCond, &sig->WakeCondLock);
pthread_mutex_unlock(&sig->WakeCondLock);
return ret;
}
int unblock_RT_to_nRT_signal(void* handle){
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle;
return pthread_cond_signal(&sig->WakeCond);
}
void nRT_reschedule(void){
sched_yield();
}
/* /*
This file is part of Beremiz, a Integrated Development Environment for This file is part of Beremiz, a Integrated Development Environment for
programming IEC 61131-3 automates supporting plcopen standard and CanFestival. programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
......
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<ModbusTCPclient xmlns:xsd="http://www.w3.org/2001/XMLSchema" Configuration_Name="Modbus TCP Client 0.0" Remote_IP_Address="192.168.0.110" Invocation_Rate_in_ms="1000"/> <ModbusTCPclient xmlns:xsd="http://www.w3.org/2001/XMLSchema" Configuration_Name="Modbus TCP Client 0.0" Remote_IP_Address="192.168.0.78" Invocation_Rate_in_ms="1000" Remote_Port_Number="1502"/>
<?xml version='1.0' encoding='utf-8'?>
<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="1" Name="opcua_0"/>
<?xml version='1.0' encoding='utf-8'?>
<OPCUAClient xmlns:xsd="http://www.w3.org/2001/XMLSchema" Server_URI="opc.tcp://192.168.0.78:4840"/>
input,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 0)",1,str,relay0,Int32,0
input,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 1)",1,str,relay1,Int32,1
input,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 2)",1,str,relay2,Int32,2
input,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 3)",1,str,relay3,Int32,3
output,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 0)",1,str,relay0,Int32,0
output,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 1)",1,str,relay1,Int32,1
output,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 2)",1,str,relay2,Int32,2
output,"LocalizedText(Encoding:3, Locale:en-US, Text:Relay 3)",1,str,relay3,Int32,3
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201"> <project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2021-05-14T14:33:11"/> <fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2021-05-14T14:33:11"/>
<contentHeader name="Counter (OSIE)" modificationDateTime="2021-06-03T16:47:18"> <contentHeader name="Counter (OSIE)" modificationDateTime="2021-10-22T15:53:30">
<coordinateInfo> <coordinateInfo>
<fbd> <fbd>
<scaling x="0" y="0"/> <scaling x="0" y="0"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment