Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ArduBlock2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
ArduBlock Source
ArduBlock2
Merge requests
!2
Dev preferences
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Dev preferences
dev_preferences
into
master
Overview
0
Commits
4
Pipelines
0
Changes
10
Merged
Dev preferences
Anian Bühler
requested to merge
dev_preferences
into
master
Apr 24, 2024
Overview
0
Commits
4
Pipelines
0
Changes
10
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
359ba0c5
4 commits,
Apr 24, 2024
10 files
+
227
−
33
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
src/main/java/com/ardublock/translator/block/communication/PlotMessageBlock.java
0 → 100644
+
52
−
0
View file @ 359ba0c5
Edit in single-file editor
Open in Web IDE
package
com.ardublock.translator.block.communication
;
import
java.util.ResourceBundle
;
import
com.ardublock.translator.Translator
;
import
com.ardublock.translator.block.TranslatorBlock
;
import
com.ardublock.translator.block.exception.BlockException
;
import
com.ardublock.translator.block.exception.SocketNullException
;
import
com.ardublock.translator.block.exception.SubroutineNotDeclaredException
;
import
com.ardublock.translator.block.numbers.ConstantStringBlock
;
import
com.ardublock.translator.block.numbers.LocalVariableNumberBlock
;
import
com.ardublock.translator.block.numbers.LocalVariableStringBlock
;
import
com.ardublock.translator.block.numbers.StringBlock
;
import
com.ardublock.translator.block.numbers.VariableNumberBlock
;
import
com.ardublock.translator.block.numbers.VariableStringBlock
;
public
class
PlotMessageBlock
extends
TranslatorBlock
{
private
static
ResourceBundle
uiMessageBundle
=
ResourceBundle
.
getBundle
(
"com/ardublock/block/ardublock"
);
public
PlotMessageBlock
(
Long
blockId
,
Translator
translator
,
String
codePrefix
,
String
codeSuffix
,
String
label
)
{
super
(
blockId
,
translator
,
codePrefix
,
codeSuffix
,
label
);
}
@Override
public
String
toCode
()
throws
SocketNullException
,
SubroutineNotDeclaredException
{
String
VarMarker
=
"><"
;
//split marker for SerialPrintBlock
String
ret
=
""
;
TranslatorBlock
tB_label
=
this
.
getTranslatorBlockAtSocket
(
0
);
TranslatorBlock
tB_value
=
this
.
getRequiredTranslatorBlockAtSocket
(
1
);
if
(!(
tB_label
instanceof
StringBlock
))
{
throw
new
BlockException
(
blockId
,
uiMessageBundle
.
getString
(
"ardublock.error_msg.string_only_slot"
));
}
if
(
tB_label
!=
null
){
StringBuilder
tb_label_buffer
=
new
StringBuilder
(
tB_label
.
toCode
().
replaceAll
(
"\\s*_.new\\b\\s*"
,
""
));
tb_label_buffer
.
replace
(
tb_label_buffer
.
lastIndexOf
(
"\""
),
tb_label_buffer
.
lastIndexOf
(
"\""
)
+
1
,
":\""
);
ret
=
tb_label_buffer
.
toString
()+
VarMarker
;
}
if
(
tB_value
!=
null
){
ret
+=
tB_value
.
toCode
().
replaceAll
(
"\\s*_.new\\b\\s*"
,
""
);
}
return
ret
;
}
}
Loading