Commit ef701ad3 authored by Houkime's avatar Houkime

initial commit

parents
*.import
*~
[submodule "godot_headers"]
path = godot_headers
url = https://github.com/GodotNativeTools/godot_headers
CC := gcc
CCFLAGS := -std=c11 -fPIC -Isrc -I./godot_headers/
LDFLAGS := -rdynamic -shared -pthread -lmodbus
OBJ := src/simple.o
TARGETS := simple/bin/libsimple.so
LIBS :=
.PHONY: all
all: $(TARGETS)
$(OBJ): %.o : %.c
$(CC) -c -o $@ $< $(CCFLAGS)
$(TARGETS): % : $(OBJ)
$(CC) -o $@ $(LIBS) $^ $(CCFLAGS) $(LDFLAGS)
Subproject commit 98ee82599dfe07e17983ad831f5e9ac41068667f
*.import
bin/*.so
\ No newline at end of file
extends Spatial
export var speed = 1.0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
var mat = $belt/graphics.get_surface_material(0)
mat.set_shader_param("speed",speed)
$StaticBody.constant_linear_velocity.x = speed
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
[gd_scene load_steps=13 format=2]
[ext_resource path="res://outline.tres" type="Material" id=1]
[ext_resource path="res://belt.shader" type="Shader" id=2]
[ext_resource path="res://Conveyor.gd" type="Script" id=3]
[ext_resource path="res://test_bevel.obj" type="ArrayMesh" id=4]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
flags_unshaded = true
albedo_color = Color( 0.564706, 0.564706, 0.564706, 1 )
[sub_resource type="ArrayMesh" id=3]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="CubeMesh" id=4]
[sub_resource type="ArrayMesh" id=5]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="PlaneMesh" id=6]
[sub_resource type="ShaderMaterial" id=7]
shader = ExtResource( 2 )
shader_param/bg_color = null
shader_param/fg_color = Color( 0.976471, 0.917647, 0.0196078, 1 )
shader_param/scale = null
shader_param/speed = 0.1
[sub_resource type="ConvexPolygonShape" id=8]
points = PoolVector3Array( -0.986604, -0.9557, -0.832278, -0.986604, -0.9557, 0.832278, -0.986604, -0.832278, -0.9557, -0.986604, -0.832278, 0.9557, -0.986604, 0.832278, -0.9557, -0.986604, 0.832278, 0.9557, -0.986604, 0.9557, -0.832278, -0.986604, 0.9557, 0.832278, -0.985938, -0.924172, -0.893482, -0.9557, -0.986604, -0.832278, -0.9557, -0.986604, 0.832278, -0.9557, -0.832278, -0.986604, -0.9557, -0.832278, 0.986604, -0.9557, 0.832278, -0.986604, -0.9557, 0.832278, 0.986604, -0.9557, 0.986604, -0.832278, -0.9557, 0.986604, 0.832278, -0.9537, -0.9537, -0.9537, -0.9537, -0.9537, 0.9537, -0.9537, 0.9537, -0.9537, -0.9537, 0.9537, 0.9537, -0.832278, -0.986604, -0.9557, -0.832278, -0.986604, 0.9557, -0.832278, -0.9557, -0.986604, -0.832278, -0.9557, 0.986604, -0.832278, 0.9557, -0.986604, -0.832278, 0.9557, 0.986604, -0.832278, 0.986604, -0.9557, -0.832278, 0.986604, 0.9557, 0.832278, -0.986604, -0.9557, 0.832278, -0.986604, 0.9557, 0.832278, -0.9557, -0.986604, 0.832278, -0.9557, 0.986604, 0.832278, 0.9557, -0.986604, 0.832278, 0.9557, 0.986604, 0.832278, 0.986604, -0.9557, 0.832278, 0.986604, 0.9557, 0.893315, 0.924199, 0.985967, 0.9537, -0.9537, -0.9537, 0.9537, -0.9537, 0.9537, 0.9537, 0.9537, -0.9537, 0.9537, 0.9537, 0.9537, 0.9557, -0.986604, -0.832278, 0.9557, -0.986604, 0.832278, 0.9557, -0.832278, -0.986604, 0.9557, -0.832278, 0.986604, 0.9557, 0.832278, -0.986604, 0.9557, 0.832278, 0.986604, 0.9557, 0.986604, -0.832278, 0.9557, 0.986604, 0.832278, 0.986604, -0.9557, -0.832278, 0.986604, -0.9557, 0.832278, 0.986604, -0.832278, -0.9557, 0.986604, -0.832278, 0.9557, 0.986604, 0.832278, -0.9557, 0.986604, 0.832278, 0.9557, 0.986604, 0.9557, -0.832278, 0.986604, 0.9557, 0.832278 )
[node name="Conveyor" type="Spatial"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
script = ExtResource( 3 )
[node name="base" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.8, 0, 0, 0, 1, 0, -0.2, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="base"]
material_override = ExtResource( 1 )
mesh = SubResource( 3 )
material/0 = null
[node name="belt" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0.8, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="MeshInstance" type="MeshInstance" parent="belt"]
mesh = SubResource( 5 )
material/0 = ExtResource( 1 )
[node name="graphics" type="MeshInstance" parent="belt"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.02021, 0 )
mesh = SubResource( 6 )
material/0 = SubResource( 7 )
[node name="StaticBody" type="StaticBody" parent="."]
constant_linear_velocity = Vector3( 0.1, 0, 0 )
[node name="test_bevel" type="MeshInstance" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
visible = false
mesh = ExtResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1.2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
shape = SubResource( 8 )
extends KinematicBody
var phase = 0.0
var freq = 1.0
var rot_freq = 2.0
var amplitude = 1.0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
phase = wrapf(phase + freq*delta,0,2*PI)
translation = Vector3(0,amplitude*sin(phase),0)
rotate_x(freq*delta)
rotate_y(freq*delta)
rotate_z(freq*delta/2.0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Node
class_name ModbusServer
var c_backend = load('res://simple.gdns').new()
var hold_register = 17 setget set_holding_register, get_holding_register #single for now
#var coils = [0,0,0,0]
func _init(address, port):
c_backend.start_server(address, port)
func set_holding_register(value):
c_backend.set_holding_register(value)
func get_holding_register():
return c_backend.get_holding_register()
func get_coil():
return c_backend.get_coil()
extends Spatial
class_name ModbusSpatial
export var address = "192.168.56.1"
export var port = 5020
var ms
func _ready():
print("creating sth with " + address + " " + str(port))
ms = ModbusServer.new(address, port)
[gd_scene load_steps=14 format=2]
[ext_resource path="res://SimplePusher.gd" type="Script" id=1]
[ext_resource path="res://Spawner.gd" type="Script" id=2]
[ext_resource path="res://pushermat.tres" type="Material" id=3]
[ext_resource path="res://Sensor.tscn" type="PackedScene" id=4]
[ext_resource path="res://Conveyor.tscn" type="PackedScene" id=5]
[ext_resource path="res://blockshader_ghost.shader" type="Shader" id=6]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 6 )
shader_param/color = Color( 0.227451, 0.521569, 0.521569, 1 )
shader_param/scale = 113.0
[sub_resource type="CubeMesh" id=3]
[sub_resource type="CubeMesh" id=4]
[sub_resource type="SpatialMaterial" id=5]
flags_unshaded = true
albedo_color = Color( 0.207843, 0.207843, 0.207843, 1 )
[sub_resource type="ConvexPolygonShape" id=6]
points = PoolVector3Array( -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 )
[sub_resource type="CylinderMesh" id=7]
[node name="Pushertest" type="Spatial"]
[node name="Spawner" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="Spawner"]
transform = Transform( 0.48, 0, 0, 0, 0.48, 0, 0, 0, 0.48, 0, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 2.01221, 6.90506 )
far = 8192.0
[node name="Pusher" type="Spatial" parent="."]
transform = Transform( -8.14603e-08, 0, -0.5, 0, 0.5, 0, 0.5, 0, -8.14603e-08, 5, 1, -1 )
script = ExtResource( 1 )
port = 5040
[node name="MeshInstance" type="MeshInstance" parent="Pusher"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 0, 0 )
mesh = SubResource( 3 )
material/0 = ExtResource( 3 )
[node name="PusherHandle" type="Spatial" parent="Pusher"]
[node name="MeshInstance2" type="MeshInstance" parent="Pusher/PusherHandle"]
transform = Transform( 0.2, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 0 )
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
[node name="KinematicBody" type="KinematicBody" parent="Pusher/PusherHandle"]
[node name="CollisionShape" type="CollisionShape" parent="Pusher/PusherHandle/KinematicBody"]
transform = Transform( 0.2, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 0 )
shape = SubResource( 6 )
[node name="shaft_handle" type="Spatial" parent="Pusher"]
transform = Transform( -1.31134e-08, -0.1, 0, 0.3, -4.37114e-09, 0, 0, 0, 0.3, 0.6, 0, 0 )
[node name="MeshInstance2" type="MeshInstance" parent="Pusher/shaft_handle"]
transform = Transform( 1, 7.10543e-15, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
mesh = SubResource( 7 )
material/0 = null
[node name="Conveyor" parent="." instance=ExtResource( 5 )]
[node name="Conveyor2" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1, 0, 0 )
[node name="Conveyor3" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 2, 0, 0 )
[node name="Conveyor4" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 3, 0, 0 )
[node name="Conveyor5" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 4, 0, 0 )
[node name="Conveyor6" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 5, 0, 0 )
[node name="Conveyor7" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 6, 0, 0 )
[node name="Sensor" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 4, 0 )
extends ModbusSpatial
func _physics_process(delta):
ms.hold_register = floor($RayCast.distance*100.0)
This source diff could not be displayed because it is too large. You can view the blob instead.
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Kinematic_Cube.gd" type="Script" id=1]
[ext_resource path="res://distance_readout.gd" type="Script" id=2]
[ext_resource path="res://Sensor.gd" type="Script" id=3]
[ext_resource path="res://Sensor.tscn" type="PackedScene" id=4]
[sub_resource type="CubeMesh" id=2]
[sub_resource type="SpatialMaterial" id=3]
flags_unshaded = true
albedo_color = Color( 0.87451, 1, 0, 1 )
[sub_resource type="ArrayMesh" id=4]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="SpatialMaterial" id=5]
flags_unshaded = true
[sub_resource type="BoxShape" id=6]
[node name="SensorTest" type="Spatial"]
[node name="Sensor" type="Spatial" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )
script = ExtResource( 3 )
[node name="test_equilibrium" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
[node name="Kinematic_Cube" type="KinematicBody" parent="test_equilibrium"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -4.76837e-07, -4.76837e-07 )
script = ExtResource( 1 )
[node name="test_cube" type="MeshInstance" parent="test_equilibrium/Kinematic_Cube"]
mesh = SubResource( 2 )
material/0 = SubResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="test_equilibrium/Kinematic_Cube/test_cube"]
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape" parent="test_equilibrium/Kinematic_Cube"]
shape = SubResource( 6 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.88643, 0.462863, 0, -0.462863, 0.88643, 0, 4.71983, 6.1721 )
far = 8192.0
[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
extends ModbusSpatial
var speed = 1;
var max_extension = 1.0;
var extension = 0;
var min_shaft_len = 0.1; # godot does not like zero-lenth things
func _physics_process(delta):
var needs_to_extend = ms.get_coil()
#var needs_to_extend = false
#var just_to_read = ms.get_coil()
#print(needs_to_extend)
if needs_to_extend and extension < max_extension:
extension = clamp($PusherHandle.translation.x/2.0 + speed * delta, 0, max_extension)
$PusherHandle.translation.x = extension * 2
$shaft_handle.scale.y = max(extension, min_shaft_len)
if !needs_to_extend and extension > 0:
extension = clamp($PusherHandle.translation.x/2.0 - speed * delta, 0, max_extension)
$PusherHandle.translation.x = extension * 2
$shaft_handle.scale.y = max(extension, min_shaft_len)
extends Spatial
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Spatial.gd" type="Script" id=1]
[ext_resource path="res://skyshader.tres" type="Material" id=2]
[ext_resource path="res://Pushertest.tscn" type="PackedScene" id=3]
[ext_resource path="res://firewall.gd" type="Script" id=7]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 13.3624, 1, 18.5475 )
[sub_resource type="SphereMesh" id=2]
flip_faces = true
[node name="MAIN" type="Spatial"]
script = ExtResource( 1 )
[node name="Pushertest" parent="." instance=ExtResource( 3 )]
[node name="Area" type="Area" parent="."]
script = ExtResource( 7 )
__meta__ = {
"_edit_lock_": true
}
[node name="CollisionShape" type="CollisionShape" parent="Area"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -6.34348, 0 )
shape = SubResource( 1 )
[node name="Sky" type="MeshInstance" parent="."]
transform = Transform( 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0 )
mesh = SubResource( 2 )
material/0 = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true
}
extends Spatial
export var frequency = 0.3
onready var timer = Timer.new()
var boxscene = preload("res://TestBox.tscn")
func _ready():
timer.wait_time = 1.0/float(frequency)
timer.connect("timeout",self,"spawn")
add_child(timer)
timer.start()
spawn()
func spawn():
var box = boxscene.instance()
add_child(box)
[gd_scene load_steps=4 format=2]
[ext_resource path="res://basic_cube.tscn" type="PackedScene" id=1]
[sub_resource type="PhysicsMaterial" id=1]
rough = true
[sub_resource type="BoxShape" id=2]
[node name="TestCube" type="RigidBody"]
physics_material_override = SubResource( 1 )
can_sleep = false
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
shape = SubResource( 2 )
[node name="test_cube" parent="." instance=ExtResource( 1 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
[gd_scene load_steps=4 format=2]
[ext_resource path="res://blockshader.shader" type="Shader" id=1]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/color = Color( 0.686275, 0.65098, 0.0784314, 1 )
shader_param/scale = 113.0
[node name="test_cube" type="MeshInstance"]
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
shader_type spatial;
render_mode unshaded;
uniform vec4 bg_color: hint_color;
uniform vec4 fg_color: hint_color;
uniform float scale;
uniform float speed;
bool triangle(float x,float y){
// if (x < 0.3) {
// return false;
// }
if (abs(y-0.5)+x-0.5 > 0.5) {
return false;
}
if (abs(y-0.5)+x-0.5 < 0.3) {
return false;
}
return true;
}
void fragment(){
float x = UV.x;
float y = UV.y;
float unity = 1.0;
x -= TIME*speed;
x = x - floor(x);
if (triangle(x,y)){
ALBEDO = fg_color.xyz;
} else{
ALBEDO = bg_color.xyz;
}
}
shader_type spatial;
render_mode unshaded;
uniform vec4 color: hint_color;
uniform float scale;
void fragment()
{
ALBEDO=color.xyz;
if (cos(UV.x*scale/6.)>=0.9||cos(UV.y*scale/9.)>=0.9){
ALBEDO=vec3(1,1,1);
}
}
\ No newline at end of file
shader_type spatial;
render_mode unshaded;
render_mode blend_add;
uniform vec4 color: hint_color;
uniform float scale;
void fragment()
{
float screen_y = mod(SCREEN_UV.y + TIME/30.0, 1.0);
if (mod(screen_y, 1.0/100.0) <= 0.005){
discard;
}
ALBEDO=color.xyz;
if (cos(UV.x*scale/6.)>=0.9||cos(UV.y*scale/9.)>=0.9){
ALBEDO=vec3(1,1,1);
}
}
\ No newline at end of file
extends Label
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
text = "Distance: " + str($"../Sensor/RayCast".distance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Area
func _ready():
connect("body_entered",self,"destroy_intruders")
func destroy_intruders(body):
body.queue_free()
[entry]
X11.64="res://bin/libsimple.so"
[dependencies]
X11.64=[ ]
[general]
singleton=false
load_once=false
symbol_prefix="godot_"
reloadable=true
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_sky = SubResource( 1 )
[gd_resource type="SpatialMaterial" format=2]
[resource]
flags_unshaded = true
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "Node",
"class": "ModbusServer",
"language": "GDScript",
"path": "res://Modbus_Server.gd"
}, {
"base": "Reference",
"class": "ModbusServerNative",
"language": "NativeScript",
"path": "res://simple.gdns"
}, {
"base": "Spatial",
"class": "ModbusSpatial",
"language": "GDScript",
"path": "res://Modbus_Spatial.gd"
} ]
_global_script_class_icons={
"ModbusServer": "",
"ModbusServerNative": "",
"ModbusSpatial": ""
}
[application]
run/main_scene="res://Spatial.tscn"
[physics]
3d/physics_engine="GodotPhysics"
[rendering]
environment/default_environment="res://new_environment.tres"
[gd_resource type="SpatialMaterial" format=2]
[resource]
flags_unshaded = true
albedo_color = Color( 0.988235, 0.694118, 0.0745098, 1 )
extends RayCast
export var maxlength = 10.0
var distance = 0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
cast_to = Vector3(0,-maxlength,0)
func _physics_process(delta):
if !is_colliding():
$intersection.visible = false
$ray_handle.scale = Vector3(0,distance,0)
return
var collision_p = to_local(get_collision_point())
distance = collision_p.length()
$ray_handle.scale = Vector3(1,distance,1)
$intersection.visible = true
$intersection.translation = collision_p
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://libsimple.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "ModbusServerNative"
library = ExtResource( 1 )
script_class_name = "ModbusServerNative"
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode unshaded;
uniform float thickness;
uniform float step_theta;
uniform float step_phi;
void fragment(){
if (mod(UV.y,step_theta*abs(1.0+sin(TIME/10.0)/2.0)) < thickness) {
ALBEDO=vec3(255,0,255);
} else{
ALBEDO=vec3(0,0,0);
}
}"
[resource]
shader = SubResource( 1 )
shader_param/thickness = 0.01
shader_param/step_theta = 0.056
shader_param/step_phi = null
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
This diff is collapsed.
#include "../godot_headers/gdnative_api_struct.gen.h"
#include <unistd.h>
#include <asm/unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus/modbus.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/syscall.h>
const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
void *modbus_constructor(godot_object *p_instance, void *p_method_data);
void modbus_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data);
godot_variant modbus_get_data(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args);
typedef struct user_data_struct {
modbus_t *ctx;
modbus_mapping_t *mb_mapping;
} user_data_struct;
user_data_struct ud;
//typedef struct server_parameters {
// int port;
// char *address;
//} server_parameters;
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options)
{
api = p_options->api_struct;
// Now find our extensions.
for (int i = 0; i < api->num_extensions; i++) {
switch (api->extensions[i]->type) {
case GDNATIVE_EXT_NATIVESCRIPT: {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
}; break;
default: break;
}
}
}
void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options)
{
api = NULL;
nativescript_api = NULL;
}
void *server_routine(void *user_data_void_p)
{
user_data_struct *user_data = (user_data_struct *) user_data_void_p;
//printf("in server_routine address is %s and port is %d\n", user_data->ctx->address, user_data->ctx->port);
int s = -1;
for (;;) {
s = modbus_tcp_listen(user_data->ctx, 1);
printf("before accept\n");
printf("[%d]: outer loop \n", syscall(__NR_gettid));
modbus_tcp_accept(user_data->ctx, &s);
for (;;) {
uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
int rc;
printf("[%d]: inner loop entry\n", syscall(__NR_gettid));
rc = modbus_receive(user_data->ctx, query);
if (rc > 0) {
/* rc is the query size */
modbus_reply(user_data->ctx, query, rc, user_data->mb_mapping);
} else if (rc == -1) {
/* Connection closed by the client or error */
break;
}
}
printf("Quit the loop: %s\n", modbus_strerror(errno));
if (s != -1) {
close(s);
}
}
modbus_mapping_free(user_data->mb_mapping);
modbus_close(user_data->ctx);
modbus_free(user_data->ctx);
}
void *modbus_constructor(godot_object *p_instance, void *p_method_data)
{
user_data_struct *user_data = api->godot_alloc(sizeof(user_data_struct));
// init is delayed so that we can pass arguments normally
return user_data;
}
void modbus_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data)
{
api->godot_free(p_user_data);
}
godot_variant modbus_get_holding_register(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
int value = user_data->mb_mapping->tab_registers[reg_num];
api->godot_variant_new_int(&ret, value);
return ret;
}
godot_variant modbus_set_holding_register(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
godot_variant *gd_value = p_args[0];
int value = api->godot_variant_as_int(gd_value);
user_data->mb_mapping->tab_registers[reg_num]=value;
return ret;
}
godot_variant modbus_set_coil(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
godot_variant *gd_value = p_args[0];
bool value = api->godot_variant_as_bool(gd_value);
modbus_set_bits_from_byte(&user_data->mb_mapping->tab_bits[0], reg_num, (uint8_t) value);
return ret;
}
godot_variant modbus_get_coil(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
int bit_idx = 0;
uint8_t value = user_data->mb_mapping->tab_bits[reg_num];
printf("get coil native: %d\n", value);
value = ((value >> bit_idx) & 0x01);
api -> godot_variant_new_bool(&ret, (godot_bool) value); //godot_bool is just a typedefed bool
return ret;
}
godot_variant modbus_start_server(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
//server_parameters srv_parameters;
pthread_t server_thread;
//pthread_attr_t attr;
int port;
const char* address;
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
//pthread_attr_init(&attr);
// start_server(address,port)
godot_variant *gd_variant_address = p_args[0];
godot_variant *gd_variant_port = p_args[1];
port = api->godot_variant_as_int(gd_variant_port);
godot_string gd_string_address = api->godot_variant_as_string(gd_variant_address);
godot_char_string gd_string_ascii_address = api->godot_string_ascii(&gd_string_address);
address = api->godot_char_string_get_data(&gd_string_ascii_address);
user_data->ctx = modbus_new_tcp(address, port);
printf("created new context with address %s and port %d\n", address, port);
user_data->mb_mapping = modbus_mapping_new(500, 500, 500, 500);
if (user_data->mb_mapping == NULL) {
fprintf(stderr, "Failed to allocate the mapping: %s\n",
modbus_strerror(errno));
modbus_free(user_data->ctx);
return ret;
}
pthread_create(&server_thread, NULL, &server_routine, user_data);
return ret;
}
void GDN_EXPORT godot_nativescript_init(void *p_handle)
{
godot_instance_create_func create = { NULL, NULL, NULL };
create.create_func = &modbus_constructor;
godot_instance_destroy_func destroy = { NULL, NULL, NULL };
destroy.destroy_func = &modbus_destructor;
nativescript_api->godot_nativescript_register_class(p_handle, "ModbusServerNative", "Reference",
create, destroy);
godot_method_attributes attributes = { GODOT_METHOD_RPC_MODE_DISABLED };
godot_instance_method get_holding_register = { NULL, NULL, NULL };
get_holding_register.method = &modbus_get_holding_register;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "get_holding_register",
attributes, get_holding_register);
godot_instance_method set_holding_register = { NULL, NULL, NULL };
set_holding_register.method = &modbus_set_holding_register;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "set_holding_register",
attributes, set_holding_register);
godot_instance_method start_server = { NULL, NULL, NULL };
start_server.method = &modbus_start_server;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "start_server",
attributes, start_server);
godot_instance_method set_coil = { NULL, NULL, NULL };
set_coil.method = &modbus_set_coil;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "set_coil",
attributes, set_coil);
godot_instance_method get_coil = { NULL, NULL, NULL };
get_coil.method = &modbus_get_coil;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "get_coil",
attributes, get_coil);
}
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