Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
861b0a9b
Commit
861b0a9b
authored
Nov 03, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OneWire, generic ao device added
parent
3f561ce6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
346 additions
and
9 deletions
+346
-9
otherio/lib/rt/src/os_linux/rt_io_m_onewire.h
otherio/lib/rt/src/os_linux/rt_io_m_onewire.h
+5
-0
otherio/lib/rt/src/os_linux/rt_io_m_onewire_aodevice.c
otherio/lib/rt/src/os_linux/rt_io_m_onewire_aodevice.c
+220
-0
otherio/lib/rt/src/rt_io_otherio.meth
otherio/lib/rt/src/rt_io_otherio.meth
+1
-0
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+120
-9
No files found.
otherio/lib/rt/src/os_linux/rt_io_m_onewire.h
View file @
861b0a9b
...
...
@@ -13,4 +13,9 @@ typedef struct {
int
interval_cnt
;
}
io_sLocalAiDevice
;
typedef
struct
{
FILE
*
value_fp
;
int
interval_cnt
;
}
io_sLocalAoDevice
;
#endif
otherio/lib/rt/src/os_linux/rt_io_m_onewire_aodevice.c
0 → 100644
View file @
861b0a9b
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_io_m_onewire_aodevice.c -- I/O methods for class OneWire_AoDevice. */
#include <float.h>
#include <math.h>
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
#include "rt_io_m_onewire.h"
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
pwr_sClass_OneWire_AoDevice
*
op
=
(
pwr_sClass_OneWire_AoDevice
*
)
cp
->
op
;
io_sLocalAoDevice
*
local
;
pwr_tStatus
sts
;
char
name
[
40
];
pwr_tFileName
fname
,
tmp
;
int
name_len
;
char
*
s
;
if
(
cp
->
chanlist
[
0
].
cop
)
{
local
=
(
io_sLocalAoDevice
*
)
calloc
(
1
,
sizeof
(
io_sLocalAoDevice
));
cp
->
Local
=
local
;
sprintf
(
name
,
"%d-%012x"
,
op
->
Family
,
op
->
Super
.
Address
);
name_len
=
strlen
(
name
);
strncpy
(
fname
,
op
->
DataFile
,
sizeof
(
fname
));
// Replace all '%s' with 'family-serialnumber'
s
=
fname
;
while
(
(
s
=
strstr
(
s
,
"%s"
)))
{
strncpy
(
tmp
,
s
+
2
,
sizeof
(
tmp
));
strcpy
(
s
,
name
);
strncat
(
fname
,
tmp
,
sizeof
(
fname
));
}
local
->
value_fp
=
fopen
(
fname
,
"w"
);
if
(
!
local
->
value_fp
)
{
errh_Error
(
"OneWire_AoDevice Unable op open %s, '%ux'"
,
cp
->
Name
,
op
->
Super
.
Address
);
sts
=
IO__INITFAIL
;
op
->
Status
=
sts
;
return
sts
;
}
io_AoRangeToCoef
(
&
cp
->
chanlist
[
0
]);
errh_Info
(
"Init of OneWire_AoDevice '%s'"
,
cp
->
Name
);
}
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoCardClose
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sLocalAoDevice
*
local
=
(
io_sLocalAoDevice
*
)
cp
->
Local
;
if
(
cp
->
chanlist
[
0
].
cop
)
{
fclose
(
local
->
value_fp
);
}
free
(
cp
->
Local
);
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sLocalAoDevice
*
local
=
(
io_sLocalAoDevice
*
)
cp
->
Local
;
pwr_sClass_OneWire_AoDevice
*
op
=
(
pwr_sClass_OneWire_AoDevice
*
)
cp
->
op
;
char
str
[
80
];
pwr_tUInt32
error_count
=
op
->
Super
.
ErrorCount
;
int
num
;
if
(
op
->
ScanInterval
>
1
)
{
if
(
local
->
interval_cnt
!=
0
)
{
local
->
interval_cnt
++
;
if
(
local
->
interval_cnt
>=
op
->
ScanInterval
)
local
->
interval_cnt
=
0
;
return
IO__SUCCESS
;
}
local
->
interval_cnt
++
;
}
if
(
cp
->
chanlist
[
0
].
cop
&&
cp
->
chanlist
[
0
].
sop
)
{
io_sChannel
*
chanp
=
&
cp
->
chanlist
[
0
];
pwr_sClass_ChanAo
*
cop
=
(
pwr_sClass_ChanAo
*
)
chanp
->
cop
;
pwr_sClass_Ao
*
sop
=
(
pwr_sClass_Ao
*
)
chanp
->
sop
;
if
(
cop
->
CalculateNewCoef
)
// Request to calculate new coefficients
io_AoRangeToCoef
(
chanp
);
switch
(
op
->
ChAo
.
Representation
)
{
case
pwr_eDataRepEnum_Float32
:
case
pwr_eDataRepEnum_Float64
:
{
pwr_tFloat32
fvalue
;
fvalue
=
*
(
pwr_tFloat32
*
)
cp
->
chanlist
[
0
].
vbp
*
cop
->
OutPolyCoef1
+
cop
->
OutPolyCoef0
;
if
(
fvalue
>
cop
->
ActValRangeHigh
)
fvalue
=
cop
->
ActValRangeHigh
;
else
if
(
fvalue
<
cop
->
ActValRangeLow
)
fvalue
=
cop
->
ActValRangeLow
;
if
(
fvalue
>
0
)
sop
->
RawValue
=
fvalue
+
0
.
5
;
else
sop
->
RawValue
=
fvalue
-
0
.
5
;
if
(
strcmp
(
op
->
Format
,
""
)
==
0
)
num
=
snprintf
(
str
,
sizeof
(
str
),
"%f"
,
fvalue
);
else
num
=
snprintf
(
str
,
sizeof
(
str
),
op
->
Format
,
fvalue
);
if
(
num
!=
1
)
op
->
Super
.
ErrorCount
++
;
break
;
}
default:
{
pwr_tInt32
ivalue
;
pwr_tFloat32
fvalue
;
fvalue
=
*
(
pwr_tFloat32
*
)
cp
->
chanlist
[
0
].
vbp
*
cop
->
OutPolyCoef1
+
cop
->
OutPolyCoef0
;
if
(
fvalue
>
cop
->
ActValRangeHigh
)
fvalue
=
cop
->
ActValRangeHigh
;
else
if
(
fvalue
<
cop
->
ActValRangeLow
)
fvalue
=
cop
->
ActValRangeLow
;
if
(
fvalue
>
0
)
ivalue
=
sop
->
RawValue
=
fvalue
+
0
.
5
;
else
ivalue
=
sop
->
RawValue
=
fvalue
-
0
.
5
;
if
(
strcmp
(
op
->
Format
,
""
)
==
0
)
num
=
snprintf
(
str
,
sizeof
(
str
),
"%d"
,
ivalue
);
else
num
=
snprintf
(
str
,
sizeof
(
str
),
op
->
Format
,
ivalue
);
if
(
num
!=
1
)
op
->
Super
.
ErrorCount
++
;
}
}
if
(
num
)
{
fprintf
(
local
->
value_fp
,
"%s"
,
str
);
fflush
(
local
->
value_fp
);
rewind
(
local
->
value_fp
);
}
}
if
(
op
->
Super
.
ErrorCount
>=
op
->
Super
.
ErrorSoftLimit
&&
error_count
<
op
->
Super
.
ErrorSoftLimit
)
{
errh_Warning
(
"IO Card ErrorSoftLimit reached, '%s'"
,
cp
->
Name
);
}
if
(
op
->
Super
.
ErrorCount
>=
op
->
Super
.
ErrorHardLimit
)
{
errh_Error
(
"IO Card ErrorHardLimit reached '%s', IO stopped"
,
cp
->
Name
);
ctx
->
Node
->
EmergBreakTrue
=
1
;
return
IO__ERRDEVICE
;
}
return
IO__SUCCESS
;
}
/* Every method should be registred here. */
pwr_dExport
pwr_BindIoMethods
(
OneWire_AoDevice
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardClose
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_NullMethod
};
otherio/lib/rt/src/rt_io_otherio.meth
View file @
861b0a9b
...
...
@@ -16,6 +16,7 @@ Arduino_Uno
GPIO
GPIO_Module
OneWire_AiDevice
OneWire_AoDevice
Maxim_DS18B20
USB_Agent
Velleman_K8055_Board
...
...
otherio/wbl/mcomp/src/otherio.wb_load
View file @
861b0a9b
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X
295
"
Attr NextCix = "_X3
4
"
Attr NextOix = "_X
300
"
Attr NextCix = "_X3
5
"
Attr NextTix[0] = "_X10"
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
...
...
@@ -904,8 +904,8 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
!/**
! Specifies the action when the errorcounter has reached the error limit.
!
! No no action.
!
! No no action.
! Reset inputs the inputs for the slave are reset.
! Emergency break all I/O is stopped.
!*/
...
...
@@ -2113,7 +2113,8 @@ Volume OtherIO $ClassVolume 0.0.250.10
!*/
Object Debug $Attribute 17 27-OCT-2011 08:55:53.85
Body SysBody 27-OCT-2011 08:58:09.11
Attr Flags = 25167872
Attr PgmName = "Debug"
Attr Flags = 8390656
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
...
...
@@ -2236,8 +2237,8 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
!/**
! Specifies the action when the errorcounter has reached the error limit.
!
! No no action.
!
! No no action.
! Reset inputs the inputs for the slave are reset.
! Emergency break all I/O is stopped.
!*/
...
...
@@ -2806,7 +2807,8 @@ Volume OtherIO $ClassVolume 0.0.250.10
!*/
Object Debug $Attribute 60 27-OCT-2011 08:57:19.86
Body SysBody 27-OCT-2011 08:57:53.68
Attr Flags = 25167872
Attr PgmName = "Debug"
Attr Flags = 8390656
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
...
...
@@ -3423,7 +3425,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
Object Template OneWire_AiDevice 2154266624 01-JAN-1970 01:00:00.00
Body RtBody 0
8-JUN-2011 14:10:37.59
Body RtBody 0
1-NOV-2011 13:33:54.15
Attr Super.Process = 1
Attr Super.ErrorSoftLimit = 50
Attr Super.ErrorHardLimit = 100
...
...
@@ -3445,6 +3447,115 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
Object OneWire_AoDevice $ClassDef 34 01-NOV-2011 13:31:45.25
Body SysBody 01-NOV-2011 13:31:33.55
Attr Editor = 0
Attr Method = 0
Attr Flags = 51280
EndBody
Object RtBody $ObjBodyDef 1 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:52.28
Attr StructName = "OneWire_AoDevice"
Attr NextAix = "_X42"
EndBody
Object Super $Attribute 33 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "Super"
Attr Flags = 393216
Attr TypeRef = "BaseComponent:Class-BaseIOCard"
EndBody
EndObject
Object Status $Attribute 34 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "Status"
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object Family $Attribute 35 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "Family"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object Resolution $Attribute 36 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "Resolution"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object ScanInterval $Attribute 37 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "ScanInterval"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object DataFile $Attribute 38 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "DataFile"
Attr TypeRef = "pwrs:Type-$String256"
EndBody
EndObject
Object Format $Attribute 39 01-NOV-2011 13:32:10.45
Body SysBody 01-NOV-2011 13:32:11.28
Attr PgmName = "Format"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object ErrorValue $Attribute 40 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr PgmName = "ErrorValue"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ChAo $Attribute 41 01-NOV-2011 13:32:25.24
Body SysBody 01-NOV-2011 13:32:30.71
Attr PgmName = "ChAo"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanAo"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 296 01-NOV-2011 13:31:33.55
Object IoCardInit $Method 297 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:32:46.32
Attr MethodName = "OneWire_AoDevice-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 298 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:32:52.67
Attr MethodName = "OneWire_AoDevice-IoCardClose"
EndBody
EndObject
Object IoCardWrite $Method 299 01-NOV-2011 13:33:10.62
Body SysBody 01-NOV-2011 15:49:42.73
Attr MethodName = "OneWire_AoDevice-IoCardWrite"
EndBody
EndObject
EndObject
Object PostCreate $DbCallBack 300 01-NOV-2011 13:31:33.55
Body SysBody 01-NOV-2011 13:31:33.55
Attr MethodName = "BaseIOCard-PostCreate"
EndBody
EndObject
Object Template OneWire_AoDevice 2156625920 01-JAN-1970 01:00:00.00
Body RtBody 01-NOV-2011 13:34:13.61
Attr Super.Process = 1
Attr Super.ErrorSoftLimit = 50
Attr Super.ErrorHardLimit = 100
Attr Super.MaxNoOfChannels = 1
Attr ScanInterval = 1
Attr DataFile = "/sys/bus/w1/devices/w1 bus master/%s/w1_slave"
Attr ChAo.OutPolyType = 1
Attr ChAo.ActValRangeLow = -1.000000e+02
Attr ChAo.ActValRangeHigh = 1.000000e+02
Attr ChAo.SensorSigValRangeLow = -5.000000e+00
Attr ChAo.SensorSigValRangeHigh = 5.000000e+00
Attr ChAo.SigValueUnit = "V"
Attr ChAo.ChannelSigValRangeLow = -5.000000e+00
Attr ChAo.ChannelSigValRangeHigh = 5.000000e+00
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment