Skip to content

Commit

Permalink
Fixed lathe tool initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
dragossusi committed Oct 19, 2024
1 parent 2d208f3 commit 915e2f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,23 @@ internal class DummyToolsInitializer(private val database: KtcncDatabase, privat
}

private suspend fun createDummyTools() {
val entities = listOf(
LatheToolEntity(
insertId = getInsertByCode("DCMT").id,
type = ToolType.Turning,
tipOrientation = TipOrientation.Position2.orient,
frontAngle = 0.0,
backAngle = 0.0,
spindleDirection = SpindleDirection.Reverse,
)
),
LatheToolEntity(
insertId = getInsertByCode("VCMT").id,
type = ToolType.Turning,
tipOrientation = TipOrientation.Position2.orient,
frontAngle = 0.0,
backAngle = 0.0,
spindleDirection = SpindleDirection.Reverse,
)
),
LatheToolEntity(
insertId = getInsertByCode("CCMT").id,
type = ToolType.Boring,
Expand All @@ -104,22 +105,24 @@ internal class DummyToolsInitializer(private val database: KtcncDatabase, privat
spindleDirection = SpindleDirection.Reverse,
minBoreDiameter = 20.0,
maxZDepth = 50.0,
)
),
LatheToolEntity(
insertId = getInsertByCode("VCMT").id,
tipOrientation = TipOrientation.Position7.orient,
spindleDirection = SpindleDirection.Reverse,
type = ToolType.Parting,
bladeWidth = 2.0,
maxXDepth = 20.0,
)
),
LatheToolEntity(
type = ToolType.Drilling,
tipOrientation = TipOrientation.Position7.orient,
spindleDirection = SpindleDirection.Reverse,
toolDiameter = 8.0,
maxZDepth = 80.0,
),
)
database.latheToolDao.insertAll(entities)
}

private suspend fun getInsertByCode(code: String): CuttingInsertEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.mindovercnc.linuxcnc.tools.LatheToolRepository
import com.mindovercnc.linuxcnc.tools.model.LatheTool
import com.mindovercnc.linuxcnc.tools.model.ToolType
import com.mindovercnc.model.TipOrientation
import mu.KotlinLogging

/** Implementation for [LatheToolRepository]. */
class LatheToolRepositoryLocal(
Expand All @@ -15,7 +16,9 @@ class LatheToolRepositoryLocal(
) : LatheToolRepository {

override suspend fun getLatheTools(): List<LatheTool> {
return latheToolDao.getAll().mapNotNull { it.toLatheTool() }
return latheToolDao.getAll().also {
LOG.info { "Found ${it.size} lathe tools" }
}.mapNotNull { it.toLatheTool() }
}

override suspend fun getUnmountedLatheTools(): List<LatheTool> {
Expand Down Expand Up @@ -242,7 +245,14 @@ class LatheToolRepositoryLocal(
bladeWidth = bladeWidth!!,
maxZDepth = maxZDepth ?: 0.0
)
else -> null
else -> {
LOG
null
}
}
}

private companion object {
val LOG = KotlinLogging.logger("LatheToolRepository")
}
}

0 comments on commit 915e2f6

Please sign in to comment.